package sign import ( "encoding/json" "errors" "fmt" "mtp20access/global" "mtp20access/model/account" "mtp20access/model/account/request" "mtp20access/service/asign" "strconv" "go.uber.org/zap" ) // QueryUserESignRecord 查询用户电子签记录表 func QueryUserESignRecord(userId int) (rsp []account.Useresignrecord, err error) { rsp = make([]account.Useresignrecord, 0) err = global.M2A_DB.Where("USERID = ?", userId).Find(&rsp) return } // AddUser 添加用户 func AddUser(req request.AddUserReq, userId int) (err error) { // 调用爱签API-添加个人用户(https://{host}/user/addPersonalUser) rsp, err := asign.AddPersonalUserBy( strconv.Itoa(userId), req.Name, req.IdCard, req.Mobile, req.IdCardType, ) if err != nil { return } if rsp.Code != 100000 { err = errors.New(strconv.Itoa(rsp.Code)) global.M2A_LOG.Error("【AddUser】 接口调用失败", zap.Error(err)) return } // 更新用户电子签记录-实名认证状态 authinfo, err := json.Marshal(req) if err != nil { global.M2A_LOG.Error("【AddUser】 构建AUTHINFO失败", zap.Error(err)) return } sql := fmt.Sprintf(` UPDATE useresignrecord SET RECORDSTATUS = 3, UPDATETIME = SYSDATE, AUTHINFO = '%v' WHERE USERID = %v `, string(authinfo), userId) if _, err = global.M2A_DB.Exec(sql); err != nil { global.M2A_LOG.Error("【AddUser】 添加用户电子签记录", zap.Error(err)) return } return }