123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package query
- import (
- "context"
- jsoniter "github.com/json-iterator/go"
- "gd_adm_data/apis"
- "gd_adm_data/errors"
- "git.getensh.com/common/gopkgsv2/database"
- "gorm.io/gorm"
- )
- type v02Request struct {
- IdCard string `json:"id_card"`
- Name string `json:"name"`
- }
- type v02Response struct {
- IsMatch int32 `json:"is_match"`
- UpdatedAt int64 `json:"updated_at"`
- }
- type ads20Response struct {
- Name string `json:"name"`
- UpdatedAt int64 `json:"updated_at"`
- }
- // 人名身份证验证
- func V02(ctx context.Context, params string) (reply *apis.QueryResponse, err error) {
- reply = &apis.QueryResponse{}
- var req v02Request
- err = jsoniter.UnmarshalFromString(params, &req)
- if err != nil || (req.Name == "" || req.IdCard == "") {
- return nil, errors.ParamsError
- }
- var res v02Response
- var ads20 ads20Response
- //var name string
- //var updatedAt int64
- db := database.DB()
- err = db.Raw("select name,updated_at from t_adm_dws15 where id_card = ?", req.IdCard).Find(&ads20).Error
- if err != nil {
- if err == gorm.ErrRecordNotFound {
- return reply, errors.DataNotExistError
- }
- return reply, errors.SystemError
- }
- res.UpdatedAt = ads20.UpdatedAt
- if ads20.Name == "" {
- return reply, errors.DataNotExistError
- } else {
- if ads20.Name == req.Name {
- // 姓名匹配为1
- res.IsMatch = 1
- reply.Data, _ = jsoniter.MarshalToString(res)
- } else {
- // 姓名不匹配为-1
- res.IsMatch = -1
- reply.Data, _ = jsoniter.MarshalToString(res)
- }
- }
- return reply, nil
- }
|