|
|
@@ -2,6 +2,7 @@ package com.xjrsoft.module.system.controller;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
@@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.toolkit.MPJWrappers;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.jdcloud.sdk.utils.StringUtils;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.enums.AuthorizeType;
|
|
|
@@ -21,24 +23,11 @@ import com.xjrsoft.common.model.result.R;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.utils.TreeUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.organization.entity.Department;
|
|
|
import com.xjrsoft.module.organization.service.IUserRoleRelationService;
|
|
|
-import com.xjrsoft.module.system.dto.AddMenuDto;
|
|
|
-import com.xjrsoft.module.system.dto.AddMenuFormDto;
|
|
|
-import com.xjrsoft.module.system.dto.MenuTreeDto;
|
|
|
-import com.xjrsoft.module.system.dto.RoleMenuServeListDto;
|
|
|
-import com.xjrsoft.module.system.dto.UpdateMenuDto;
|
|
|
-import com.xjrsoft.module.system.dto.UpdateMenuFormDto;
|
|
|
-import com.xjrsoft.module.system.entity.Authorize;
|
|
|
-import com.xjrsoft.module.system.entity.Menu;
|
|
|
-import com.xjrsoft.module.system.entity.MenuButton;
|
|
|
-import com.xjrsoft.module.system.entity.MenuColumn;
|
|
|
-import com.xjrsoft.module.system.entity.MenuForm;
|
|
|
-import com.xjrsoft.module.system.entity.Subsystem;
|
|
|
-import com.xjrsoft.module.system.service.IAuthorizeService;
|
|
|
-import com.xjrsoft.module.system.service.IMenuButtonService;
|
|
|
-import com.xjrsoft.module.system.service.IMenuColumnService;
|
|
|
-import com.xjrsoft.module.system.service.IMenuFormService;
|
|
|
-import com.xjrsoft.module.system.service.IMenuService;
|
|
|
+import com.xjrsoft.module.system.dto.*;
|
|
|
+import com.xjrsoft.module.system.entity.*;
|
|
|
+import com.xjrsoft.module.system.service.*;
|
|
|
import com.xjrsoft.module.system.vo.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
@@ -56,6 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.validation.Valid;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -82,6 +72,8 @@ public class MenuController {
|
|
|
|
|
|
private final IAuthorizeService authorizeService;
|
|
|
|
|
|
+ private final IXjrMenuDeptRelationService xjrMenuDeptRelationService;
|
|
|
+
|
|
|
private final IUserRoleRelationService userRoleRelationService;
|
|
|
|
|
|
@GetMapping("/list")
|
|
|
@@ -140,8 +132,7 @@ public class MenuController {
|
|
|
if (StrUtil.isEmpty(dto.getSystemType())) {
|
|
|
dto.setSystemType(SystemTypeEnum.SYSTEMPC.getCode());
|
|
|
}
|
|
|
- List<MenuTreeVo> list = menuService.selectJoinList(MenuTreeVo.class,
|
|
|
- MPJWrappers.<Menu>lambdaJoin()
|
|
|
+ MPJLambdaWrapper<Menu> wrapper = MPJWrappers.<Menu>lambdaJoin()
|
|
|
.like(StrUtil.isNotEmpty(dto.getTitle()), Menu::getTitle, dto.getTitle())
|
|
|
.like(StrUtil.isNotEmpty(dto.getName()), Menu::getName, dto.getName())
|
|
|
.like(ObjectUtil.isNotNull(dto.getSystemId()) && dto.getSystemId() > 0, Menu::getSystemId, dto.getSystemId())
|
|
|
@@ -150,13 +141,29 @@ public class MenuController {
|
|
|
.select(Menu.class, x -> VoToColumnUtil.fieldsToColumns(MenuTreeVo.class).contains(x.getProperty()))
|
|
|
.selectAs(Subsystem::getName, MenuTreeVo::getSystemName)
|
|
|
.eq(ObjectUtils.isNotEmpty(dto.getEnabledMark()), Menu::getEnabledMark, dto.getEnabledMark())
|
|
|
- .leftJoin(Subsystem.class, Subsystem::getId, Menu::getSystemId)
|
|
|
- .orderByAsc(Menu::getSortCode));
|
|
|
+ .leftJoin(Subsystem.class, Subsystem::getId, Menu::getSystemId);
|
|
|
+
|
|
|
+// wrapper.selectAs(Department::getName, MenuTreeVo::getDeptName)
|
|
|
+// .leftJoin(XjrMenuDeptRelation.class, XjrMenuDeptRelation::getMenuId,Menu::getId)
|
|
|
+// .leftJoin(Department.class, Department::getId, XjrMenuDeptRelation::getDeptId);
|
|
|
+//
|
|
|
+// if (StrUtil.isNotEmpty(dto.getDeptIds())) {
|
|
|
+// String[] deptIdArray = dto.getDeptIds().split(",");
|
|
|
+// List<String> deptIdList = Arrays.asList(deptIdArray);
|
|
|
+//
|
|
|
+// if (CollectionUtil.isNotEmpty(deptIdList)) {
|
|
|
+// wrapper.in(XjrMenuDeptRelation::getDeptId, deptIdList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ wrapper.orderByAsc(Menu::getSortCode);
|
|
|
+
|
|
|
+ List<MenuTreeVo> list = menuService.selectJoinList(MenuTreeVo.class, wrapper);
|
|
|
List<MenuTreeVo> treeVoList = TreeUtil.build(list);
|
|
|
|
|
|
return R.ok(treeVoList);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@GetMapping("/child-tree")
|
|
|
@ApiOperation(value = "获取所有菜单(树结构,禁用父级)")
|
|
|
public R menuChildTree(@Valid MenuTreeDto dto) {
|
|
|
@@ -246,6 +253,13 @@ public class MenuController {
|
|
|
menuFormService.remove(Wrappers.<MenuForm>query().lambda().eq(MenuForm::getMenuId, menu.getId()));
|
|
|
menuFormService.saveBatch(formList);
|
|
|
|
|
|
+ List<XjrMenuDeptRelation> menuDeptRelationsList = new ArrayList<>();
|
|
|
+ for (AddXjrMenuDeptRelationDto addXjrMenuDeptRelationDto : dto.getMenuDeptRelations()) {
|
|
|
+ menuDeptRelationsList.add(BeanUtil.toBean(addXjrMenuDeptRelationDto, XjrMenuDeptRelation.class));
|
|
|
+ }
|
|
|
+ menuDeptRelationsList.forEach(XjrMenuDeptRelation -> XjrMenuDeptRelation.setMenuId(menu.getId()));
|
|
|
+ xjrMenuDeptRelationService.remove(Wrappers.<XjrMenuDeptRelation>query().lambda().eq(XjrMenuDeptRelation::getMenuId, menu.getId()));
|
|
|
+ xjrMenuDeptRelationService.saveBatch(menuDeptRelationsList);
|
|
|
|
|
|
return R.ok(isSuccess);
|
|
|
}
|
|
|
@@ -304,6 +318,10 @@ public class MenuController {
|
|
|
formList.forEach(menuForm -> menuForm.setMenuId(menu.getId()));
|
|
|
menuFormService.remove(Wrappers.<MenuForm>query().lambda().eq(MenuForm::getMenuId, menu.getId()));
|
|
|
|
|
|
+ List<XjrMenuDeptRelation> menuDeptRelations = BeanUtil.copyToList(dto.getMenuDeptRelations(), XjrMenuDeptRelation.class);
|
|
|
+ menuDeptRelations.forEach(XjrMenuDeptRelation -> XjrMenuDeptRelation.setMenuId(menu.getId()));
|
|
|
+ xjrMenuDeptRelationService.remove(Wrappers.<XjrMenuDeptRelation>query().lambda().eq(XjrMenuDeptRelation::getMenuId, menu.getId()));
|
|
|
+
|
|
|
if (CollectionUtils.isNotEmpty(menuButtons)) {
|
|
|
menuButtonService.saveBatch(menuButtons);
|
|
|
}
|
|
|
@@ -313,6 +331,9 @@ public class MenuController {
|
|
|
if (CollectionUtils.isNotEmpty(formList)) {
|
|
|
menuFormService.saveBatch(formList);
|
|
|
}
|
|
|
+ if (CollectionUtils.isNotEmpty(menuDeptRelations)) {
|
|
|
+ xjrMenuDeptRelationService.saveBatch(menuDeptRelations);
|
|
|
+ }
|
|
|
return R.ok();
|
|
|
}
|
|
|
|