mirror of https://gitee.com/stylefeng/roses
Merge remote-tracking branch 'origin/group1-button'
commit
9fb7e0db9a
|
@ -0,0 +1,42 @@
|
|||
package cn.stylefeng.roses.kernel.system.exception.enums;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
|
||||
/**
|
||||
* @author luojie
|
||||
* @date 2021/1/9 11:32
|
||||
*/
|
||||
public enum SysMenuButtonExceptionEnum implements AbstractExceptionEnum {
|
||||
/**
|
||||
* 按钮code重复
|
||||
*/
|
||||
BUTTON_CODE_REPEAT(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "90", "按钮code重复,请检查buttonCode参数"),
|
||||
|
||||
/**
|
||||
* 菜单按钮不存在
|
||||
*/
|
||||
MENU_BUTTON_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "91", "菜单按钮不存在"),
|
||||
|
||||
;
|
||||
|
||||
private final String errorCode;
|
||||
|
||||
private final String userTip;
|
||||
|
||||
SysMenuButtonExceptionEnum(String errorCode, String userTip) {
|
||||
this.errorCode = errorCode;
|
||||
this.userTip = userTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserTip() {
|
||||
return userTip;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.menu;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮请求参数
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:19
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysMenuButtonRequest extends BaseRequest {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "按钮id不能为空,请检查buttonId参数", groups = {edit.class, detail.class, delete.class})
|
||||
private Long buttonId;
|
||||
|
||||
/**
|
||||
* 菜单按钮主键集合
|
||||
*/
|
||||
@NotEmpty(message = "菜单按钮主键集合不能为空,请检查 buttonIds 参数", groups = {batchDelete.class})
|
||||
private Set<@NotNull(message = "菜单按钮主键集合不能为空,请检查 buttonIds 参数", groups = {batchDelete.class}) Long> buttonIds;
|
||||
|
||||
/**
|
||||
* 菜单id,按钮需要挂在菜单下
|
||||
*/
|
||||
@NotNull(message = "菜单id不能为空,请检查menuId参数", groups = {add.class, edit.class, list.class})
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 按钮的名称
|
||||
*/
|
||||
@NotBlank(message = "按钮名称不能为空,请检查buttonName参数", groups = {add.class, edit.class})
|
||||
private String buttonName;
|
||||
|
||||
/**
|
||||
* 按钮的编码
|
||||
*/
|
||||
@NotBlank(message = "按钮编码不能为空,请检查buttonCode参数", groups = {add.class, edit.class})
|
||||
private String buttonCode;
|
||||
|
||||
/**
|
||||
* 批量删除验证分组
|
||||
*/
|
||||
public @interface batchDelete {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.menu;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮响应实体
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:19
|
||||
*/
|
||||
@Data
|
||||
public class SysMenuButtonResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6909784065876106042L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long buttonId;
|
||||
|
||||
/**
|
||||
* 菜单id,按钮需要挂在菜单下
|
||||
*/
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 按钮的名称
|
||||
*/
|
||||
private String buttonName;
|
||||
|
||||
/**
|
||||
* 按钮的编码
|
||||
*/
|
||||
private String buttonCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package cn.stylefeng.roses.kernel.menu.modular.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.service.SysMenuButtonService;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonResponse;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮控制器
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2020/3/20 18:54
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "菜单按钮管理")
|
||||
public class SysMenuButtonController {
|
||||
|
||||
@Resource
|
||||
private SysMenuButtonService sysMenuButtonService;
|
||||
|
||||
/**
|
||||
* 添加系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮请求参数
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:28
|
||||
*/
|
||||
@PostResource(name = "添加系统菜单按钮", path = "/sysMenuButton/add")
|
||||
public ResponseData add(@RequestBody @Validated(SysMenuButtonRequest.add.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
sysMenuButtonService.add(sysMenuButtonRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单按钮详情
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:53
|
||||
*/
|
||||
@GetResource(name = "获取菜单按钮详情", path = "/sysMenuButton/detail")
|
||||
public ResponseData detail(@Validated(SysMenuButtonRequest.detail.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
SysMenuButtonResponse detail = sysMenuButtonService.detail(sysMenuButtonRequest);
|
||||
return new SuccessResponseData(detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮请求参数
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:00
|
||||
*/
|
||||
@PostResource(name = "编辑系统菜单按钮", path = "/sysMenuButton/edit")
|
||||
public ResponseData edit(@RequestBody @Validated(SysMenuButtonRequest.edit.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
sysMenuButtonService.edit(sysMenuButtonRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除单个系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:14
|
||||
*/
|
||||
@PostResource(name = "删除单个系统菜单按钮", path = "/sysMenuButton/delete")
|
||||
public ResponseData delete(@RequestBody @Validated(SysMenuButtonRequest.delete.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
sysMenuButtonService.delete(sysMenuButtonRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除多个系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id集合
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:27
|
||||
*/
|
||||
@PostResource(name = "批量删除多个系统菜单按钮", path = "/sysMenuButton/batchDelete")
|
||||
public ResponseData batchDelete(@RequestBody @Validated(SysMenuButtonRequest.batchDelete.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
sysMenuButtonService.batchDelete(sysMenuButtonRequest);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单按钮列表
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:33
|
||||
*/
|
||||
@GetResource(name = "获取菜单按钮列表", path = "/sysMenuButton/pageList")
|
||||
public ResponseData pageList(@Validated(SysMenuButtonRequest.list.class) SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
PageResult<SysMenuButtonResponse> pageResult = sysMenuButtonService.pageList(sysMenuButtonRequest);
|
||||
return new SuccessResponseData(pageResult);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package cn.stylefeng.roses.kernel.menu.modular.entity;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 菜单下的按钮(SysMenuButton)表实体类
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @since 2021-01-09 10:59:27
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_menu_button")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysMenuButton extends BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "button_id")
|
||||
private Long buttonId;
|
||||
|
||||
/**
|
||||
* 菜单id,按钮需要挂在菜单下
|
||||
*/
|
||||
@TableField(value = "menu_id")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 按钮的名称
|
||||
*/
|
||||
@TableField(value = "button_name")
|
||||
private String buttonName;
|
||||
|
||||
/**
|
||||
* 按钮的编码
|
||||
*/
|
||||
@TableField(value = "button_code")
|
||||
private String buttonCode;
|
||||
|
||||
/**
|
||||
* 是否删除:Y-被删除,N-未删除
|
||||
*/
|
||||
@TableField(value = "del_flag")
|
||||
private String delFlag;
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package cn.stylefeng.roses.kernel.menu.modular.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.menu.modular.entity.SysMenuButton;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮mapper接口
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:02
|
||||
*/
|
||||
public interface SysMenuButtonMapper extends BaseMapper<SysMenuButton> {
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.menu.modular.mapper.SysMenuButtonMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap type="cn.stylefeng.roses.kernel.menu.modular.entity.SysMenuButton" id="SysMenuButton">
|
||||
<result property="buttonId" column="button_id" jdbcType="INTEGER"/>
|
||||
<result property="menuId" column="menu_id" jdbcType="INTEGER"/>
|
||||
<result property="buttonName" column="button_name" jdbcType="VARCHAR"/>
|
||||
<result property="buttonCode" column="button_code" jdbcType="VARCHAR"/>
|
||||
<result property="delFlag" column="del_flag" jdbcType="VARCHAR"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="createUser" column="create_user" jdbcType="INTEGER"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateUser" column="update_user" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,81 @@
|
|||
package cn.stylefeng.roses.kernel.menu.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.entity.SysMenuButton;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonResponse;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮service接口
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:04
|
||||
*/
|
||||
public interface SysMenuButtonService extends IService<SysMenuButton> {
|
||||
|
||||
/**
|
||||
* 添加系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮请求参数
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:28
|
||||
*/
|
||||
void add(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 获取菜单按钮详情
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id
|
||||
* @return 菜单按钮详情
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:53
|
||||
*/
|
||||
SysMenuButtonResponse detail(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 编辑系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮请求参数
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:00
|
||||
*/
|
||||
void edit(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 删除单个系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:14
|
||||
*/
|
||||
void delete(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 批量删除多个系统菜单按钮
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮id集合
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:27
|
||||
*/
|
||||
void batchDelete(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 分页获取菜单按钮列表
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单id
|
||||
* @return 菜单按钮列表
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:53
|
||||
*/
|
||||
PageResult<SysMenuButtonResponse> pageList(SysMenuButtonRequest sysMenuButtonRequest);
|
||||
|
||||
/**
|
||||
* 根据菜单id删除该菜单下的所有按钮
|
||||
*
|
||||
* @param menuId 菜单id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 14:45
|
||||
*/
|
||||
void deleteMenuButtonByMenuId(Long menuId);
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
package cn.stylefeng.roses.kernel.menu.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.entity.SysMenu;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.entity.SysMenuButton;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.mapper.SysMenuButtonMapper;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.service.SysMenuButtonService;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.service.SysMenuService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.SysMenuButtonExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.exception.enums.SysMenuExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuButtonResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.menu.SysMenuRequest;
|
||||
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 org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 系统菜单按钮service接口实现类
|
||||
*
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:05
|
||||
*/
|
||||
@Service
|
||||
public class SysMenuButtonServiceImpl extends ServiceImpl<SysMenuButtonMapper, SysMenuButton> implements SysMenuButtonService {
|
||||
|
||||
@Resource
|
||||
private SysMenuService sysMenuService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
|
||||
Long menuId = sysMenuButtonRequest.getMenuId();
|
||||
|
||||
// 根据传过来的菜单id查询是否存在
|
||||
findMenuExist(menuId);
|
||||
|
||||
// 查询菜单按钮code是否存在
|
||||
findMenuButtonCodeExist(sysMenuButtonRequest);
|
||||
|
||||
SysMenuButton sysMenuButton = new SysMenuButton();
|
||||
BeanUtil.copyProperties(sysMenuButtonRequest, sysMenuButton);
|
||||
// 设置未删除
|
||||
sysMenuButton.setDelFlag(YesOrNotEnum.N.getCode());
|
||||
this.save(sysMenuButton);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysMenuButtonResponse detail(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
// 构建查询条件 查询未删除的按钮
|
||||
LambdaQueryWrapper<SysMenuButton> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SysMenuButton::getButtonId, sysMenuButtonRequest.getButtonId());
|
||||
lqw.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
lqw.last("LIMIT 1");
|
||||
|
||||
SysMenuButton sysMenuButton = this.getOne(lqw);
|
||||
|
||||
if (ObjectUtil.isEmpty(sysMenuButton)) {
|
||||
throw new ServiceException(SysMenuButtonExceptionEnum.MENU_BUTTON_NOT_EXIST);
|
||||
}
|
||||
|
||||
SysMenuButtonResponse response = new SysMenuButtonResponse();
|
||||
BeanUtil.copyProperties(sysMenuButton, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
Long menuId = sysMenuButtonRequest.getMenuId();
|
||||
|
||||
// 查询按钮是否存在
|
||||
this.detail(sysMenuButtonRequest);
|
||||
|
||||
// 根据传过来的菜单id查询是否存在
|
||||
findMenuExist(menuId);
|
||||
|
||||
// 查询菜单按钮code是否存在
|
||||
findMenuButtonCodeExist(sysMenuButtonRequest);
|
||||
|
||||
SysMenuButton sysMenuButton = new SysMenuButton();
|
||||
BeanUtil.copyProperties(sysMenuButtonRequest, sysMenuButton);
|
||||
// 不更新删除状态
|
||||
sysMenuButton.setDelFlag(null);
|
||||
// 不更新所属菜单id
|
||||
sysMenuButton.setMenuId(null);
|
||||
|
||||
this.updateById(sysMenuButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
// 查询按钮是否存在
|
||||
this.detail(sysMenuButtonRequest);
|
||||
|
||||
// 查询条件
|
||||
LambdaQueryWrapper<SysMenuButton> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SysMenuButton::getButtonId, sysMenuButtonRequest.getButtonId());
|
||||
lqw.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
// 设置为删除状态
|
||||
SysMenuButton entity = new SysMenuButton();
|
||||
entity.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||
|
||||
this.update(entity, lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void batchDelete(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
Set<Long> buttonIds = sysMenuButtonRequest.getButtonIds();
|
||||
if (ArrayUtil.isNotEmpty(buttonIds)) {
|
||||
// 查询条件
|
||||
LambdaQueryWrapper<SysMenuButton> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.in(SysMenuButton::getButtonId, buttonIds);
|
||||
lqw.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
// 设置为删除状态
|
||||
SysMenuButton entity = new SysMenuButton();
|
||||
entity.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||
|
||||
this.update(entity, lqw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取菜单按钮列表
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单id
|
||||
* @return 菜单按钮列表
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:53
|
||||
*/
|
||||
@Override
|
||||
public PageResult<SysMenuButtonResponse> pageList(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
String buttonName = sysMenuButtonRequest.getButtonName();
|
||||
|
||||
// 构造查询条件 根据菜单id查询菜单按钮列表
|
||||
LambdaQueryWrapper<SysMenuButton> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysMenuButton::getMenuId, sysMenuButtonRequest.getMenuId());
|
||||
if (StrUtil.isNotBlank(buttonName)) {
|
||||
wrapper.like(SysMenuButton::getButtonName, buttonName);
|
||||
}
|
||||
wrapper.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
Page<SysMenuButton> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||
|
||||
// 实体转换
|
||||
List<SysMenuButton> sysButtonList = page.getRecords();
|
||||
List<SysMenuButtonResponse> sysButtonResponseList = sysButtonList.stream().map(b -> {
|
||||
SysMenuButtonResponse sysButtonResponse = new SysMenuButtonResponse();
|
||||
BeanUtil.copyProperties(b, sysButtonResponse);
|
||||
return sysButtonResponse;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
PageResult<SysMenuButtonResponse> pageResult = new PageResult<>();
|
||||
BeanUtil.copyProperties(PageResultFactory.createPageResult(page), pageResult);
|
||||
pageResult.setRows(sysButtonResponseList);
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据菜单id删除该菜单下的所有按钮
|
||||
*
|
||||
* @param menuId 菜单id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 14:45
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteMenuButtonByMenuId(Long menuId) {
|
||||
if (ObjectUtil.isNotEmpty(menuId)) {
|
||||
// 查询菜单是否存在
|
||||
findMenuExist(menuId);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<SysMenuButton> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysMenuButton::getMenuId, menuId);
|
||||
queryWrapper.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
// 设置假删除
|
||||
SysMenuButton sysMenuButton = new SysMenuButton();
|
||||
sysMenuButton.setDelFlag(YesOrNotEnum.Y.getCode());
|
||||
|
||||
this.update(sysMenuButton, queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单是否存在
|
||||
*
|
||||
* @param menuId 菜单id
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 12:10
|
||||
*/
|
||||
public void findMenuExist(Long menuId) {
|
||||
// 根据传过来的菜单id查询是否存在
|
||||
SysMenuRequest sysMenuRequest = new SysMenuRequest();
|
||||
sysMenuRequest.setMenuId(menuId);
|
||||
SysMenu sysMenu = sysMenuService.detail(sysMenuRequest);
|
||||
if (ObjectUtil.isEmpty(sysMenu)) {
|
||||
throw new ServiceException(SysMenuExceptionEnum.MENU_NOT_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询菜单按钮code是否存在
|
||||
*
|
||||
* @param sysMenuButtonRequest 菜单按钮请求参数
|
||||
* @author q18idc.com QQ993143799
|
||||
* @date 2021/1/9 11:38
|
||||
*/
|
||||
public void findMenuButtonCodeExist(SysMenuButtonRequest sysMenuButtonRequest) {
|
||||
// 查询菜单按钮code是否存在
|
||||
LambdaQueryWrapper<SysMenuButton> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.select(SysMenuButton::getButtonId);
|
||||
wrapper.eq(SysMenuButton::getButtonCode, sysMenuButtonRequest.getButtonCode());
|
||||
wrapper.eq(SysMenuButton::getDelFlag, YesOrNotEnum.N.getCode());
|
||||
if (ObjectUtil.isNotEmpty(sysMenuButtonRequest.getButtonId())) {
|
||||
wrapper.ne(SysMenuButton::getButtonId, sysMenuButtonRequest.getButtonId());
|
||||
}
|
||||
wrapper.last("LIMIT 1");
|
||||
SysMenuButton button = getOne(wrapper);
|
||||
if (ObjectUtil.isNotEmpty(button)) {
|
||||
throw new ServiceException(SysMenuButtonExceptionEnum.BUTTON_CODE_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@ import cn.stylefeng.roses.kernel.menu.modular.factory.AntdMenusFactory;
|
|||
import cn.stylefeng.roses.kernel.menu.modular.factory.LayuiMenusFactory;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.factory.common.CommonMenusFactory;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.mapper.SysMenuMapper;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.service.SysMenuButtonService;
|
||||
import cn.stylefeng.roses.kernel.menu.modular.service.SysMenuService;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
|
@ -87,6 +88,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
@Resource
|
||||
private AppServiceApi appServiceApi;
|
||||
|
||||
@Resource
|
||||
private SysMenuButtonService sysMenuButtonService;
|
||||
|
||||
@Override
|
||||
public void add(SysMenuRequest sysMenuRequest) {
|
||||
|
||||
|
@ -138,6 +142,9 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
LambdaUpdateWrapper<SysMenu> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(SysMenu::getMenuId, childIdList).set(SysMenu::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
this.update(updateWrapper);
|
||||
|
||||
// 删除该菜单下的按钮
|
||||
sysMenuButtonService.deleteMenuButtonByMenuId(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue