fix:部门管理列表
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.nl.modules.system.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.system.service.dto.MenuDto;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptVo implements Serializable {
|
||||
|
||||
|
||||
private Long dept_id;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer dept_sort;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "部门名称")
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "是否启用")
|
||||
private Boolean is_used;
|
||||
|
||||
@ApiModelProperty(value = "上级部门")
|
||||
private Long pid;
|
||||
|
||||
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||
private Integer sub_count = 0;
|
||||
//前端显示
|
||||
private Boolean hasChildren =Boolean.FALSE;
|
||||
|
||||
private List<DeptVo> children;
|
||||
|
||||
public void setSub_count(Integer sub_count) {
|
||||
this.sub_count = sub_count;
|
||||
if (sub_count>0){
|
||||
this.hasChildren=Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,10 +28,12 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.PageUtil;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.Dept;
|
||||
import org.nl.modules.system.domain.vo.DeptVo;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.dto.DeptDto;
|
||||
import org.nl.modules.system.service.dto.DeptQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.DeptTree;
|
||||
import org.nl.modules.system.util.CopyUtil;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -60,6 +62,18 @@ public class DeptController {
|
||||
return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping("/vo")
|
||||
public ResponseEntity<Object> queryvo(DeptQueryCriteria criteria) throws Exception {
|
||||
if (criteria.getPid() == null){
|
||||
criteria.setPidIsNull(true);
|
||||
}
|
||||
List<Dept> deptDtos = deptService.queryAll(criteria, true);
|
||||
List<DeptVo> deptVos = CopyUtil.copyList(deptDtos, DeptVo.class);
|
||||
return new ResponseEntity<>(PageUtil.toPage(deptVos, deptVos.size()),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询所有部门树")
|
||||
@GetMapping("/allTree")
|
||||
public ResponseEntity<Object> allTree(DeptQueryCriteria criteria) throws Exception {
|
||||
@@ -80,6 +94,7 @@ public class DeptController {
|
||||
List<DeptTree> superior = deptService.getSuperior(deptTree, new ArrayList<>());
|
||||
deptDtos.addAll(superior);
|
||||
}
|
||||
List<DeptVo> deptVos = CopyUtil.copyList(deptDtos, DeptVo.class);
|
||||
return new ResponseEntity<>(deptService.buildTree(new ArrayList<>(deptDtos)),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -98,7 +113,7 @@ public class DeptController {
|
||||
@Log("修改部门")
|
||||
@ApiOperation("修改部门")
|
||||
@PutMapping
|
||||
@SaCheckPermission("dept:edit")
|
||||
// @SaCheckPermission("dept:edit")
|
||||
public ResponseEntity<Object> update(@RequestBody Dept resources){
|
||||
deptService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
||||
@@ -143,7 +143,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
Dept dept = findById(resources.getDept_id());
|
||||
resources.setDept_id(dept.getDept_id());
|
||||
WQLObject.getWQLObject("sys_user").update((JSONObject)JSON.toJSON(resources),"dept_id = '"+resources.getDept_id()+"'");
|
||||
WQLObject.getWQLObject("sys_dept").update((JSONObject)JSON.toJSON(resources),"dept_id = '"+resources.getDept_id()+"'");
|
||||
// 更新父节点中子节点数目
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
|
||||
@@ -2,8 +2,9 @@ package org.nl.modules.system.util;
|
||||
|
||||
import org.nl.modules.system.service.GenCodeService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
|
||||
public class CodeUtil {
|
||||
|
||||
@@ -15,4 +16,5 @@ public class CodeUtil {
|
||||
return SpringContextHolder.getBean(GenCodeService.class).codeDemo(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.modules.system.util;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/1 3:35 下午
|
||||
*/
|
||||
public class CopyUtil {
|
||||
public static <F, T> List<T> copyList(final Collection<F> sources, final Class<T> clazz) {
|
||||
if (sources == null) {
|
||||
return new ArrayList(0);
|
||||
} else {
|
||||
List<T> list = new ArrayList(sources.size());
|
||||
Iterator var3 = sources.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
Object source = var3.next();
|
||||
|
||||
try {
|
||||
T dest = clazz.newInstance();
|
||||
BeanUtils.copyProperties(source, dest);
|
||||
list.add(dest);
|
||||
} catch (Throwable var6) {
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@
|
||||
sys_dept
|
||||
WHERE 1=1
|
||||
OPTION 输入.pid <> ""
|
||||
pid = 输入.id
|
||||
pid = 输入.pid
|
||||
ENDOPTION
|
||||
OPTION 输入.name <> ""
|
||||
name = 输入.name
|
||||
|
||||
Reference in New Issue
Block a user