123456789101112131415161718192021222324252627282930313233343536 |
- package user
- import (
- "errors"
- logger "eta/eta_mini_ht_api/common/component/log"
- userDao "eta/eta_mini_ht_api/models/user"
- "gorm.io/gorm"
- )
- type RiskLevelInfoDTO struct {
- Name string `json:"name"`
- PhoneNumber string `json:"phoneNumber"`
- RiskLevel string `json:"riskLevel"`
- RiskValidEndDate string `json:"riskValidEndDate"`
- }
- func UpdateRiskLevelInfo(dto RiskLevelInfoDTO) (err error) {
- user, err := userDao.GetUserByMobile(dto.PhoneNumber)
- if err != nil {
- if errors.Is(err, gorm.ErrRecordNotFound) {
- logger.Error("获取用户信息不存在:%v,用户手机号码:%s", err, dto.PhoneNumber)
- return errors.New("用户不存在,手机号码:" + dto.PhoneNumber)
- }
- logger.Error("获取用户信息失败:%v,用户手机号码:%s", err, dto.PhoneNumber)
- return errors.New("获取用户信息失败,手机号码:" + dto.PhoneNumber)
- }
- user.RiskLevel = dto.RiskLevel
- user.Username = dto.Name
- user.RiskValidEndDate = dto.RiskValidEndDate
- err = userDao.UpdateRiskLevelInfo(user)
- if err != nil {
- logger.Error("更新用户风险等级信息失败:%v,用户手机号码:%s", err, user.Mobile)
- return errors.New("更新用户风险等级信息失败,手机号码:" + user.Mobile)
- }
- return
- }
|