feat:修改icommon

V0.5.x
荭琪枫 2023-06-01 10:17:55 +08:00
parent fa5e281317
commit 4c78784e9d
4 changed files with 17 additions and 29 deletions

View File

@ -57,15 +57,13 @@ public interface ICommonData<T extends Id<ID>, ID> {
/** /**
* id * id
*/ */
default long deleteById(ID id) { default void deleteById(ID id) {
return 0L;
} }
/** /**
* id * id
*/ */
default int deleteByIds(Collection<ID> ids) { default void deleteByIds(Collection<ID> ids) {
return 0;
} }
/** /**

View File

@ -143,7 +143,7 @@ public interface ISysRoleService {
* @param roleId ID * @param roleId ID
* @return * @return
*/ */
int deleteRoleById(Long roleId); void deleteRoleById(Long roleId);
/** /**
* *
@ -151,7 +151,7 @@ public interface ISysRoleService {
* @param roleIds ID * @param roleIds ID
* @return * @return
*/ */
int deleteRoleByIds(Long[] roleIds); void deleteRoleByIds(Long[] roleIds);
/** /**
* *
@ -159,7 +159,7 @@ public interface ISysRoleService {
* @param userRole * @param userRole
* @return * @return
*/ */
int deleteAuthUser(SysUserRole userRole); void deleteAuthUser(SysUserRole userRole);
/** /**
* *
@ -168,7 +168,7 @@ public interface ISysRoleService {
* @param userIds ID * @param userIds ID
* @return * @return
*/ */
int deleteAuthUsers(Long roleId, Long[] userIds); void deleteAuthUsers(Long roleId, Long[] userIds);
/** /**
* *
@ -177,7 +177,7 @@ public interface ISysRoleService {
* @param userIds ID * @param userIds ID
* @return * @return
*/ */
int insertAuthUsers(Long roleId, Long[] userIds); void insertAuthUsers(Long roleId, Long[] userIds);
void cleanOnlineUserByRole(Long roleId); void cleanOnlineUserByRole(Long roleId);
} }

View File

@ -322,7 +322,6 @@ public class SysMenuServiceImpl implements ISysMenuService {
* *
* *
* @param bo * @param bo
* @return
*/ */
@Override @Override
public void insertMenu(SysMenuBo bo) { public void insertMenu(SysMenuBo bo) {
@ -333,7 +332,6 @@ public class SysMenuServiceImpl implements ISysMenuService {
* *
* *
* @param bo * @param bo
* @return
*/ */
@Override @Override
public void updateMenu(SysMenuBo bo) { public void updateMenu(SysMenuBo bo) {
@ -344,7 +342,6 @@ public class SysMenuServiceImpl implements ISysMenuService {
* *
* *
* @param menuId ID * @param menuId ID
* @return
*/ */
@Override @Override
public void deleteMenuById(Long menuId) { public void deleteMenuById(Long menuId) {
@ -354,7 +351,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
/** /**
* *
* *
* @param menu * @param bo
* @return * @return
*/ */
@Override @Override

View File

@ -35,12 +35,11 @@ import java.util.*;
* *
* @author Lion Li * @author Lion Li
*/ */
@RequiredArgsConstructor
@Service @Service
@RequiredArgsConstructor
public class SysRoleServiceImpl implements ISysRoleService { public class SysRoleServiceImpl implements ISysRoleService {
private final ISysRoleData iSysRoleData; private final ISysRoleData iSysRoleData;
private final ISysRoleMenuData iSysRoleMenuData; private final ISysRoleMenuData iSysRoleMenuData;
private final ISysUserRoleData iSysUserRoleData; private final ISysUserRoleData iSysUserRoleData;
private final ISysRoleDeptData iSysRoleDeptData; private final ISysRoleDeptData iSysRoleDeptData;
@ -238,7 +237,6 @@ public class SysRoleServiceImpl implements ISysRoleService {
* *
* @param roleId ID * @param roleId ID
* @param status * @param status
* @return
*/ */
@Override @Override
public void updateRoleStatus(Long roleId, String status) { public void updateRoleStatus(Long roleId, String status) {
@ -296,7 +294,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
private int insertRoleDept(SysRoleBo role) { private int insertRoleDept(SysRoleBo role) {
long rows = 1; long rows = 1;
// 新增角色与部门(数据权限)管理 // 新增角色与部门(数据权限)管理
List<SysRoleDept> list = new ArrayList<SysRoleDept>(); List<SysRoleDept> list = new ArrayList<>();
for (Long deptId : role.getDeptIds()) { for (Long deptId : role.getDeptIds()) {
SysRoleDept rd = new SysRoleDept(); SysRoleDept rd = new SysRoleDept();
rd.setRoleId(role.getRoleId()); rd.setRoleId(role.getRoleId());
@ -313,17 +311,15 @@ public class SysRoleServiceImpl implements ISysRoleService {
* ID * ID
* *
* @param roleId ID * @param roleId ID
* @return
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int deleteRoleById(Long roleId) { public void deleteRoleById(Long roleId) {
// 删除角色与菜单关联 // 删除角色与菜单关联
iSysRoleMenuData.deleteByRoleId(List.of(roleId)); iSysRoleMenuData.deleteByRoleId(List.of(roleId));
// 删除角色与部门关联 // 删除角色与部门关联
iSysRoleDeptData.deleteByRoleId(List.of(roleId)); iSysRoleDeptData.deleteByRoleId(List.of(roleId));
long num = iSysRoleData.deleteById(roleId); iSysRoleData.deleteById(roleId);
return Integer.parseInt(num + "");
} }
/** /**
@ -334,7 +330,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int deleteRoleByIds(Long[] roleIds) { public void deleteRoleByIds(Long[] roleIds) {
for (Long roleId : roleIds) { for (Long roleId : roleIds) {
checkRoleAllowed(roleId); checkRoleAllowed(roleId);
checkRoleDataScope(roleId); checkRoleDataScope(roleId);
@ -348,7 +344,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
iSysRoleMenuData.deleteByRoleId(ids); iSysRoleMenuData.deleteByRoleId(ids);
// 删除角色与部门关联 // 删除角色与部门关联
iSysRoleDeptData.deleteByRoleId(ids); iSysRoleDeptData.deleteByRoleId(ids);
return iSysRoleData.deleteByIds(ids); iSysRoleData.deleteByIds(ids);
} }
/** /**
@ -358,12 +354,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @return * @return
*/ */
@Override @Override
public int deleteAuthUser(SysUserRole userRole) { public void deleteAuthUser(SysUserRole userRole) {
long rows = iSysUserRoleData.delete(userRole.getRoleId(), List.of(userRole.getUserId())); long rows = iSysUserRoleData.delete(userRole.getRoleId(), List.of(userRole.getUserId()));
if (rows > 0) { if (rows > 0) {
cleanOnlineUserByRole(userRole.getRoleId()); cleanOnlineUserByRole(userRole.getRoleId());
} }
return Integer.parseInt(rows + "");
} }
/** /**
@ -374,12 +369,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @return * @return
*/ */
@Override @Override
public int deleteAuthUsers(Long roleId, Long[] userIds) { public void deleteAuthUsers(Long roleId, Long[] userIds) {
long rows = iSysUserRoleData.delete(roleId, Arrays.asList(userIds)); long rows = iSysUserRoleData.delete(roleId, Arrays.asList(userIds));
if (rows > 0) { if (rows > 0) {
cleanOnlineUserByRole(roleId); cleanOnlineUserByRole(roleId);
} }
return Integer.parseInt(rows + "");
} }
/** /**
@ -390,7 +384,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
* @return * @return
*/ */
@Override @Override
public int insertAuthUsers(Long roleId, Long[] userIds) { public void insertAuthUsers(Long roleId, Long[] userIds) {
// 新增用户与角色管理 // 新增用户与角色管理
long rows = 1; long rows = 1;
List<SysUserRole> list = StreamUtils.toList(List.of(userIds), userId -> { List<SysUserRole> list = StreamUtils.toList(List.of(userIds), userId -> {
@ -405,7 +399,6 @@ public class SysRoleServiceImpl implements ISysRoleService {
if (rows > 0) { if (rows > 0) {
cleanOnlineUserByRole(roleId); cleanOnlineUserByRole(roleId);
} }
return Integer.parseInt(rows + "");
} }
@Override @Override