人员配置机构
This commit is contained in:
+27
-3
@@ -9,11 +9,10 @@ import com.adc.da.sys.common.SelectionResult;
|
||||
import com.adc.da.sys.service.IDicTypeEOService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.sarMenu.entity.SarMenu;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -78,4 +77,29 @@ public class SarMenuController extends BaseController<SarMenu> {
|
||||
resultList.addAll(listDic);
|
||||
return Result.success(resultList);
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有菜单")
|
||||
@GetMapping
|
||||
public ResponseMessage<List<SarMenu>> getAll(){
|
||||
List<SarMenu> sarMenus=sarMenuEOService.getAll();
|
||||
return Result.success(sarMenus);
|
||||
}
|
||||
|
||||
@ApiOperation("添加菜单")
|
||||
@PostMapping("/add")
|
||||
public ResponseMessage<Object> addMenu(@RequestBody SarMenu sarMenu){
|
||||
return sarMenuEOService.addMenu(sarMenu);
|
||||
}
|
||||
|
||||
@ApiOperation("编辑菜单")
|
||||
@PutMapping
|
||||
public ResponseMessage<Object> updateMenu(@Validated(SarMenu.update.class) @RequestBody SarMenu sarMenu){
|
||||
return sarMenuEOService.updateMenu(sarMenu);
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
@DeleteMapping
|
||||
public ResponseMessage<Object> delMenu(@RequestParam Integer menuId){
|
||||
return sarMenuEOService.delMenu(menuId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.adc.da.base.entity.BaseEntity;
|
||||
import com.adc.da.utils.treetool.annotation.TreeNodeId;
|
||||
import com.adc.da.utils.treetool.annotation.TreeNodeName;
|
||||
import com.adc.da.utils.treetool.annotation.TreeNodeParentId;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
@@ -17,6 +18,8 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
@@ -30,13 +33,15 @@ import org.springframework.data.annotation.Transient;
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="SarMenu对象", description="")
|
||||
public class SarMenu extends BaseEntity {
|
||||
public interface update{
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@TreeNodeId
|
||||
@NotNull(message = "id不能为空",groups = {update.class})
|
||||
@ApiModelProperty(value = "主键")
|
||||
@TableId("ID")
|
||||
@TableId(value = "ID",type = IdType.UUID)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "标准法规划分")
|
||||
@@ -81,6 +86,10 @@ public class SarMenu extends BaseEntity {
|
||||
@TableField("REMARKS")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty(value = "子菜单")
|
||||
@TableField(exist = false)
|
||||
private List<SarMenu> children;
|
||||
|
||||
@TableField(exist=false)
|
||||
private List<String> roleIds;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.adc.da.slrs.sarMenu.service;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.slrs.sarMenu.entity.SarMenu;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -31,4 +32,30 @@ public interface ISarMenuService extends IService<SarMenu> {
|
||||
* @return List<SarMenu>
|
||||
*/
|
||||
List<SarMenu> getMenusByIds(List<String> menuIds);
|
||||
|
||||
/**
|
||||
* 查询所有菜单
|
||||
*/
|
||||
List<SarMenu> getAll();
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
* @param sarMenu:菜单信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> addMenu(SarMenu sarMenu);
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
* @param sarMenu:菜单信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> updateMenu(SarMenu sarMenu);
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
* @param menuId:菜单ID
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
ResponseMessage<Object> delMenu(Integer menuId);
|
||||
}
|
||||
|
||||
+88
@@ -1,5 +1,7 @@
|
||||
package com.adc.da.slrs.sarMenu.service.impl;
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.login.util.UserUtils;
|
||||
import com.adc.da.slrs.sarMenu.entity.SarMenu;
|
||||
import com.adc.da.slrs.sarMenu.dao.SarMenuDao;
|
||||
@@ -164,4 +166,90 @@ public class SarMenuServiceImpl extends ServiceImpl<SarMenuDao, SarMenu> impleme
|
||||
menuQueryWrapper.in("id",menuIds);
|
||||
return dao.selectList(menuQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有菜单
|
||||
*/
|
||||
@Override
|
||||
public List<SarMenu> getAll() {
|
||||
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
|
||||
sarMenuQueryWrapper.orderByAsc("DISPLAY_SEQ");
|
||||
sarMenuQueryWrapper.isNull("PARENT_ID");
|
||||
List<SarMenu> sarMenus=dao.selectList(sarMenuQueryWrapper);
|
||||
for(SarMenu sarMenu:sarMenus){
|
||||
sarMenu.setChildren(recursionGetChildren((sarMenu)));
|
||||
}
|
||||
return sarMenus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
* @param sarMenu:菜单信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> addMenu(SarMenu sarMenu) {
|
||||
if(sarMenu.getParentId()!=null){
|
||||
SarMenu parent=dao.selectById(sarMenu.getParentId());
|
||||
if(parent==null){
|
||||
return Result.error("该父菜单不存在");
|
||||
}
|
||||
}
|
||||
dao.insert(sarMenu);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑菜单
|
||||
* @param sarMenu:菜单信息
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> updateMenu(SarMenu sarMenu) {
|
||||
SarMenu oldMenu=dao.selectById(sarMenu.getId());
|
||||
if(oldMenu==null){
|
||||
return Result.error("该菜单不存在");
|
||||
}
|
||||
if(sarMenu.getParentId()!=null){
|
||||
SarMenu parent=dao.selectById(sarMenu.getParentId());
|
||||
if(parent==null){
|
||||
return Result.error("父节点不存在");
|
||||
}
|
||||
}
|
||||
dao.updateById(sarMenu);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除菜单
|
||||
* @param menuId:菜单ID
|
||||
* @return ResponseMessage<Object>
|
||||
*/
|
||||
@Override
|
||||
public ResponseMessage<Object> delMenu(Integer menuId) {
|
||||
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
|
||||
sarMenuQueryWrapper.eq("parent_id",menuId);
|
||||
List<SarMenu> children=dao.selectList(sarMenuQueryWrapper);
|
||||
if(children!=null&&children.size()>0){
|
||||
return Result.error("该菜单有子节点,无法删除");
|
||||
}
|
||||
dao.deleteById(menuId);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归调用获取子节点
|
||||
* @param parent:父节点
|
||||
* @return List<SarMenu>
|
||||
*/
|
||||
private List<SarMenu> recursionGetChildren(SarMenu parent){
|
||||
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
|
||||
sarMenuQueryWrapper.orderByAsc("DISPLAY_SEQ");
|
||||
sarMenuQueryWrapper.eq("PARENT_ID",parent.getId());
|
||||
List<SarMenu> children=dao.selectList(sarMenuQueryWrapper);
|
||||
for(SarMenu sarMenu:children){
|
||||
sarMenu.setChildren(recursionGetChildren((sarMenu)));
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user