瀏覽代碼

会议小程序

孙永军 1 年之前
父節點
當前提交
0cbddb86b2
共有 1 個文件被更改,包括 9 次插入8 次删除
  1. 9 8
      src/main/java/com/smcic/api/user/service/impl/UserServiceImpl.java

+ 9 - 8
src/main/java/com/smcic/api/user/service/impl/UserServiceImpl.java

@@ -10,6 +10,7 @@ import com.smcic.api.user.entity.User;
 import com.smcic.api.user.mapper.UserMapper;
 import com.smcic.api.user.service.IUserService;
 import com.smcic.core.advice.APIException;
+import com.smcic.core.advice.BizException;
 import com.smcic.core.auth.AESUtil;
 import com.smcic.core.auth.HttpContextUtil;
 import org.apache.http.util.TextUtils;
@@ -29,7 +30,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
                 .oneOpt();
 
         if (!optionalUser.isPresent()) {
-            throw new APIException("用户不存在");
+            throw new BizException("用户不存在");
         }
 
         Long id = optionalUser.get().getId();
@@ -44,12 +45,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     public User getLoginUser() {
         Optional<String> token = HttpContextUtil.getToken();
         if (!token.isPresent()) {
-            throw new APIException("获取token异常");
+            throw new BizException("获取token异常");
         }
         String userId = AESUtil.decryptStr(token.get());
         User user = this.lambdaQuery().eq(User::getId, Long.parseLong(userId)).one();
         if (user == null) {
-            throw new APIException("用户不存在");
+            throw new BizException("用户不存在");
         }
 
         return user;
@@ -59,7 +60,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         String userId = AESUtil.decryptStr(token);
         User user = this.lambdaQuery().eq(User::getId, Long.parseLong(userId)).one();
         if (user == null) {
-            throw new APIException("用户不存在");
+            throw new BizException("用户不存在");
         }
         return user;
     }
@@ -84,12 +85,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     public void logout(){
         Optional<String> token = HttpContextUtil.getToken();
         if (!token.isPresent()) {
-            throw new APIException("获取token异常");
+            throw new BizException("获取token异常");
         }
         String userId = AESUtil.decryptStr(token.get());
         User user = this.lambdaQuery().eq(User::getId, Long.parseLong(userId)).one();
         if (user == null) {
-            throw new APIException("用户不存在");
+            throw new BizException("用户不存在");
         }
         user.setLogoutTime(LocalDateTime.now());
         updateById(user);
@@ -101,7 +102,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         String uid = AESUtil.decryptStr(token.get());
         User user = this.lambdaQuery().eq(User::getId, Long.parseLong(uid)).eq(User::getLoginPassword, pwdResetDTO.getOldPwd()).one();
         if(null == user){
-            throw new APIException(40001, "原密码错误");
+            throw new BizException("原密码错误");
         }
 
         user.setLoginPassword(pwdResetDTO.getPwd());
@@ -114,7 +115,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     public void updateRole(UserDTO userDTO){
         User user = getById(userDTO.getId());
         if(null == user){
-            throw new APIException(40001, "不存在的用户");
+            throw new BizException("不存在的用户");
         }
 
         if(userDTO.getRoleId() != null && userDTO.getRoleId() > 0)