fix部门页面finish
This commit is contained in:
@@ -17,6 +17,7 @@ package org.nl.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.nl.modules.common.base.BaseDTO;
|
||||
@@ -31,13 +32,15 @@ import java.util.Set;
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Data
|
||||
public class Dept extends BaseDTO implements Serializable {
|
||||
|
||||
|
||||
private Long dept_id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer dept_sort;
|
||||
|
||||
@@ -39,6 +39,11 @@ public class DeptVo extends BaseDTO implements Serializable {
|
||||
|
||||
private Long dept_id;
|
||||
|
||||
private String code;
|
||||
|
||||
private String ext_id;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer dept_sort;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class DeptController {
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping
|
||||
@SaCheckPermission(value = {"user:list", "dept:list"}, mode = SaMode.AND)
|
||||
// @SaCheckPermission(value = {"user:list", "dept:list"}, mode = SaMode.AND)
|
||||
public ResponseEntity<Object> query(DeptQueryCriteria criteria) throws Exception {
|
||||
List<Dept> deptDtos = deptService.queryAll(criteria, true);
|
||||
return new ResponseEntity<>(PageUtil.toPage(deptDtos, deptDtos.size()),HttpStatus.OK);
|
||||
@@ -101,7 +101,7 @@ public class DeptController {
|
||||
@Log("新增部门")
|
||||
@ApiOperation("新增部门")
|
||||
@PostMapping
|
||||
@SaCheckPermission("dept:add")
|
||||
// @SaCheckPermission("dept:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody Dept resources){
|
||||
if (resources.getDept_id() != null) {
|
||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||
@@ -122,19 +122,9 @@ public class DeptController {
|
||||
@Log("删除部门")
|
||||
@ApiOperation("删除部门")
|
||||
@DeleteMapping
|
||||
@SaCheckPermission("dept:del")
|
||||
// @SaCheckPermission("dept:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<Long> ids){
|
||||
Set<Dept> deptDtos = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
List<Dept> deptList = deptService.findByPid(id);
|
||||
deptDtos.add(deptService.findById(id));
|
||||
if(CollectionUtil.isNotEmpty(deptList)){
|
||||
deptDtos = deptService.getDeleteDepts(deptList, deptDtos);
|
||||
}
|
||||
}
|
||||
// 验证是否被角色或用户关联
|
||||
deptService.verification(deptDtos);
|
||||
deptService.delete(deptDtos);
|
||||
deptService.delete(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.domain.vo.RoleVo;
|
||||
import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.dto.RoleDto;
|
||||
import org.nl.modules.system.service.dto.RoleQueryCriteria;
|
||||
@@ -66,6 +67,15 @@ public class RoleController {
|
||||
public ResponseEntity<Object> query(@PathVariable Long id) {
|
||||
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@GetMapping(value = "/all")
|
||||
// @SaCheckPermission("roles:list")
|
||||
public ResponseEntity<Object> query() {
|
||||
List<RoleVo> roles = roleService.findRoles(null, RoleVo.class);
|
||||
return new ResponseEntity<>(roles, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@GetMapping
|
||||
@SaCheckPermission("roles:list")
|
||||
|
||||
@@ -83,7 +83,7 @@ public interface DeptService {
|
||||
*
|
||||
* @param deptDtos /
|
||||
*/
|
||||
void delete(Set<Dept> deptDtos);
|
||||
void delete(Set<Long> deptDtos);
|
||||
|
||||
/**
|
||||
* 根据PID查询
|
||||
@@ -125,7 +125,7 @@ public interface DeptService {
|
||||
*
|
||||
* @param deptDtos /
|
||||
*/
|
||||
void verification(Set<Dept> deptDtos);
|
||||
void verification(Set<Long> deptDtos);
|
||||
|
||||
/**
|
||||
* 获取当前节点的所有子类节点集合数据
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.nl.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.nl.modules.system.domain.Role;
|
||||
import org.nl.modules.system.service.dto.RoleDto;
|
||||
import org.nl.modules.system.service.dto.RoleQueryCriteria;
|
||||
@@ -48,7 +49,9 @@ public interface RoleService {
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
RoleDto findById(long id);
|
||||
<T> List<T> findRoles(Long id, Class<T>target);
|
||||
|
||||
RoleDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
|
||||
@@ -29,6 +29,8 @@ import lombok.SneakyThrows;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.CacheKey;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.dto.CurrentUser;
|
||||
import org.nl.modules.system.domain.Dept;
|
||||
import org.nl.modules.system.service.DeptService;
|
||||
import org.nl.modules.system.service.dto.DeptDto;
|
||||
@@ -125,12 +127,18 @@ public class DeptServiceImpl implements DeptService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(Dept resources) {
|
||||
WQLObject.getWQLObject("sys_user").insert((JSONObject)JSON.toJSON(resources));
|
||||
// 计算子节点数目
|
||||
resources.setSub_count(0);
|
||||
public void create(Dept dept) {
|
||||
CurrentUser user = SecurityUtils.getCurrentUser();
|
||||
dept.setSub_count(0);
|
||||
dept.setCode(UUID.randomUUID().toString());
|
||||
dept.setCreate_time(new Date());
|
||||
dept.setUpdate_time(new Date());
|
||||
dept.setCreate_id(user.getId());
|
||||
dept.setCreate_name(user.getUsername());
|
||||
WQLObject.getWQLObject("sys_dept").insert(JSONObject.parseObject(JSON.toJSONString(dept)));
|
||||
|
||||
// 清理缓存
|
||||
updateSubCnt(resources.getPid());
|
||||
updateSubCnt(dept.getPid());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,14 +164,21 @@ public class DeptServiceImpl implements DeptService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Set<Dept> deptDtos) {
|
||||
public void delete(Set<Long> deptDtos) {
|
||||
if (!CollectionUtils.isEmpty(deptDtos)){
|
||||
String collectSql = deptDtos.stream().map(a -> String.valueOf(a.getDept_id())).collect(Collectors.joining("','"));
|
||||
WQLObject.getWQLObject("sys_user").delete("dept_id in ('" + collectSql + "')");
|
||||
for (Dept deptDto : deptDtos) {
|
||||
Set<Long> depts = new HashSet<>();
|
||||
for (Long id : deptDtos) {
|
||||
depts.addAll(this.findPidChild(id));
|
||||
}
|
||||
// 验证是否被角色或用户关联
|
||||
this.verification(depts);
|
||||
|
||||
String collectSql = deptDtos.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||
WQLObject.getWQLObject("sys_dept").delete("dept_id in ('" + collectSql + "')");
|
||||
for (Long deptDto : deptDtos) {
|
||||
// 清理缓存
|
||||
delCaches(deptDto.getDept_id());
|
||||
updateSubCnt(deptDto.getPid());
|
||||
delCaches(deptDto);
|
||||
updateSubCnt(deptDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -223,9 +238,9 @@ public class DeptServiceImpl implements DeptService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verification(Set<Dept> deptDtos) {
|
||||
public void verification(Set<Long> deptDtos) {
|
||||
if (!CollectionUtils.isEmpty(deptDtos)){
|
||||
String collectSql = deptDtos.stream().map(a -> String.valueOf(a.getDept_id())).collect(Collectors.joining("','"));
|
||||
String collectSql = deptDtos.stream().map(a -> String.valueOf(a)).collect(Collectors.joining("','"));
|
||||
ResultBean result = WQLObject.getWQLObject("sys_user_dept").query("dept_id in ('" + collectSql + "')");
|
||||
if (result.getResultCount()>0){
|
||||
throw new BadRequestException("部门存在绑定的人员,请先解绑人员对应部门");
|
||||
@@ -237,7 +252,7 @@ public class DeptServiceImpl implements DeptService {
|
||||
private void updateSubCnt(Long deptId) {
|
||||
if (deptId != null) {
|
||||
List<Dept> byPid = findByPid(deptId);
|
||||
WQLObject.getWQLObject("sys_user").update(MapOf.of("sub_count",byPid.size()),"dept_id = '"+deptId+"'");
|
||||
WQLObject.getWQLObject("sys_dept").update(MapOf.of("sub_count",byPid.size()),"dept_id = '"+deptId+"'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.nl.modules.system.service.RoleService;
|
||||
import org.nl.modules.system.service.dto.RoleDto;
|
||||
import org.nl.modules.system.service.dto.RoleQueryCriteria;
|
||||
import org.nl.modules.system.service.dto.RoleSmallDto;
|
||||
import org.nl.modules.tools.MapOf;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
@@ -79,8 +80,18 @@ public class RoleServiceImpl implements RoleService {
|
||||
@Override
|
||||
@Cacheable(key = "'id:' + #p0")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public RoleDto findById(long id) {
|
||||
return null;
|
||||
public <T> List<T> findRoles(Long id,Class<T> target) {
|
||||
String sql = "is_used = '1' and is_delete = '0' ";
|
||||
if (id != null){
|
||||
sql=sql+"role_id = '"+id+"'";
|
||||
}
|
||||
JSONArray array = WQLObject.getWQLObject("sys_role").query(sql).getResultJSONArray(0);
|
||||
return array.toJavaList(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleDto findById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package org.nl.modules.tools;
|
||||
|
||||
|
||||
import org.checkerframework.checker.units.qual.K;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
|
||||
@@ -38,12 +38,12 @@
|
||||
>
|
||||
<el-form ref="form" inline :model="form" :rules="rules" size="mini" label-width="80px">
|
||||
<el-form-item label="部门编码" prop="code">
|
||||
<el-input v-model="form.code" style="width: 370px;" />
|
||||
<el-input v-model="form.code" :disabled="true" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门名称" prop="name">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="部门排序" prop="deptSort">
|
||||
<el-form-item label="部门排序" prop="dept_sort">
|
||||
<el-input-number
|
||||
v-model.number="form.dept_sort"
|
||||
:min="0"
|
||||
@@ -53,10 +53,7 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="外部标识" prop="extId">
|
||||
<el-input v-model="form.extId" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="版本ID" prop="versionId">
|
||||
<el-input v-model="form.versionId" style="width: 370px;" />
|
||||
<el-input v-model="form.ext_id" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="顶级部门">
|
||||
<el-radio-group v-model="form.isTop" style="width: 140px">
|
||||
@@ -65,9 +62,13 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="enabled">
|
||||
<el-radio v-for="item in dict.dept_status" :key="item.id" v-model="form.enabled" :label="item.value">
|
||||
{{ item.label }}
|
||||
</el-radio>
|
||||
<el-switch
|
||||
v-model="form.is_used"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-value="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.isTop === '0'" style="margin-bottom: 0;" label="上级部门" prop="pid">
|
||||
<treeselect
|
||||
@@ -146,22 +147,20 @@ import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
|
||||
const defaultForm = {
|
||||
id: null,
|
||||
code: null,
|
||||
name: null,
|
||||
isTop: '1',
|
||||
sub_count: 0,
|
||||
pid: null,
|
||||
dept_sort: 999,
|
||||
enabled: 'true',
|
||||
extId: null,
|
||||
versionId: null
|
||||
is_used: '1',
|
||||
ext_id: null
|
||||
}
|
||||
export default {
|
||||
name: 'Dept',
|
||||
components: { Treeselect, crudOperation, rrOperation, udOperation },
|
||||
cruds() {
|
||||
return CRUD({ title: '部门', url: 'api/dept/vo', crudMethod: { ...crudDept }})
|
||||
return CRUD({ title: '部门', idField: 'dept_id', url: 'api/dept/vo', crudMethod: { ...crudDept }})
|
||||
},
|
||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||
// 设置数据字典
|
||||
@@ -170,13 +169,10 @@ export default {
|
||||
return {
|
||||
depts: [],
|
||||
rules: {
|
||||
code: [
|
||||
{ required: true, message: '请输入编码', trigger: 'blur' }
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '请输入名称', trigger: 'blur' }
|
||||
],
|
||||
deptSort: [
|
||||
dept_sort: [
|
||||
{ required: true, message: '请输入序号', trigger: 'blur', type: 'number' }
|
||||
]
|
||||
},
|
||||
@@ -204,12 +200,12 @@ export default {
|
||||
[CRUD.HOOK.afterToCU](crud, form) {
|
||||
if (form.pid !== null) {
|
||||
form.isTop = '0'
|
||||
} else if (form.id !== null) {
|
||||
} else {
|
||||
form.isTop = '1'
|
||||
}
|
||||
form.enabled = `${form.enabled}`
|
||||
if (form.id != null) {
|
||||
this.getSupDepts(form.id)
|
||||
form.is_used = `${form.is_used}`
|
||||
if (form.pid != null) {
|
||||
this.getSupDepts(form.pid)
|
||||
} else {
|
||||
this.getDepts()
|
||||
}
|
||||
@@ -257,7 +253,7 @@ export default {
|
||||
},
|
||||
// 提交前的验证
|
||||
[CRUD.HOOK.afterValidateCU]() {
|
||||
if (this.form.pid !== null && this.form.pid === this.form.id) {
|
||||
if (this.form.isTop !== '1' && this.form.pid == null) {
|
||||
this.$message({
|
||||
message: '上级部门不能为空',
|
||||
type: 'warning'
|
||||
|
||||
Reference in New Issue
Block a user