Commit 3ba508c9 authored by 宋永孟's avatar 宋永孟

add 联调token

parent d5579c1d
...@@ -47,5 +47,6 @@ class URLs { ...@@ -47,5 +47,6 @@ class URLs {
const val authPersonalGetToken = "/Identify/IdOcr/getBizToken" const val authPersonalGetToken = "/Identify/IdOcr/getBizToken"
const val getKSYunToken = "/ksy/Ksyun/getToken" const val getKSYunToken = "/ksy/Ksyun/getToken"
const val getIDCardOCR = "Identify/IdOcr/idCardOcr" const val getIDCardOCR = "Identify/IdOcr/idCardOcr"
const val identifyIdOcrVerify = "/Identify/IdOcr/verify"
} }
} }
\ No newline at end of file
...@@ -22,6 +22,22 @@ import org.json.JSONObject ...@@ -22,6 +22,22 @@ import org.json.JSONObject
class ApiService { class ApiService {
companion object { companion object {
//获取活体检测接口
fun identifyIdOcrVerify(apiCallback: IdentifyIdOcrVerifyCallback, requestParams: IdentifyIdOcrVerifyBean.Request) {
val paramsMap = HttpParamsUtils.getParamsMap()
ServiceFactory.getInstance().createService(CommonService::class.java)
.identifyIdOcrVerify(paramsMap, requestParams)
.compose(TransformUtil.defaultSchedulers())
.subscribe(object : HttpResultSubscriber<Any?>() {
override fun onSuccess(result: HttpResult<Any?>?) {
apiCallback.identifyIdOcrVerifySuccess(result)
}
override fun onFailer(result: HttpResult<Any?>?) {
}
})
}
//获取活体检测接口 //获取活体检测接口
fun authPersonalGetToken(apiCallback: AuthPersonalGetTokenCallback, requestParams: AuthPersonalGetTokenBean.Request) { fun authPersonalGetToken(apiCallback: AuthPersonalGetTokenCallback, requestParams: AuthPersonalGetTokenBean.Request) {
val paramsMap = HttpParamsUtils.getParamsMap() val paramsMap = HttpParamsUtils.getParamsMap()
......
...@@ -115,5 +115,9 @@ interface CommonService { ...@@ -115,5 +115,9 @@ interface CommonService {
@Headers("Content-Type: application/json") @Headers("Content-Type: application/json")
@POST(URLs.getIDCardOCR) @POST(URLs.getIDCardOCR)
fun getIDCardOCR(@QueryMap commonParams: Map<String, String>, @Body requestParams: GetIDCardOCRBean.Request) : Observable<HttpResult<GetIDCardOCRBean.Response?>> fun getIDCardOCR(@QueryMap commonParams: Map<String, String>, @Body requestParams: GetIDCardOCRBean.Request): Observable<HttpResult<GetIDCardOCRBean.Response?>>
@Headers("Content-Type: application/json")
@POST(URLs.identifyIdOcrVerify)
fun identifyIdOcrVerify(@QueryMap commonParams: Map<String, String>, @Body requestParams: IdentifyIdOcrVerifyBean.Request): Observable<HttpResult<Any?>>
} }
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.http.httpbean
class IdentifyIdOcrVerifyBean(var request: Request, val response: Response) {
data class Request(var biz_token: String, var meglive_data: String)
data class Response(val biz_token: String)
}
package com.yidian.shenghuoquan.newscontent.http.httpbean
import com.yidian.common.http.HttpResult
interface IdentifyIdOcrVerifyCallback {
fun identifyIdOcrVerifySuccess(t: HttpResult<Any?>?)
}
\ No newline at end of file
...@@ -13,6 +13,8 @@ import com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBindin ...@@ -13,6 +13,8 @@ import com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBindin
import com.yidian.shenghuoquan.newscontent.http.ApiService import com.yidian.shenghuoquan.newscontent.http.ApiService
import com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean import com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback import com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback
import com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyCallback
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.InputStream import java.io.InputStream
...@@ -24,6 +26,7 @@ import java.io.InputStream ...@@ -24,6 +26,7 @@ import java.io.InputStream
*/ */
class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallback, DetectCallback { class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallback, DetectCallback {
private var sign = "" private var sign = ""
private var bizToken = ""
private var megLiveManager: MegLiveManager? = null private var megLiveManager: MegLiveManager? = null
private var modelPath = "" // 模型本地存放路径 private var modelPath = "" // 模型本地存放路径
private var mProgressDialog: ProgressDialog? = null private var mProgressDialog: ProgressDialog? = null
...@@ -64,7 +67,8 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -64,7 +67,8 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
private val authPersonalGetTokenCallback = object : AuthPersonalGetTokenCallback { private val authPersonalGetTokenCallback = object : AuthPersonalGetTokenCallback {
override fun getTokenSuccess(t: HttpResult<AuthPersonalGetTokenBean.Response?>?) { override fun getTokenSuccess(t: HttpResult<AuthPersonalGetTokenBean.Response?>?) {
Log.d("song_test", t?.result?.biz_token) Log.d("song_test", t?.result?.biz_token)
megLiveManager?.preDetect(this@AliveTestActivity, t?.result?.biz_token, "zh", "https://api.megvii.com", modelPath, this@AliveTestActivity) bizToken = t?.result?.biz_token!!
megLiveManager?.preDetect(this@AliveTestActivity, bizToken, "zh", "https://api.megvii.com", modelPath, this@AliveTestActivity)
} }
} }
...@@ -132,6 +136,9 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -132,6 +136,9 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
override fun onDetectFinish(token: String?, errorCode: Int, errorMessage: String?, data: String?) { override fun onDetectFinish(token: String?, errorCode: Int, errorMessage: String?, data: String?) {
if (errorCode == 1000) { if (errorCode == 1000) {
token?.let { verify(it, data!!.toByteArray()) } token?.let { verify(it, data!!.toByteArray()) }
val requestParams: IdentifyIdOcrVerifyBean.Request = IdentifyIdOcrVerifyBean.Request(bizToken, data!!)
ApiService.identifyIdOcrVerify(identifyIdOcrVerifyCallback, requestParams)
} }
} }
...@@ -139,5 +146,10 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -139,5 +146,10 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
showDialogDismiss() showDialogDismiss()
} }
private val identifyIdOcrVerifyCallback = object : IdentifyIdOcrVerifyCallback {
override fun identifyIdOcrVerifySuccess(t: HttpResult<Any?>?) {
//人脸验证成功
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment