mirror of https://gitee.com/stylefeng/roses
【7.6.0】【sys】【app】更新删除应用接口
parent
44120aa235
commit
a558820be0
|
@ -21,7 +21,12 @@ public enum SysAppExceptionEnum implements AbstractExceptionEnum {
|
|||
/**
|
||||
* 不允许修改应用编码
|
||||
*/
|
||||
APP_CODE_CANT_EDIT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "不允许修改应用编码");
|
||||
APP_CODE_CANT_EDIT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10002", "不允许修改应用编码"),
|
||||
|
||||
/**
|
||||
* 该应用下有绑定菜单,无法删除应用
|
||||
*/
|
||||
APP_BIND_MENU(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + "10003", "该应用下有绑定菜单,无法删除应用");
|
||||
|
||||
/**
|
||||
* 错误编码
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.sys.modular.app.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
|
@ -12,11 +13,13 @@ import cn.stylefeng.roses.kernel.sys.modular.app.enums.SysAppExceptionEnum;
|
|||
import cn.stylefeng.roses.kernel.sys.modular.app.mapper.SysAppMapper;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.app.pojo.request.SysAppRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.app.service.SysAppService;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.menu.service.SysMenuService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +31,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysAppServiceImpl extends ServiceImpl<SysAppMapper, SysApp> implements SysAppService {
|
||||
|
||||
@Resource
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
@Override
|
||||
public void add(SysAppRequest sysAppRequest) {
|
||||
SysApp sysApp = new SysApp();
|
||||
|
@ -38,6 +44,12 @@ public class SysAppServiceImpl extends ServiceImpl<SysAppMapper, SysApp> impleme
|
|||
@Override
|
||||
public void del(SysAppRequest sysAppRequest) {
|
||||
SysApp sysApp = this.querySysApp(sysAppRequest);
|
||||
|
||||
// 判断应用下是否有绑定菜单
|
||||
if (this.sysMenuService.validateMenuBindApp(CollectionUtil.set(false, sysApp.getAppId()))) {
|
||||
throw new ServiceException(SysAppExceptionEnum.APP_BIND_MENU);
|
||||
}
|
||||
|
||||
this.removeById(sysApp.getAppId());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import cn.stylefeng.roses.kernel.sys.modular.menu.pojo.request.SysMenuRequest;
|
|||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 系统菜单 服务类
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
*/
|
||||
public interface SysMenuService extends IService<SysMenu> {
|
||||
|
||||
/**
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
|
@ -24,7 +25,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
*/
|
||||
void add(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
|
@ -33,7 +34,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
*/
|
||||
void del(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
|
@ -42,7 +43,7 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
*/
|
||||
void edit(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 查询详情
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
|
@ -51,24 +52,34 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
*/
|
||||
SysMenu detail(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
* @param sysMenuRequest 请求参数
|
||||
* @return List<SysMenu> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/10 21:28
|
||||
*/
|
||||
List<SysMenu> findList(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
/**
|
||||
* 获取列表(带分页)
|
||||
*
|
||||
* @param sysMenuRequest 请求参数
|
||||
* @param sysMenuRequest 请求参数
|
||||
* @return PageResult<SysMenu> 返回结果
|
||||
* @author fengshuonan
|
||||
* @date 2023/06/10 21:28
|
||||
*/
|
||||
PageResult<SysMenu> findPage(SysMenuRequest sysMenuRequest);
|
||||
|
||||
/**
|
||||
* 校验菜单是否绑定到某个app下
|
||||
*
|
||||
* @return true-该app下有菜单,false-该app下没菜单
|
||||
* @author fengshuonan
|
||||
* @since 2023/6/12 19:23
|
||||
*/
|
||||
boolean validateMenuBindApp(Set<Long> appIdList);
|
||||
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 系统菜单业务实现层
|
||||
|
@ -28,7 +29,7 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void add(SysMenuRequest sysMenuRequest) {
|
||||
SysMenu sysMenu = new SysMenu();
|
||||
BeanUtil.copyProperties(sysMenuRequest, sysMenu);
|
||||
|
@ -60,6 +61,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return PageResultFactory.createPageResult(sysRolePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateMenuBindApp(Set<Long> appIdList) {
|
||||
|
||||
LambdaQueryWrapper<SysMenu> sysMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysMenuLambdaQueryWrapper.in(SysMenu::getAppId, appIdList);
|
||||
sysMenuLambdaQueryWrapper.select(SysMenu::getMenuId);
|
||||
long count = this.count(sysMenuLambdaQueryWrapper);
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysMenu> findList(SysMenuRequest sysMenuRequest) {
|
||||
LambdaQueryWrapper<SysMenu> wrapper = this.createWrapper(sysMenuRequest);
|
||||
|
|
Loading…
Reference in New Issue