Browse Source

登录查询接口增加手机号码和证件号码解密功能

zhou.xiaoning 3 years ago
parent
commit
5059e13d7a
4 changed files with 18 additions and 12 deletions
  1. 0 4
      docs/docs.go
  2. 0 4
      docs/swagger.json
  3. 0 3
      docs/swagger.yaml
  4. 18 1
      models/account.go

+ 0 - 4
docs/docs.go

@@ -30059,10 +30059,6 @@ const docTemplate = `{
                     "description": "修改时间",
                     "type": "string"
                 },
-                "password": {
-                    "description": "登陆密码",
-                    "type": "string"
-                },
                 "pwdwrongcount": {
                     "description": "密码错误次数",
                     "type": "integer"

+ 0 - 4
docs/swagger.json

@@ -30050,10 +30050,6 @@
                     "description": "修改时间",
                     "type": "string"
                 },
-                "password": {
-                    "description": "登陆密码",
-                    "type": "string"
-                },
                 "pwdwrongcount": {
                     "description": "密码错误次数",
                     "type": "integer"

+ 0 - 3
docs/swagger.yaml

@@ -10487,9 +10487,6 @@ definitions:
       modifytime:
         description: 修改时间
         type: string
-      password:
-        description: 登陆密码
-        type: string
       pwdwrongcount:
         description: 密码错误次数
         type: integer

+ 18 - 1
models/account.go

@@ -16,7 +16,7 @@ type Loginaccount struct {
 	Loginid            int64     `json:"loginid"  xorm:"LOGINID" binding:"required"`    // 登陆账号
 	Userid             int64     `json:"userid"  xorm:"USERID"`                         // 用户ID
 	Loginfailnum       int32     `json:"loginfailnum"  xorm:"LOGINFAILNUM"`             // 连续登录失败次数(登录成功时清零)
-	Password           string    `json:"password"  xorm:"PASSWORD"`                     // 登陆密码
+	Password           string    `json:"-"  xorm:"PASSWORD"`                            // 登陆密码
 	Loginusertype      int32     `json:"loginusertype"  xorm:"LOGINUSERTYPE"`           // 登录账号类型 - 1:投资者 2:机构交易员
 	Loginstatus        int32     `json:"loginstatus"  xorm:"LOGINSTATUS"`               // 登录账号状态 1:正常 2:冻结(停用) 3:无效(注销)
 	Lastlogintime      time.Time `json:"lastlogintime"  xorm:"LASTLOGINTIME"`           // 最新登录时间
@@ -647,6 +647,23 @@ func GetUserInfo(userID int) (*Userinfo, error) {
 		return nil, err
 	}
 
+	// 解密证件号码和手机号码
+	key, _ := hex.DecodeString(utils.AESSecretKey)
+	if len(userInfo.Cardnum) > 0 {
+		if s1, err := hex.DecodeString(userInfo.Cardnum); err == nil { // hex -> []byte
+			if s2, err := utils.AESDecrypt(s1, key); err == nil {
+				userInfo.Cardnum = string(s2)
+			}
+		}
+	}
+	if len(userInfo.Mobile) > 0 {
+		if s1, err := hex.DecodeString(userInfo.Mobile); err == nil { // hex -> []byte
+			if s2, err := utils.AESDecrypt(s1, key); err == nil {
+				userInfo.Mobile2 = string(s2)
+			}
+		}
+	}
+
 	return &userInfo, nil
 }