From 4c78784e9df013fcc2f9077942092b916371c57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=AD=E7=90=AA=E6=9E=AB?= Date: Thu, 1 Jun 2023 10:17:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9icommon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cc/iotkit/data/ICommonData.java | 6 ++--- .../system/service/ISysRoleService.java | 10 ++++---- .../service/impl/SysMenuServiceImpl.java | 5 +--- .../service/impl/SysRoleServiceImpl.java | 25 +++++++------------ 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java index cd482fc6..9bcc14a3 100644 --- a/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java +++ b/iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/ICommonData.java @@ -57,15 +57,13 @@ public interface ICommonData, ID> { /** * 按id删除 */ - default long deleteById(ID id) { - return 0L; + default void deleteById(ID id) { } /** * 按id批量删除 */ - default int deleteByIds(Collection ids) { - return 0; + default void deleteByIds(Collection ids) { } /** diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java index 93e98162..9987ae48 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/ISysRoleService.java @@ -143,7 +143,7 @@ public interface ISysRoleService { * @param roleId 角色ID * @return 结果 */ - int deleteRoleById(Long roleId); + void deleteRoleById(Long roleId); /** * 批量删除角色信息 @@ -151,7 +151,7 @@ public interface ISysRoleService { * @param roleIds 需要删除的角色ID * @return 结果 */ - int deleteRoleByIds(Long[] roleIds); + void deleteRoleByIds(Long[] roleIds); /** * 取消授权用户角色 @@ -159,7 +159,7 @@ public interface ISysRoleService { * @param userRole 用户和角色关联信息 * @return 结果 */ - int deleteAuthUser(SysUserRole userRole); + void deleteAuthUser(SysUserRole userRole); /** * 批量取消授权用户角色 @@ -168,7 +168,7 @@ public interface ISysRoleService { * @param userIds 需要取消授权的用户数据ID * @return 结果 */ - int deleteAuthUsers(Long roleId, Long[] userIds); + void deleteAuthUsers(Long roleId, Long[] userIds); /** * 批量选择授权用户角色 @@ -177,7 +177,7 @@ public interface ISysRoleService { * @param userIds 需要删除的用户数据ID * @return 结果 */ - int insertAuthUsers(Long roleId, Long[] userIds); + void insertAuthUsers(Long roleId, Long[] userIds); void cleanOnlineUserByRole(Long roleId); } diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java index 6677b9f7..1e0b2855 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysMenuServiceImpl.java @@ -322,7 +322,6 @@ public class SysMenuServiceImpl implements ISysMenuService { * 新增保存菜单信息 * * @param bo 菜单信息 - * @return 结果 */ @Override public void insertMenu(SysMenuBo bo) { @@ -333,7 +332,6 @@ public class SysMenuServiceImpl implements ISysMenuService { * 修改保存菜单信息 * * @param bo 菜单信息 - * @return 结果 */ @Override public void updateMenu(SysMenuBo bo) { @@ -344,7 +342,6 @@ public class SysMenuServiceImpl implements ISysMenuService { * 删除菜单管理信息 * * @param menuId 菜单ID - * @return 结果 */ @Override public void deleteMenuById(Long menuId) { @@ -354,7 +351,7 @@ public class SysMenuServiceImpl implements ISysMenuService { /** * 校验菜单名称是否唯一 * - * @param menu 菜单信息 + * @param bo 菜单信息 * @return 结果 */ @Override diff --git a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java index 1bc0cab3..4caca080 100644 --- a/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java +++ b/iot-module/iot-system/src/main/java/cc/iotkit/system/service/impl/SysRoleServiceImpl.java @@ -35,12 +35,11 @@ import java.util.*; * * @author Lion Li */ -@RequiredArgsConstructor @Service +@RequiredArgsConstructor public class SysRoleServiceImpl implements ISysRoleService { private final ISysRoleData iSysRoleData; - private final ISysRoleMenuData iSysRoleMenuData; private final ISysUserRoleData iSysUserRoleData; private final ISysRoleDeptData iSysRoleDeptData; @@ -238,7 +237,6 @@ public class SysRoleServiceImpl implements ISysRoleService { * * @param roleId 角色ID * @param status 角色状态 - * @return 结果 */ @Override public void updateRoleStatus(Long roleId, String status) { @@ -296,7 +294,7 @@ public class SysRoleServiceImpl implements ISysRoleService { private int insertRoleDept(SysRoleBo role) { long rows = 1; // 新增角色与部门(数据权限)管理 - List list = new ArrayList(); + List list = new ArrayList<>(); for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); @@ -313,17 +311,15 @@ public class SysRoleServiceImpl implements ISysRoleService { * 通过角色ID删除角色 * * @param roleId 角色ID - * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleById(Long roleId) { + public void deleteRoleById(Long roleId) { // 删除角色与菜单关联 iSysRoleMenuData.deleteByRoleId(List.of(roleId)); // 删除角色与部门关联 iSysRoleDeptData.deleteByRoleId(List.of(roleId)); - long num = iSysRoleData.deleteById(roleId); - return Integer.parseInt(num + ""); + iSysRoleData.deleteById(roleId); } /** @@ -334,7 +330,7 @@ public class SysRoleServiceImpl implements ISysRoleService { */ @Override @Transactional(rollbackFor = Exception.class) - public int deleteRoleByIds(Long[] roleIds) { + public void deleteRoleByIds(Long[] roleIds) { for (Long roleId : roleIds) { checkRoleAllowed(roleId); checkRoleDataScope(roleId); @@ -348,7 +344,7 @@ public class SysRoleServiceImpl implements ISysRoleService { iSysRoleMenuData.deleteByRoleId(ids); // 删除角色与部门关联 iSysRoleDeptData.deleteByRoleId(ids); - return iSysRoleData.deleteByIds(ids); + iSysRoleData.deleteByIds(ids); } /** @@ -358,12 +354,11 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int deleteAuthUser(SysUserRole userRole) { + public void deleteAuthUser(SysUserRole userRole) { long rows = iSysUserRoleData.delete(userRole.getRoleId(), List.of(userRole.getUserId())); if (rows > 0) { cleanOnlineUserByRole(userRole.getRoleId()); } - return Integer.parseInt(rows + ""); } /** @@ -374,12 +369,11 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int deleteAuthUsers(Long roleId, Long[] userIds) { + public void deleteAuthUsers(Long roleId, Long[] userIds) { long rows = iSysUserRoleData.delete(roleId, Arrays.asList(userIds)); if (rows > 0) { cleanOnlineUserByRole(roleId); } - return Integer.parseInt(rows + ""); } /** @@ -390,7 +384,7 @@ public class SysRoleServiceImpl implements ISysRoleService { * @return 结果 */ @Override - public int insertAuthUsers(Long roleId, Long[] userIds) { + public void insertAuthUsers(Long roleId, Long[] userIds) { // 新增用户与角色管理 long rows = 1; List list = StreamUtils.toList(List.of(userIds), userId -> { @@ -405,7 +399,6 @@ public class SysRoleServiceImpl implements ISysRoleService { if (rows > 0) { cleanOnlineUserByRole(roleId); } - return Integer.parseInt(rows + ""); } @Override