zhousq
9 months ago
4 changed files with 646 additions and 0 deletions
@ -0,0 +1,64 @@ |
|||
package com.lzbi.common.controller; |
|||
|
|||
import com.lzbi.common.core.controller.BaseController; |
|||
import com.lzbi.common.core.domain.AjaxResult; |
|||
import com.lzbi.common.core.domain.entity.SysDept; |
|||
import com.lzbi.common.service.IotSysDeptService; |
|||
import com.lzbi.common.utils.StringUtils; |
|||
import org.apache.commons.lang3.ArrayUtils; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.PathVariable; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
@RestController |
|||
@RequestMapping("/common/iot/dept") |
|||
public class IOTCommonDataControler extends BaseController{ |
|||
@Resource |
|||
IotSysDeptService iotSysDeptService; |
|||
/** |
|||
* 获取部门列表 |
|||
*/ |
|||
//@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
|||
@GetMapping("/list") |
|||
public AjaxResult list(SysDept dept) |
|||
{ |
|||
List<SysDept> depts = iotSysDeptService.selectDeptList(dept); |
|||
return success(depts); |
|||
} |
|||
|
|||
/** |
|||
* 查询部门列表(排除节点) |
|||
*/ |
|||
//@PreAuthorize("@ss.hasPermi('system:dept:list')")
|
|||
@GetMapping("/list/exclude/{deptId}") |
|||
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
|||
{ |
|||
List<SysDept> depts = iotSysDeptService.selectDeptList(new SysDept()); |
|||
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
|||
return success(depts); |
|||
} |
|||
|
|||
/** |
|||
* 根据部门编号获取详细信息 |
|||
*/ |
|||
//@PreAuthorize("@ss.hasPermi('system:dept:query')")
|
|||
@GetMapping(value = "/{deptId}") |
|||
public AjaxResult getInfo(@PathVariable Long deptId) |
|||
{ |
|||
iotSysDeptService.checkDeptDataScope(deptId); |
|||
return success(iotSysDeptService.selectDeptById(deptId)); |
|||
} |
|||
/** |
|||
* 获取部门树列表 |
|||
*/ |
|||
//@PreAuthorize("@ss.hasPermi('system:user:list')")
|
|||
@GetMapping("/deptTree") |
|||
public AjaxResult deptTree(SysDept dept) |
|||
{ |
|||
return success(iotSysDeptService.selectDeptTreeList(dept)); |
|||
} |
|||
} |
@ -0,0 +1,131 @@ |
|||
package com.lzbi.common.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.lzbi.bi.domain.DcBusiDataScreenDto; |
|||
import com.lzbi.common.core.domain.entity.SysDept; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 部门管理 数据层 |
|||
* |
|||
* @author ruoyi |
|||
*/@InterceptorIgnore(tenantLine = "true") |
|||
public interface IOTSysDeptMapper extends BaseMapper<SysDept> |
|||
{ |
|||
/** |
|||
* 查询部门管理数据 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 部门信息集合 |
|||
*/ |
|||
public List<SysDept> selectDeptList(SysDept dept); |
|||
|
|||
/** |
|||
* 根据角色ID查询部门树信息 |
|||
* |
|||
* @param roleId 角色ID |
|||
* @param deptCheckStrictly 部门树选择项是否关联显示 |
|||
* @return 选中部门列表 |
|||
*/ |
|||
public List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly); |
|||
|
|||
/** |
|||
* 根据部门ID查询信息 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 部门信息 |
|||
*/ |
|||
public SysDept selectDeptById(Long deptId); |
|||
|
|||
/** |
|||
* 根据ID查询所有子部门 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 部门列表 |
|||
*/ |
|||
public List<SysDept> selectChildrenDeptById(Long deptId); |
|||
|
|||
/** |
|||
* 根据ID查询所有子部门(正常状态) |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 子部门数 |
|||
*/ |
|||
public int selectNormalChildrenDeptById(Long deptId); |
|||
|
|||
/** |
|||
* 是否存在子节点 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 结果 |
|||
*/ |
|||
public int hasChildByDeptId(Long deptId); |
|||
|
|||
/** |
|||
* 查询部门是否存在用户 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 结果 |
|||
*/ |
|||
public int checkDeptExistUser(Long deptId); |
|||
|
|||
/** |
|||
* 校验部门名称是否唯一 |
|||
* |
|||
* @param deptName 部门名称 |
|||
* @param parentId 父部门ID |
|||
* @return 结果 |
|||
*/ |
|||
public SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); |
|||
|
|||
/** |
|||
* 新增部门信息 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertDept(SysDept dept); |
|||
|
|||
/** |
|||
* 修改部门信息 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateDept(SysDept dept); |
|||
|
|||
/** |
|||
* 修改所在部门正常状态 |
|||
* |
|||
* @param deptIds 部门ID组 |
|||
*/ |
|||
public void updateDeptStatusNormal(Long[] deptIds); |
|||
|
|||
/** |
|||
* 修改子元素关系 |
|||
* |
|||
* @param depts 子元素 |
|||
* @return 结果 |
|||
*/ |
|||
public int updateDeptChildren(@Param("depts") List<SysDept> depts); |
|||
|
|||
/** |
|||
* 删除部门管理信息 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 结果 |
|||
*/ |
|||
public int deleteDeptById(Long deptId); |
|||
//add by zhousq 2023-12 根据部门类别筛选部门
|
|||
public List<SysDept> selectOrg(Long parentId); |
|||
public List<SysDept> selectCompany(Long parentId); |
|||
public Map<Long,String> selectDeptMap(); |
|||
|
|||
List<SysDept> selectDeptListByRoleIds(List<Long> ids); |
|||
} |
@ -0,0 +1,239 @@ |
|||
package com.lzbi.common.service; |
|||
|
|||
import com.baomidou.dynamic.datasource.annotation.DS; |
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.lzbi.common.annotation.DataScope; |
|||
import com.lzbi.common.constant.UserConstants; |
|||
import com.lzbi.common.core.domain.TreeSelect; |
|||
import com.lzbi.common.core.domain.entity.SysDept; |
|||
import com.lzbi.common.core.domain.entity.SysRole; |
|||
import com.lzbi.common.core.domain.entity.SysUser; |
|||
import com.lzbi.common.core.text.Convert; |
|||
import com.lzbi.common.exception.ServiceException; |
|||
import com.lzbi.common.mapper.IOTSysDeptMapper; |
|||
import com.lzbi.common.utils.SecurityUtils; |
|||
import com.lzbi.common.utils.StringUtils; |
|||
import com.lzbi.common.utils.spring.SpringUtils; |
|||
|
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 部门管理 服务实现 |
|||
* |
|||
* @author ruoyi |
|||
*/ |
|||
@DS("workDB") |
|||
@Service |
|||
public class IotSysDeptService extends ServiceImpl<IOTSysDeptMapper, SysDept> implements IService<SysDept> { |
|||
|
|||
|
|||
/** |
|||
* 查询部门管理数据 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 部门信息集合 |
|||
*/ |
|||
|
|||
@DataScope(deptAlias = "d") |
|||
public List<SysDept> selectDeptList(SysDept dept) { |
|||
return baseMapper.selectDeptList(dept); |
|||
} |
|||
|
|||
public List<SysDept> selecttList(SysDept dept) { |
|||
return baseMapper.selectDeptList(dept); |
|||
} |
|||
|
|||
/** |
|||
* 查询部门树结构信息 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 部门树信息集合 |
|||
*/ |
|||
|
|||
public List<TreeSelect> selectDeptTreeList(SysDept dept) { |
|||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); |
|||
return buildDeptTreeSelect(depts); |
|||
} |
|||
|
|||
|
|||
public List<SysDept> selectDeptListByRoleIds(List<Long> ids) { |
|||
return baseMapper.selectDeptListByRoleIds(ids); |
|||
} |
|||
|
|||
/** |
|||
* 构建前端所需要树结构 |
|||
* |
|||
* @param depts 部门列表 |
|||
* @return 树结构列表 |
|||
*/ |
|||
|
|||
public List<SysDept> buildDeptTree(List<SysDept> depts) { |
|||
List<SysDept> returnList = new ArrayList<SysDept>(); |
|||
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); |
|||
for (SysDept dept : depts) { |
|||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|||
if (!tempList.contains(dept.getParentId())) { |
|||
recursionFn(depts, dept); |
|||
returnList.add(dept); |
|||
} |
|||
} |
|||
if (returnList.isEmpty()) { |
|||
returnList = depts; |
|||
} |
|||
return returnList; |
|||
} |
|||
|
|||
/** |
|||
* 构建前端所需要下拉树结构 |
|||
* |
|||
* @param depts 部门列表 |
|||
* @return 下拉树结构列表 |
|||
*/ |
|||
|
|||
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) { |
|||
List<SysDept> deptTrees = buildDeptTree(depts); |
|||
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); |
|||
} |
|||
|
|||
|
|||
|
|||
/** |
|||
* 根据部门ID查询信息 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 部门信息 |
|||
*/ |
|||
|
|||
public SysDept selectDeptById(Long deptId) { |
|||
return baseMapper.selectDeptById(deptId); |
|||
} |
|||
|
|||
/** |
|||
* 根据ID查询所有子部门(正常状态) |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 子部门数 |
|||
*/ |
|||
|
|||
public int selectNormalChildrenDeptById(Long deptId) { |
|||
return baseMapper.selectNormalChildrenDeptById(deptId); |
|||
} |
|||
|
|||
/** |
|||
* 是否存在子节点 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 结果 |
|||
*/ |
|||
|
|||
public boolean hasChildByDeptId(Long deptId) { |
|||
int result = baseMapper.hasChildByDeptId(deptId); |
|||
return result > 0; |
|||
} |
|||
|
|||
/** |
|||
* 查询部门是否存在用户 |
|||
* |
|||
* @param deptId 部门ID |
|||
* @return 结果 true 存在 false 不存在 |
|||
*/ |
|||
|
|||
public boolean checkDeptExistUser(Long deptId) { |
|||
int result = baseMapper.checkDeptExistUser(deptId); |
|||
return result > 0; |
|||
} |
|||
|
|||
/** |
|||
* 校验部门名称是否唯一 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 结果 |
|||
*/ |
|||
public boolean checkDeptNameUnique(SysDept dept) { |
|||
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); |
|||
SysDept info = baseMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); |
|||
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { |
|||
return UserConstants.NOT_UNIQUE; |
|||
} |
|||
return UserConstants.UNIQUE; |
|||
} |
|||
|
|||
/** |
|||
* 校验部门是否有数据权限 |
|||
* |
|||
* @param deptId 部门id |
|||
*/ |
|||
public void checkDeptDataScope(Long deptId) { |
|||
if (!SysUser.isAdmin(SecurityUtils.getUserId())) { |
|||
SysDept dept = new SysDept(); |
|||
dept.setDeptId(deptId); |
|||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); |
|||
if (StringUtils.isEmpty(depts)) { |
|||
throw new ServiceException("没有权限访问部门数据!"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 新增保存部门信息 |
|||
* |
|||
* @param dept 部门信息 |
|||
* @return 结果 |
|||
*/ |
|||
public int insertDept(SysDept dept) { |
|||
SysDept info = baseMapper.selectDeptById(dept.getParentId()); |
|||
// 如果父节点不为正常状态,则不允许新增子节点
|
|||
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { |
|||
throw new ServiceException("部门停用,不允许新增"); |
|||
} |
|||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); |
|||
return baseMapper.insertDept(dept); |
|||
} |
|||
|
|||
|
|||
//获取所有部门的hash映射,便于查询(key :depid,value:deptName)
|
|||
public Map selectDeptMap(){ |
|||
return baseMapper.selectDeptMap(); |
|||
} |
|||
/** |
|||
* 递归列表 |
|||
*/ |
|||
private void recursionFn(List<SysDept> list, SysDept t) { |
|||
// 得到子节点列表
|
|||
List<SysDept> childList = getChildList(list, t); |
|||
t.setChildren(childList); |
|||
for (SysDept tChild : childList) { |
|||
if (hasChild(list, tChild)) { |
|||
recursionFn(list, tChild); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 得到子节点列表 |
|||
*/ |
|||
private List<SysDept> getChildList(List<SysDept> list, SysDept t) { |
|||
List<SysDept> tlist = new ArrayList<SysDept>(); |
|||
Iterator<SysDept> it = list.iterator(); |
|||
while (it.hasNext()) { |
|||
SysDept n = (SysDept) it.next(); |
|||
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { |
|||
tlist.add(n); |
|||
} |
|||
} |
|||
return tlist; |
|||
} |
|||
|
|||
/** |
|||
* 判断是否有子节点 |
|||
*/ |
|||
private boolean hasChild(List<SysDept> list, SysDept t) { |
|||
return getChildList(list, t).size() > 0; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,212 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper |
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.lzbi.common.mapper.IOTSysDeptMapper"> |
|||
|
|||
<resultMap type="SysDept" id="SysDeptResult"> |
|||
<id property="deptId" column="dept_id" /> |
|||
<result property="parentId" column="parent_id" /> |
|||
<result property="ancestors" column="ancestors" /> |
|||
<result property="deptName" column="dept_name" /> |
|||
<result property="orderNum" column="order_num" /> |
|||
<result property="leader" column="leader" /> |
|||
<result property="phone" column="phone" /> |
|||
<result property="email" column="email" /> |
|||
<result property="status" column="status" /> |
|||
<result property="delFlag" column="del_flag" /> |
|||
<result property="parentName" column="parent_name" /> |
|||
<result property="createBy" column="create_by" /> |
|||
<result property="createTime" column="create_time" /> |
|||
<result property="updateBy" column="update_by" /> |
|||
<result property="updateTime" column="update_time" /> |
|||
<result property="shortName" column="short_name"/> |
|||
<result property="allName" column="all_name"/> |
|||
<result property="orgType" column="org_type"/> |
|||
|
|||
</resultMap> |
|||
|
|||
<sql id="selectDeptVo"> |
|||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.short_name,d.all_name,d.org_type |
|||
from sys_dept d |
|||
</sql> |
|||
|
|||
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> |
|||
<include refid="selectDeptVo"/> |
|||
where d.del_flag = '0' |
|||
<if test="deptId != null and deptId != 0"> |
|||
AND dept_id = #{deptId} |
|||
</if> |
|||
<if test="parentId != null and parentId != 0"> |
|||
AND parent_id = #{parentId} |
|||
</if> |
|||
<if test="deptName != null and deptName != ''"> |
|||
AND dept_name like concat('%', #{deptName}, '%') |
|||
</if> |
|||
<if test="status != null and status != ''"> |
|||
AND status = #{status} |
|||
</if> |
|||
<if test="orgType != null and orgType != ''"> |
|||
AND org_type = #{orgType} |
|||
</if> |
|||
<!-- 数据范围过滤 --> |
|||
${params.dataScope} |
|||
order by d.parent_id, d.order_num |
|||
</select> |
|||
|
|||
<select id="selectDeptListByRoleId" resultType="Long"> |
|||
select d.dept_id |
|||
from sys_dept d |
|||
left join sys_role_dept rd on d.dept_id = rd.dept_id |
|||
where rd.role_id = #{roleId} |
|||
<if test="deptCheckStrictly"> |
|||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId}) |
|||
</if> |
|||
order by d.parent_id, d.order_num |
|||
</select> |
|||
|
|||
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> |
|||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.short_name,d.all_name,d.org_type, |
|||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
|||
from sys_dept d |
|||
where d.dept_id = #{deptId} |
|||
</select> |
|||
<select id="selectCompany" parameterType="long" resultMap="SysDeptResult"> |
|||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.short_name,d.all_name,d.org_type, |
|||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
|||
from sys_dept d |
|||
<where> |
|||
org_type in ('1001','1002') |
|||
<if test="parentId != null "> and d.parent_id = #{parentId}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectOrg" parameterType="long" resultMap="SysDeptResult"> |
|||
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,d.short_name,d.all_name,d.org_type, |
|||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
|||
from sys_dept d |
|||
<where> |
|||
org_type not in ('1001','1002') |
|||
<if test="parentId != null "> and d.parent_id = #{parentId}</if> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectDeptMap" resultType="map"> |
|||
select d.dept_id,d.dept_name from sys_dept d |
|||
</select> |
|||
<select id="checkDeptExistUser" parameterType="Long" resultType="int"> |
|||
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' |
|||
</select> |
|||
|
|||
<select id="hasChildByDeptId" parameterType="Long" resultType="int"> |
|||
select count(1) from sys_dept |
|||
where del_flag = '0' and parent_id = #{deptId} limit 1 |
|||
</select> |
|||
|
|||
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> |
|||
select * from sys_dept where find_in_set(#{deptId}, ancestors) |
|||
</select> |
|||
|
|||
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> |
|||
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) |
|||
</select> |
|||
|
|||
<select id="checkDeptNameUnique" resultMap="SysDeptResult"> |
|||
<include refid="selectDeptVo"/> |
|||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 |
|||
</select> |
|||
|
|||
<select id="selectDeptListByRoleIds" parameterType="List" resultMap="SysDeptResult"> |
|||
select DISTINCT d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.short_name,d.all_name,d.org_type from sys_dept d left join sys_role_dept rd on d.dept_id = rd.dept_id |
|||
where d.del_flag = '0' |
|||
and rd.role_id in |
|||
<foreach collection="list" item="ids" open="(" separator="," close=")"> |
|||
#{ids} |
|||
</foreach> |
|||
order by d.parent_id, d.order_num |
|||
</select> |
|||
|
|||
<insert id="insertDept" parameterType="SysDept"> |
|||
insert into sys_dept( |
|||
<if test="deptId != null and deptId != 0">dept_id,</if> |
|||
<if test="parentId != null and parentId != 0">parent_id,</if> |
|||
<if test="deptName != null and deptName != ''">dept_name,</if> |
|||
<if test="ancestors != null and ancestors != ''">ancestors,</if> |
|||
<if test="orderNum != null">order_num,</if> |
|||
<if test="leader != null and leader != ''">leader,</if> |
|||
<if test="phone != null and phone != ''">phone,</if> |
|||
<if test="email != null and email != ''">email,</if> |
|||
<if test="status != null">status,</if> |
|||
<if test="createBy != null and createBy != ''">create_by,</if> |
|||
<if test="shortName != null and shortName != ''">short_name,</if> |
|||
<if test="allName != null and allName != ''">all_name,</if> |
|||
<if test="orgType != null and orgType != ''">org_type,</if> |
|||
create_time |
|||
)values( |
|||
<if test="deptId != null and deptId != 0">#{deptId},</if> |
|||
<if test="parentId != null and parentId != 0">#{parentId},</if> |
|||
<if test="deptName != null and deptName != ''">#{deptName},</if> |
|||
<if test="ancestors != null and ancestors != ''">#{ancestors},</if> |
|||
<if test="orderNum != null">#{orderNum},</if> |
|||
<if test="leader != null and leader != ''">#{leader},</if> |
|||
<if test="phone != null and phone != ''">#{phone},</if> |
|||
<if test="email != null and email != ''">#{email},</if> |
|||
<if test="status != null">#{status},</if> |
|||
<if test="createBy != null and createBy != ''">#{createBy},</if> |
|||
<if test="shortName != null and shortName != ''">#{shortName},</if> |
|||
<if test="allName != null and allName != ''">#{allName},</if> |
|||
<if test="orgType != null and orgType != ''">#{orgType},</if> |
|||
sysdate() |
|||
) |
|||
</insert> |
|||
|
|||
<update id="updateDept" parameterType="SysDept"> |
|||
update sys_dept |
|||
<set> |
|||
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if> |
|||
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if> |
|||
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> |
|||
<if test="orderNum != null">order_num = #{orderNum},</if> |
|||
<if test="leader != null">leader = #{leader},</if> |
|||
<if test="phone != null">phone = #{phone},</if> |
|||
<if test="email != null">email = #{email},</if> |
|||
<if test="status != null and status != ''">status = #{status},</if> |
|||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
|||
<if test="shortName != null and shortName != ''">short_name = #{shortName},</if> |
|||
<if test="allName != null and allName != ''">all_name = #{allName},</if> |
|||
<if test="orgType != null and orgType != ''">org_type = #{orgType},</if> |
|||
update_time = sysdate() |
|||
</set> |
|||
where dept_id = #{deptId} |
|||
</update> |
|||
|
|||
<update id="updateDeptChildren" parameterType="java.util.List"> |
|||
update sys_dept set ancestors = |
|||
<foreach collection="depts" item="item" index="index" |
|||
separator=" " open="case dept_id" close="end"> |
|||
when #{item.deptId} then #{item.ancestors} |
|||
</foreach>, |
|||
all_name = |
|||
<foreach collection="depts" item="item" index="index" |
|||
separator=" " open="case dept_id" close="end"> |
|||
when #{item.deptId} then #{item.allName} |
|||
</foreach> |
|||
where dept_id in |
|||
<foreach collection="depts" item="item" index="index" |
|||
separator="," open="(" close=")"> |
|||
#{item.deptId} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<update id="updateDeptStatusNormal" parameterType="Long"> |
|||
update sys_dept set status = '0' where dept_id in |
|||
<foreach collection="array" item="deptId" open="(" separator="," close=")"> |
|||
#{deptId} |
|||
</foreach> |
|||
</update> |
|||
|
|||
<delete id="deleteDeptById" parameterType="Long"> |
|||
update sys_dept set del_flag = '2' where dept_id = #{deptId} |
|||
</delete> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue