diff --git a/luoo_common/src/main/java/constants/ErrorConstants.java b/luoo_common/src/main/java/constants/ErrorConstants.java index cbfb4b0..bc41f6f 100644 --- a/luoo_common/src/main/java/constants/ErrorConstants.java +++ b/luoo_common/src/main/java/constants/ErrorConstants.java @@ -50,4 +50,6 @@ public class ErrorConstants { public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0"; public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核"; + + public final static String USER_STATUS_ERROR = "用户状态错误"; } diff --git a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java index bbf2a1b..68b46d0 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java @@ -12,6 +12,10 @@ import com.alibaba.fastjson.JSONObject; import com.luoo.user.dto.request.*; import com.luoo.user.service.WeChatAouth2Service; import com.luoo.user.util.IOSTokenUtils; +import constants.ErrorConstants; +import enums.UserStatusEnum; +import exception.BizException; +import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; @@ -372,6 +376,10 @@ public class LoginController extends BaseController { @PostMapping("/login/{userName}/{password}") public Result loginByUserName(@PathVariable String userName, @PathVariable String password) { UserInfo userInfo = userInfoService.findByUserNameAndPassword(userName, password); + if(ObjectUtils.notEqual(UserStatusEnum.ENABLE.getStatus(), userInfo.getStatus())){ + // 用户状态错误 + throw new BizException(ErrorConstants.USER_STATUS_ERROR); + } if (userInfo !=null) { //生成token String token = jwtUtil.createJWT(userInfo.getId(),userInfo.getUserName(),"artist","");