From 20d6d3d73682b6fd25e038f898651b6e138b501e Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期一, 16 八月 2021 15:58:56 +0800 Subject: [PATCH] 优化异常信息 --- src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java b/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java index 65114a3..9f6583d 100644 --- a/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.aspectj.lang.annotation.DataScope; @@ -64,6 +64,32 @@ public List<SysUser> selectUserList(SysUser user) { return userMapper.selectUserList(user); + } + + /** + * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ宸插垎閰嶇敤鎴疯鑹插垪琛� + * + * @param user 鐢ㄦ埛淇℃伅 + * @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List<SysUser> selectAllocatedList(SysUser user) + { + return userMapper.selectAllocatedList(user); + } + + /** + * 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈垎閰嶇敤鎴疯鑹插垪琛� + * + * @param user 鐢ㄦ埛淇℃伅 + * @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅 + */ + @Override + @DataScope(deptAlias = "d", userAlias = "u") + public List<SysUser> selectUnallocatedList(SysUser user) + { + return userMapper.selectUnallocatedList(user); } /** @@ -197,7 +223,7 @@ { if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { - throw new CustomException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳鐢ㄦ埛"); + throw new ServiceException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳鐢ㄦ埛"); } } @@ -218,6 +244,18 @@ // 鏂板鐢ㄦ埛涓庤鑹茬鐞� insertUserRole(user); return rows; + } + + /** + * 娉ㄥ唽鐢ㄦ埛淇℃伅 + * + * @param user 鐢ㄦ埛淇℃伅 + * @return 缁撴灉 + */ + @Override + public boolean registerUser(SysUser user) + { + return userMapper.insertUser(user) > 0; } /** @@ -248,6 +286,8 @@ * @param userId 鐢ㄦ埛ID * @param roleIds 瑙掕壊缁� */ + @Override + @Transactional public void insertUserAuth(Long userId, Long[] roleIds) { userRoleMapper.deleteUserRoleByUserId(userId); @@ -445,7 +485,7 @@ { if (StringUtils.isNull(userList) || userList.size() == 0) { - throw new CustomException("瀵煎叆鐢ㄦ埛鏁版嵁涓嶈兘涓虹┖锛�"); + throw new ServiceException("瀵煎叆鐢ㄦ埛鏁版嵁涓嶈兘涓虹┖锛�"); } int successNum = 0; int failureNum = 0; @@ -490,7 +530,7 @@ if (failureNum > 0) { failureMsg.insert(0, "寰堟姳姝夛紝瀵煎叆澶辫触锛佸叡 " + failureNum + " 鏉℃暟鎹牸寮忎笉姝g‘锛岄敊璇涓嬶細"); - throw new CustomException(failureMsg.toString()); + throw new ServiceException(failureMsg.toString()); } else { -- Gitblit v1.9.3