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 }