| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- package asign
- import (
- "encoding/json"
- "mtp2_if/config"
- "mtp2_if/logger"
- "github.com/fatih/structs"
- )
- // APIPersonBankCard4 个人银行卡四要素认证
- func APIPersonBankCard4(req APIPersonBankCard4Req) (rsp *APIRsp[APIBankCard4Rsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/auth/person/bankCard4"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIBankCard4Rsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APICompanyBankCard4 企业法人银行卡四要素认证
- func APICompanyBankCard4(req APICompanyBankCard4Req) (rsp *APIRsp[APIBankCard4Rsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/auth/company/bankCard4"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIBankCard4Rsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APICaptchaVerify 认证验证码校验
- func APICaptchaResend(req APICaptchaResendReq) (rsp *APIRsp[interface{}], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/auth/captcha/resend"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[interface{}])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APICaptchaVerify 认证验证码校验
- func APICaptchaVerify(req APICaptchaVerifyReq) (rsp *APIRsp[APICaptchaVerifyRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/auth/captcha/verify"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APICaptchaVerifyRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APIGetUser 查询用户信息
- func APIGetUser(req APIGetUserReq) (rsp *APIRsp[[]APIGetUserRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/user/getUser"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[[]APIGetUserRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APIAddPersonalUser 添加个人用户(V2)
- func APIAddPersonalUser(req APIAddPersonalUserReq) (rsp *APIRsp[APIAddUserRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/v2/user/addPersonalUser"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIAddUserRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APIAddEnterpriseUser 添加企业用户(V2)
- func APIAddEnterpriseUser(req APIAddEnterpriseUserReq) (rsp *APIRsp[APIAddUserRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/v2/user/addEnterpriseUser"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIAddUserRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APITemplateList 查询模板列表
- func APITemplateList(req APITemplateListReq) (rsp *APIRsp[APITemplateListRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/template/list"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APITemplateListRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APICreateContract 上传待签署文件
- func APICreateContract(req APICreateContractReq) (rsp *APIRsp[APICreateContractRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/contract/createContract"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APICreateContractRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APIAddSigner 添加签署方
- func APIAddSigner(req []APIAddSignerReq) (rsp *APIRsp[APIAddSignerRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/contract/addSigner"
- reqArray := make([]map[string]interface{}, 0)
- for _, item := range req {
- reqArray = append(reqArray, structs.Map(item))
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqArray)
- rspBody, err := HttpPost2(apiUrl, reqArray)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIAddSignerRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
- // APIContractStatus 查询合同状态
- func APIContractStatus(req APIContractStatusReq) (rsp *APIRsp[APIContractStatusRsp], err error) {
- apiUrl := config.SerCfg.AsignCfg.Url + "/contract/status"
- reqMap := structs.Map(req)
- logger.GetLogger().Info("调用接口 "+apiUrl+" 请求, request:", reqMap)
- rspBody, err := HttpPost(apiUrl, reqMap)
- if err != nil {
- logger.GetLogger().Error("调用接口 "+apiUrl+" 错误, error:", err.Error())
- return
- }
- rspStr := string(rspBody)
- if len(rspStr) == 0 {
- logger.GetLogger().Error("调用接口 " + apiUrl + " 错误, response为空")
- return
- }
- logger.GetLogger().Info("调用接口 "+apiUrl+" 返回, response:", rspStr)
- rsp = new(APIRsp[APIContractStatusRsp])
- err = json.Unmarshal(rspBody, rsp)
- return
- }
|