|
@@ -113,17 +113,27 @@ func BindUserMobile(userId int, mobile string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetUserByOpenId(openId string) (UserDTO, error) {
|
|
|
- var dto UserDTO
|
|
|
+func GetUserByOpenId(openId string) (userDto UserDTO, err error) {
|
|
|
templateUser, err := userDao.GetUserByOpenId(openId)
|
|
|
if err != nil {
|
|
|
- if !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- logger.Error("查询用户失败:%v", err)
|
|
|
- }
|
|
|
- return dto, err
|
|
|
+ logger.Error("查询用户失败:%v", err)
|
|
|
+ return
|
|
|
}
|
|
|
- dto = convertUserDTO(templateUser)
|
|
|
- return dto, nil
|
|
|
+ if templateUser.IsDeleted == 1 {
|
|
|
+ logger.Error("用户已删除:%v", err)
|
|
|
+ err = errors.New("用户已删除")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if templateUser.Mobile == "" {
|
|
|
+ logger.Error("用户手机号为空:%v", err)
|
|
|
+ err = errors.New("用户手机号为空")
|
|
|
+ }
|
|
|
+ if templateUser.OpenId == "" {
|
|
|
+ logger.Error("用户openId为空:%v", err)
|
|
|
+ err = errors.New("用户openId为空")
|
|
|
+ }
|
|
|
+ userDto = convertUserDTO(templateUser)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
func GetTemplateUserByUnionId(openId string) (user UserDTO, err error) {
|