|
@@ -5,7 +5,6 @@ import cc.uncarbon.framework.core.context.UserContextHolder;
|
|
|
import cc.uncarbon.framework.core.enums.EnabledStatusEnum;
|
|
import cc.uncarbon.framework.core.enums.EnabledStatusEnum;
|
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
import cc.uncarbon.framework.core.exception.BusinessException;
|
|
|
import cc.uncarbon.framework.core.function.StreamFunction;
|
|
import cc.uncarbon.framework.core.function.StreamFunction;
|
|
|
-import cc.uncarbon.framework.crud.service.impl.HelioBaseServiceImpl;
|
|
|
|
|
import cc.uncarbon.module.sys.constant.SysConstant;
|
|
import cc.uncarbon.module.sys.constant.SysConstant;
|
|
|
import cc.uncarbon.module.sys.entity.SysMenuEntity;
|
|
import cc.uncarbon.module.sys.entity.SysMenuEntity;
|
|
|
import cc.uncarbon.module.sys.enums.SysErrorEnum;
|
|
import cc.uncarbon.module.sys.enums.SysErrorEnum;
|
|
@@ -18,6 +17,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
import cn.hutool.core.lang.Snowflake;
|
|
|
|
|
+import cn.hutool.core.text.CharSequenceUtil;
|
|
|
import cn.hutool.core.text.StrPool;
|
|
import cn.hutool.core.text.StrPool;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -34,24 +34,23 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 后台菜单
|
|
* 后台菜单
|
|
|
- *
|
|
|
|
|
- * @author Uncarbon
|
|
|
|
|
*/
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
-@Slf4j
|
|
|
|
|
@Service
|
|
@Service
|
|
|
-public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuEntity> {
|
|
|
|
|
-
|
|
|
|
|
- private static final Snowflake SNOWFLAKE = IdUtil.getSnowflake(0L, 0L);
|
|
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class SysMenuService {
|
|
|
|
|
|
|
|
|
|
+ private final SysMenuMapper sysMenuMapper;
|
|
|
private final SysRoleMenuRelationService sysRoleMenuRelationService;
|
|
private final SysRoleMenuRelationService sysRoleMenuRelationService;
|
|
|
|
|
|
|
|
|
|
+ private static final Snowflake SNOWFLAKE = IdUtil.getSnowflake(0L, 0L);
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 后台管理-列表
|
|
* 后台管理-列表
|
|
|
*/
|
|
*/
|
|
|
public List<SysMenuBO> adminList() {
|
|
public List<SysMenuBO> adminList() {
|
|
|
- List<SysMenuEntity> entityList = this.list(
|
|
|
|
|
|
|
+ List<SysMenuEntity> entityList = sysMenuMapper.selectList(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
// 排序
|
|
// 排序
|
|
@@ -79,7 +78,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
* @return null or BO
|
|
* @return null or BO
|
|
|
*/
|
|
*/
|
|
|
public SysMenuBO getOneById(Long id, boolean throwIfInvalidId) throws BusinessException {
|
|
public SysMenuBO getOneById(Long id, boolean throwIfInvalidId) throws BusinessException {
|
|
|
- SysMenuEntity entity = this.getById(id);
|
|
|
|
|
|
|
+ SysMenuEntity entity = sysMenuMapper.selectById(id);
|
|
|
if (throwIfInvalidId) {
|
|
if (throwIfInvalidId) {
|
|
|
SysErrorEnum.INVALID_ID.assertNotNull(entity);
|
|
SysErrorEnum.INVALID_ID.assertNotNull(entity);
|
|
|
}
|
|
}
|
|
@@ -106,7 +105,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
SysMenuEntity entity = new SysMenuEntity();
|
|
SysMenuEntity entity = new SysMenuEntity();
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
BeanUtil.copyProperties(dto, entity);
|
|
|
|
|
|
|
|
- this.save(entity);
|
|
|
|
|
|
|
+ sysMenuMapper.insert(entity);
|
|
|
|
|
|
|
|
return entity.getId();
|
|
return entity.getId();
|
|
|
}
|
|
}
|
|
@@ -126,7 +125,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
SysMenuEntity entity = new SysMenuEntity();
|
|
SysMenuEntity entity = new SysMenuEntity();
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
BeanUtil.copyProperties(dto, entity);
|
|
|
|
|
|
|
|
- this.updateById(entity);
|
|
|
|
|
|
|
+ sysMenuMapper.updateById(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -135,7 +134,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminDelete(Collection<Long> ids) {
|
|
public void adminDelete(Collection<Long> ids) {
|
|
|
log.info("[后台管理-删除后台菜单] >> 入参={}", ids);
|
|
log.info("[后台管理-删除后台菜单] >> 入参={}", ids);
|
|
|
- this.removeByIds(ids);
|
|
|
|
|
|
|
+ sysMenuMapper.deleteBatchIds(ids);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -172,7 +171,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
|
|
|
|
|
if (SysConstant.SUPER_ADMIN_ROLE_ID.equals(roleId)) {
|
|
if (SysConstant.SUPER_ADMIN_ROLE_ID.equals(roleId)) {
|
|
|
// 超级管理员读取所有权限,不管有没有被禁用
|
|
// 超级管理员读取所有权限,不管有没有被禁用
|
|
|
- permissions = this.list().stream()
|
|
|
|
|
|
|
+ permissions = sysMenuMapper.selectList(null).stream()
|
|
|
.map(SysMenuEntity::getPermission)
|
|
.map(SysMenuEntity::getPermission)
|
|
|
.filter(StrUtil::isNotEmpty)
|
|
.filter(StrUtil::isNotEmpty)
|
|
|
.collect(Collectors.toSet())
|
|
.collect(Collectors.toSet())
|
|
@@ -184,7 +183,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
if (CollUtil.isEmpty(menuIds)) {
|
|
if (CollUtil.isEmpty(menuIds)) {
|
|
|
permissions = Collections.emptySet();
|
|
permissions = Collections.emptySet();
|
|
|
} else {
|
|
} else {
|
|
|
- permissions = this.list(
|
|
|
|
|
|
|
+ permissions = sysMenuMapper.selectList(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
.select(SysMenuEntity::getPermission)
|
|
.select(SysMenuEntity::getPermission)
|
|
@@ -213,7 +212,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
return Collections.emptySet();
|
|
return Collections.emptySet();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return this.list(
|
|
|
|
|
|
|
+ return sysMenuMapper.selectList(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
.select(SysMenuEntity::getPermission)
|
|
.select(SysMenuEntity::getPermission)
|
|
@@ -269,7 +268,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
.setPath(bo.getComponent())
|
|
.setPath(bo.getComponent())
|
|
|
;
|
|
;
|
|
|
// 防止用户忘记加了, 主动补充/
|
|
// 防止用户忘记加了, 主动补充/
|
|
|
- if (StrUtil.isNotBlank(bo.getPath()) && !bo.getPath().startsWith(StrPool.SLASH)) {
|
|
|
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(bo.getPath()) && !bo.getPath().startsWith(StrPool.SLASH)) {
|
|
|
bo.setPath(StrPool.SLASH + bo.getPath());
|
|
bo.setPath(StrPool.SLASH + bo.getPath());
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -307,7 +306,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
SysErrorEnum.NO_ROLE_AVAILABLE_FOR_CURRENT_USER.assertNotEmpty(roleIds);
|
|
SysErrorEnum.NO_ROLE_AVAILABLE_FOR_CURRENT_USER.assertNotEmpty(roleIds);
|
|
|
|
|
|
|
|
// 2. 得到所有可用的 菜单ID-上级菜单ID map,备用
|
|
// 2. 得到所有可用的 菜单ID-上级菜单ID map,备用
|
|
|
- Map<Long, Long> allMenuMap = this.list(
|
|
|
|
|
|
|
+ Map<Long, Long> allMenuMap = sysMenuMapper.selectList(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
.select(SysMenuEntity::getId, SysMenuEntity::getParentId)
|
|
.select(SysMenuEntity::getId, SysMenuEntity::getParentId)
|
|
@@ -332,7 +331,7 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
Assert.notEmpty(ids);
|
|
Assert.notEmpty(ids);
|
|
|
Assert.notEmpty(types);
|
|
Assert.notEmpty(types);
|
|
|
|
|
|
|
|
- List<SysMenuEntity> entityList = this.list(
|
|
|
|
|
|
|
+ List<SysMenuEntity> entityList = sysMenuMapper.selectList(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
.in(SysMenuEntity::getId, ids)
|
|
.in(SysMenuEntity::getId, ids)
|
|
@@ -353,10 +352,10 @@ public class SysMenuService extends HelioBaseServiceImpl<SysMenuMapper, SysMenuE
|
|
|
* @param dto DTO
|
|
* @param dto DTO
|
|
|
*/
|
|
*/
|
|
|
private void checkExistence(AdminInsertOrUpdateSysMenuDTO dto) {
|
|
private void checkExistence(AdminInsertOrUpdateSysMenuDTO dto) {
|
|
|
- if (StrUtil.isNotBlank(dto.getPermission())) {
|
|
|
|
|
- dto.setPermission(StrUtil.cleanBlank(dto.getPermission()));
|
|
|
|
|
|
|
+ if (CharSequenceUtil.isNotBlank(dto.getPermission())) {
|
|
|
|
|
+ dto.setPermission(CharSequenceUtil.cleanBlank(dto.getPermission()));
|
|
|
|
|
|
|
|
- SysMenuEntity existingEntity = this.getOne(
|
|
|
|
|
|
|
+ SysMenuEntity existingEntity = sysMenuMapper.selectOne(
|
|
|
new QueryWrapper<SysMenuEntity>()
|
|
new QueryWrapper<SysMenuEntity>()
|
|
|
.lambda()
|
|
.lambda()
|
|
|
// 仅取主键ID
|
|
// 仅取主键ID
|