【7.6.0】【sys】【app】更新删除应用接口

pull/55/MERGE
fengshuonan 2023-06-12 19:28:27 +08:00
parent 44120aa235
commit a558820be0
4 changed files with 50 additions and 10 deletions

View File

@ -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", "该应用下有绑定菜单,无法删除应用");
/**
*

View File

@ -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());
}

View File

@ -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-appfalse-app
* @author fengshuonan
* @since 2023/6/12 19:23
*/
boolean validateMenuBindApp(Set<Long> appIdList);
}

View File

@ -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);