Ver Fonte

新增网上开户账户信息时加密指定数据

zhou.xiaoning há 5 anos atrás
pai
commit
53ada4502f
1 ficheiros alterados com 51 adições e 0 exclusões
  1. 51 0
      models/account.go

+ 51 - 0
models/account.go

@@ -703,6 +703,57 @@ func GetTaAccountsByLoginID(loginID, taAccountType int) ([]Taaccount, error) {
 func InsertWSKHUserInfo(userinfo Wskhuserinfo) error {
 	engine := db.GetEngine()
 
+	// 加密数据
+	key, _ := hex.DecodeString(utils.AESSecretKey)
+	// 证件号码
+	if len(userinfo.Cardnum) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Cardnum), key); err == nil {
+			userinfo.Cardnum = hex.EncodeToString(encrypted)
+		}
+	}
+	// 证件地址
+	if len(userinfo.Cardaddress) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Cardaddress), key); err == nil {
+			userinfo.Cardaddress = hex.EncodeToString(encrypted)
+		}
+	}
+	// 手机
+	if len(userinfo.Mobilephone) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Mobilephone), key); err == nil {
+			userinfo.Mobilephone = hex.EncodeToString(encrypted)
+		}
+	}
+	// 微信
+	if len(userinfo.Wechat) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Wechat), key); err == nil {
+			userinfo.Wechat = hex.EncodeToString(encrypted)
+		}
+	}
+	// 邮件
+	if len(userinfo.Email) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Email), key); err == nil {
+			userinfo.Email = hex.EncodeToString(encrypted)
+		}
+	}
+	// 银行帐号
+	if len(userinfo.Bankaccount) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Bankaccount), key); err == nil {
+			userinfo.Bankaccount = hex.EncodeToString(encrypted)
+		}
+	}
+	// 经纪人ID
+	if len(userinfo.Brokerid) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Brokerid), key); err == nil {
+			userinfo.Brokerid = hex.EncodeToString(encrypted)
+		}
+	}
+	// 登录帐号
+	if len(userinfo.Logincode) > 0 {
+		if encrypted, err := utils.AESEncrypt([]byte(userinfo.Logincode), key); err == nil {
+			userinfo.Logincode = hex.EncodeToString(encrypted)
+		}
+	}
+
 	// 自增ID
 	seqMap, err := engine.QueryString("SELECT SEQ_WSKH_USERINFO.nextval USERID FROM dual")
 	if err != nil {