From 2808ef350ac8f5b8b1431f207a2142a12bbe467e Mon Sep 17 00:00:00 2001 From: huangyawei Date: Tue, 28 May 2024 20:45:05 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E7=99=BB=E5=BD=95=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luoo_common/src/main/java/constants/ErrorConstants.java | 2 ++ .../java/com/luoo/user/controller/LoginController.java | 8 ++++++++ 2 files changed, 10 insertions(+) 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","");