master:快捷功能完善;
parent
3c32eb61bb
commit
f5dd315ca4
|
|
@ -5,11 +5,10 @@ import com.ruoyi.common.annotation.Log;
|
|||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.system.domain.vo.menu.SysMenuDTO;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.web.controller.xkt.vo.quickFunction.QuickFuncVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.quickFunction.StoreQuickFuncVO;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncDTO;
|
||||
import com.ruoyi.web.controller.xkt.vo.quickFunction.QuickFuncResVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.quickFunction.QuickFuncUpdateVO;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncUpdateDTO;
|
||||
import com.ruoyi.xkt.service.IQuickFunctionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -18,8 +17,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 快捷功能Controller
|
||||
*
|
||||
|
|
@ -37,36 +34,20 @@ public class QuickFunctionController extends XktBaseController {
|
|||
|
||||
private static final String MENU_TYPE_C = "C";
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,seller,store')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,seller,agent,store')")
|
||||
@ApiOperation(value = "档口或电商卖家选择的快捷功能", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/selected/{roleId}/{bizId}")
|
||||
public R<List<StoreQuickFuncVO>> getSelectedList(@PathVariable("roleId") Long roleId, @PathVariable("bizId") Long bizId) {
|
||||
@GetMapping("/selected")
|
||||
public R<QuickFuncResVO> getSelectedList() {
|
||||
// 找到当前所有的快捷菜单
|
||||
List<QuickFuncDTO.DetailDTO> checkedList = quickFuncService.getCheckedMenuList(roleId, bizId);
|
||||
return R.ok(BeanUtil.copyToList(checkedList, StoreQuickFuncVO.class));
|
||||
return R.ok(BeanUtil.toBean(quickFuncService.getCheckedMenuList(), QuickFuncResVO.class));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,seller,store')")
|
||||
@ApiOperation(value = "常用功能 点击 设置", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/menus/{roleId}/{bizId}")
|
||||
public R<QuickFuncVO> getMenuList(@PathVariable("roleId") Long roleId, @PathVariable("bizId") Long bizId) {
|
||||
// 找到当前所有的快捷菜单
|
||||
List<QuickFuncDTO.DetailDTO> checkedList = quickFuncService.getCheckedMenuList(roleId, bizId);
|
||||
// 找到系统所有的二级菜单
|
||||
List<SysMenuDTO> sysMenuList = menuService.selectMenuListByRoleIdAndMenuType(roleId, MENU_TYPE_C);
|
||||
return R.ok(QuickFuncVO.builder().bizId(bizId).roleId(roleId)
|
||||
.checkedList(BeanUtil.copyToList(checkedList, QuickFuncVO.QuickFuncDetailVO.class))
|
||||
.menuList(BeanUtil.copyToList(sysMenuList, QuickFuncVO.QuickFuncDetailVO.class))
|
||||
.build());
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,seller,store')")
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,seller,agent,store')")
|
||||
@ApiOperation(value = "修改快捷功能", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "修改快捷功能", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/checked")
|
||||
public R editCheckedList(@Validated @RequestBody QuickFuncVO quickFuncVO) {
|
||||
quickFuncService.updateCheckedList(BeanUtil.toBean(quickFuncVO, QuickFuncDTO.class));
|
||||
return success();
|
||||
public R<Integer> update(@Validated @RequestBody QuickFuncUpdateVO quickFuncVO) {
|
||||
return R.ok(quickFuncService.update(BeanUtil.toBean(quickFuncVO, QuickFuncUpdateDTO.class)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
|
|
@ -18,17 +20,18 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class StoreQuickFuncVO {
|
||||
public class QuickFuncResVO {
|
||||
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
private String menuName;
|
||||
@ApiModelProperty(value = "显示顺序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "路由地址")
|
||||
private String path;
|
||||
@ApiModelProperty(value = "组件路径")
|
||||
private String component;
|
||||
@ApiModelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
@ApiModelProperty(value = "菜单id列表")
|
||||
private List<QFMenuVO> menuList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
public static class QFMenuVO {
|
||||
@ApiModelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.quickFunction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QuickFuncUpdateVO {
|
||||
|
||||
@NotNull(message = "用户ID不能为空!")
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
@NotNull(message = "菜单id列表不能为空!")
|
||||
@ApiModelProperty(value = "菜单id列表")
|
||||
private List<QFMenuVO> menuList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
@Valid
|
||||
public static class QFMenuVO {
|
||||
@NotNull(message = "菜单ID不能为空!")
|
||||
@ApiModelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
@NotNull(message = "排序不能为空!")
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.quickFunction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Builder
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QuickFuncVO {
|
||||
|
||||
@ApiModelProperty(value = "业务ID 根据roleId确定,可能为store_id、user_id", required = true)
|
||||
@NotNull(message = "业务ID不能为空!")
|
||||
private Long bizId;
|
||||
@ApiModelProperty(value = "角色ID", required = true)
|
||||
@NotNull(message = "角色ID不能为空!")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(value = "档口勾选的快捷功能", required = true)
|
||||
@NotNull(message = "档口勾选的快捷功能不能为空!")
|
||||
private List<QuickFuncDetailVO> checkedList;
|
||||
@ApiModelProperty(value = "系统所有的二级菜单列表")
|
||||
private List<QuickFuncDetailVO> menuList;
|
||||
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public static class QuickFuncDetailVO {
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
private String menuName;
|
||||
@ApiModelProperty(value = "显示顺序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "路由地址")
|
||||
private String path;
|
||||
@ApiModelProperty(value = "组件路径")
|
||||
private String component;
|
||||
@ApiModelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2299,12 +2299,9 @@ DROP TABLE IF EXISTS `quick_function`;
|
|||
CREATE TABLE `quick_function`
|
||||
(
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '档口快捷功能ID',
|
||||
`biz_id` bigint UNSIGNED NOT NULL COMMENT 'store.id or user.id',
|
||||
`role_id` bigint UNSIGNED NOT NULL COMMENT '角色ID',
|
||||
`menu_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '快捷功能名称',
|
||||
`icon` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '快捷功能图标',
|
||||
`path` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '快捷功能路径',
|
||||
`order_num` int UNSIGNED NULL DEFAULT NULL COMMENT '排序',
|
||||
`user_id` bigint UNSIGNED NOT NULL COMMENT 'user.id',
|
||||
`menu_id` bigint UNSIGNED NOT NULL COMMENT '菜单id',
|
||||
`order_num` int UNSIGNED NOT NULL COMMENT '排序',
|
||||
`version` bigint UNSIGNED NOT NULL COMMENT '版本号',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '删除标志(0代表存在 2代表删除)',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import com.ruoyi.common.core.domain.XktBaseEntity;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 档口快捷功能对象 store_quick_function
|
||||
|
|
@ -28,32 +26,13 @@ public class QuickFunction extends XktBaseEntity {
|
|||
private Long id;
|
||||
|
||||
/**
|
||||
* store.id or user.id
|
||||
* 用户ID
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
private Long userId;
|
||||
/**
|
||||
* 角色ID
|
||||
* 菜单ID
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 快捷功能名称
|
||||
*/
|
||||
@Excel(name = "快捷功能名称")
|
||||
private String menuName;
|
||||
|
||||
/**
|
||||
* 快捷功能图标
|
||||
*/
|
||||
@Excel(name = "快捷功能图标")
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 快捷功能路径
|
||||
*/
|
||||
@Excel(name = "快捷功能路径")
|
||||
private String path;
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
|
|
@ -61,22 +40,4 @@ public class QuickFunction extends XktBaseEntity {
|
|||
@Excel(name = "排序")
|
||||
private Integer orderNum;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("bizId", getBizId())
|
||||
.append("menuName", getMenuName())
|
||||
.append("icon", getIcon())
|
||||
.append("path", getPath())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("version", getVersion())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package com.ruoyi.xkt.dto.quickFunction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口快捷功能")
|
||||
@Data
|
||||
|
||||
public class QuickFuncDTO {
|
||||
|
||||
@ApiModelProperty(value = "bizId 根据roleId确定,为storeId或者userId")
|
||||
private Long bizId;
|
||||
@ApiModelProperty(value = "角色ID")
|
||||
private Long roleId;
|
||||
@ApiModelProperty(value = "档口勾选的快捷功能")
|
||||
List<DetailDTO> checkedList;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class DetailDTO {
|
||||
@ApiModelProperty(value = "菜单名称")
|
||||
private String menuName;
|
||||
@ApiModelProperty(value = "显示顺序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "路由地址")
|
||||
private String path;
|
||||
@ApiModelProperty(value = "组件路径")
|
||||
private String component;
|
||||
@ApiModelProperty(value = "菜单图标")
|
||||
private String icon;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.xkt.dto.quickFunction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class QuickFuncResDTO {
|
||||
|
||||
@ApiModelProperty(value = "菜单id列表")
|
||||
private List<QFMenuDTO> menuList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
public static class QFMenuDTO {
|
||||
@ApiModelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.ruoyi.xkt.dto.quickFunction;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QuickFuncUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Long userId;
|
||||
@ApiModelProperty(value = "菜单id列表")
|
||||
private List<QFMenuVO> menuList;
|
||||
|
||||
@Data
|
||||
@ApiModel
|
||||
public static class QFMenuVO {
|
||||
@ApiModelProperty(value = "菜单ID")
|
||||
private Long menuId;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.ruoyi.xkt.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.QuickFunction;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 档口快捷功能Mapper接口
|
||||
|
|
@ -12,12 +11,4 @@ import org.apache.ibatis.annotations.Param;
|
|||
*/
|
||||
public interface QuickFunctionMapper extends BaseMapper<QuickFunction> {
|
||||
|
||||
/**
|
||||
* 将指定角色指定bizId的快捷功能置为无效
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param bizId 业务ID
|
||||
*/
|
||||
void updateDelFlagByRoleIdAndBizId(@Param("roleId") Long roleId, @Param("bizId") Long bizId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.ruoyi.xkt.service;
|
||||
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncDTO;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncResDTO;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncUpdateDTO;
|
||||
|
||||
/**
|
||||
* 档口快捷功能Service接口
|
||||
|
|
@ -11,21 +10,20 @@ import java.util.List;
|
|||
* @date 2025-03-26
|
||||
*/
|
||||
public interface IQuickFunctionService {
|
||||
|
||||
/**
|
||||
* 获取当前绑定的快捷功能
|
||||
*
|
||||
* @param roleId 当前角色ID
|
||||
* @param bizId bizId
|
||||
* @return List<StoreQuickFuncDTO.DetailDTO>
|
||||
*/
|
||||
List<QuickFuncDTO.DetailDTO> getCheckedMenuList(Long roleId, Long bizId);
|
||||
QuickFuncResDTO getCheckedMenuList();
|
||||
|
||||
/**
|
||||
* 更新绑定的快捷功能
|
||||
*
|
||||
* @param storeQuickFuncDTO 绑定快捷功能的DTO
|
||||
* @param updateDTO 绑定快捷功能的DTO
|
||||
* @return
|
||||
*/
|
||||
void updateCheckedList(QuickFuncDTO storeQuickFuncDTO);
|
||||
Integer update(QuickFuncUpdateDTO updateDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,21 @@ package com.ruoyi.xkt.service.impl;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.xkt.domain.QuickFunction;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncDTO;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncResDTO;
|
||||
import com.ruoyi.xkt.dto.quickFunction.QuickFuncUpdateDTO;
|
||||
import com.ruoyi.xkt.mapper.QuickFunctionMapper;
|
||||
import com.ruoyi.xkt.service.IQuickFunctionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 快捷功能Service业务层处理
|
||||
|
|
@ -29,27 +33,36 @@ public class QuickFunctionServiceImpl implements IQuickFunctionService {
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<QuickFuncDTO.DetailDTO> getCheckedMenuList(Long roleId, Long bizId) {
|
||||
List<QuickFunction> storeQuickFuncList = quickFuncMapper.selectList(new LambdaQueryWrapper<QuickFunction>()
|
||||
.eq(QuickFunction::getBizId, bizId).eq(QuickFunction::getRoleId, roleId).eq(QuickFunction::getDelFlag, Constants.UNDELETED));
|
||||
return CollectionUtils.isEmpty(storeQuickFuncList) ? new ArrayList<>() : BeanUtil.copyToList(storeQuickFuncList, QuickFuncDTO.DetailDTO.class);
|
||||
public QuickFuncResDTO getCheckedMenuList() {
|
||||
Long userId = SecurityUtils.getUserIdSafe();
|
||||
if (ObjectUtils.isEmpty(userId)) {
|
||||
throw new ServiceException("用户未登录,请先登录!", HttpStatus.ERROR);
|
||||
}
|
||||
List<QuickFunction> quickFuncList = this.quickFuncMapper.selectList(new LambdaQueryWrapper<QuickFunction>()
|
||||
.eq(QuickFunction::getUserId, userId).eq(QuickFunction::getDelFlag, Constants.UNDELETED));
|
||||
return new QuickFuncResDTO().setMenuList(BeanUtil.copyToList(quickFuncList, QuickFuncResDTO.QFMenuDTO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新绑定的快捷功能
|
||||
*
|
||||
* @param storeQuickFuncDTO 绑定快捷功能的DTO
|
||||
* @param updateDTO 绑定快捷功能的DTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateCheckedList(QuickFuncDTO storeQuickFuncDTO) {
|
||||
public Integer update(QuickFuncUpdateDTO updateDTO) {
|
||||
// 先将旧的绑定关系置为无效
|
||||
this.quickFuncMapper.updateDelFlagByRoleIdAndBizId(storeQuickFuncDTO.getRoleId(), storeQuickFuncDTO.getBizId());
|
||||
// 新增档口的快捷功能
|
||||
List<QuickFunction> checkedList = BeanUtil.copyToList(storeQuickFuncDTO.getCheckedList(), QuickFunction.class);
|
||||
checkedList.forEach(x -> x.setBizId(storeQuickFuncDTO.getBizId()).setRoleId(storeQuickFuncDTO.getRoleId()));
|
||||
this.quickFuncMapper.insert(checkedList);
|
||||
List<QuickFunction> existList = this.quickFuncMapper.selectList(new LambdaQueryWrapper<QuickFunction>()
|
||||
.eq(QuickFunction::getUserId, updateDTO.getUserId()).eq(QuickFunction::getDelFlag, Constants.UNDELETED));
|
||||
if (ObjectUtils.isNotEmpty(existList)) {
|
||||
existList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
this.quickFuncMapper.updateById(existList);
|
||||
}
|
||||
// 再新增新的快捷功能绑定关系
|
||||
List<QuickFunction> checkedList = updateDTO.getMenuList().stream()
|
||||
.map(x -> BeanUtil.toBean(x, QuickFunction.class).setUserId(updateDTO.getUserId())).collect(Collectors.toList());
|
||||
return this.quickFuncMapper.insert(checkedList).size();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.xkt.mapper.QuickFunctionMapper">
|
||||
|
||||
<update id="updateDelFlagByRoleIdAndBizId" parameterType="Long">
|
||||
UPDATE quick_function SET del_flag = 2 WHERE role_id = #{roleId} AND biz_id = #{bizId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue