修改用户表
This commit is contained in:
parent
e3264e81e3
commit
44aac5403e
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||||
import com.bonus.common.annotation.RequiresPermissions;
|
import com.bonus.common.annotation.RequiresPermissions;
|
||||||
import com.bonus.common.annotation.SysLog;
|
import com.bonus.common.annotation.SysLog;
|
||||||
import com.bonus.common.enums.OperaType;
|
import com.bonus.common.enums.OperaType;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
@ -33,6 +35,7 @@ import com.bonus.system.service.ISysDeptService;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/dept")
|
@RequestMapping("/system/dept")
|
||||||
|
@Slf4j
|
||||||
public class SysDeptController extends BaseController {
|
public class SysDeptController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysDeptService deptService;
|
private ISysDeptService deptService;
|
||||||
|
|
@ -146,4 +149,17 @@ public class SysDeptController extends BaseController {
|
||||||
deptService.checkDeptDataScope(deptId);
|
deptService.checkDeptDataScope(deptId);
|
||||||
return toAjax(deptService.deleteDeptById(deptId));
|
return toAjax(deptService.deleteDeptById(deptId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取部门下拉")
|
||||||
|
@GetMapping("getDeptSelect")
|
||||||
|
@SysLog(title = "获取部门下拉", module = "数据/档案移交->档案移交申请", businessType = OperaType.QUERY, details = "获取部门下拉", logType = 1)
|
||||||
|
public AjaxResult getDeptSelect(SysDept dto) {
|
||||||
|
try {
|
||||||
|
List<SysDept> list = deptService.getDeptSelect(dto);
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.toString(), e);
|
||||||
|
return AjaxResult.error("请求出错了");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,4 +121,11 @@ public interface SysDeptMapper
|
||||||
Integer getSysUserDeptId(Long deptId);
|
Integer getSysUserDeptId(Long deptId);
|
||||||
|
|
||||||
Integer getTransferIssueDeptId(Long deptId);
|
Integer getTransferIssueDeptId(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询下拉选
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysDept> getDeptSelect(SysDept dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,4 +127,11 @@ public interface ISysDeptService
|
||||||
Integer getSysUserDeptId(Long deptId);
|
Integer getSysUserDeptId(Long deptId);
|
||||||
|
|
||||||
Integer getTransferIssueDeptId(Long deptId);
|
Integer getTransferIssueDeptId(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门不下来选
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SysDept> getDeptSelect(SysDept dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package com.bonus.system.service.impl;
|
package com.bonus.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -87,7 +85,30 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
}
|
}
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
public static List<SysDept> buildDeptTree2(List<SysDept> list) {
|
||||||
|
// 使用 Map 提升查找效率
|
||||||
|
Map<Long, SysDept> map = new HashMap<>();
|
||||||
|
List<SysDept> roots = new ArrayList<>();
|
||||||
|
|
||||||
|
// 第一步:将所有节点放入 map
|
||||||
|
for (SysDept item : list) {
|
||||||
|
map.put(item.getDeptId(), item);
|
||||||
|
}
|
||||||
|
// 第二步:构建父子关系
|
||||||
|
for (SysDept item : list) {
|
||||||
|
Long parentId = item.getParentId();
|
||||||
|
// 如果 parent_id 为 null,则为根节点
|
||||||
|
if (parentId == 0) {
|
||||||
|
roots.add(item);
|
||||||
|
} else {
|
||||||
|
SysDept parent = map.get(parentId);
|
||||||
|
if (parent != null) {
|
||||||
|
parent.getChildren().add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 构建前端所需要下拉树结构
|
* 构建前端所需要下拉树结构
|
||||||
*
|
*
|
||||||
|
|
@ -312,6 +333,16 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
return deptMapper.getTransferIssueDeptId(deptId);
|
return deptMapper.getTransferIssueDeptId(deptId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> getDeptSelect(SysDept dto) {
|
||||||
|
List<SysDept> deptSelect = deptMapper.getDeptSelect(dto);
|
||||||
|
// 构建树
|
||||||
|
List<SysDept> tree = buildDeptTree2(deptSelect);
|
||||||
|
return tree;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 递归列表
|
* 递归列表
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -135,8 +135,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
INNER JOIN DeptTree dt ON t.dept_id = dt.dept_id
|
INNER JOIN DeptTree dt ON t.dept_id = dt.dept_id
|
||||||
WHERE t.del_flag = '1'
|
WHERE t.del_flag = '1'
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getDeptSelect" resultType="com.bonus.common.core.domain.entity.SysDept">
|
||||||
|
SELECT dept_id AS deptId,
|
||||||
|
parent_id AS parentId,
|
||||||
|
ancestors,
|
||||||
|
dept_name AS deptName,
|
||||||
|
order_num AS orderNum,
|
||||||
|
leader,
|
||||||
|
phone,
|
||||||
|
email,
|
||||||
|
status,
|
||||||
|
del_flag AS delFlag
|
||||||
|
FROM da_ky_sys_dept
|
||||||
|
WHERE del_flag = '0'
|
||||||
|
and status = '0'
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertDept" parameterType="SysDept">
|
<insert id="insertDept" parameterType="SysDept">
|
||||||
insert into da_ky_sys_dept(
|
insert into da_ky_sys_dept(
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
<if test="parentId != null and parentId != 0">parent_id,</if>
|
<if test="parentId != null and parentId != 0">parent_id,</if>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue