mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update mp化
This commit is contained in:
		@@ -64,6 +64,7 @@ public class SysDept
 | 
			
		||||
    private String delFlag;
 | 
			
		||||
 | 
			
		||||
    /** 父部门名称 */
 | 
			
		||||
    @TableField(exist = false)
 | 
			
		||||
    private String parentName;
 | 
			
		||||
 | 
			
		||||
    /** 创建者 */
 | 
			
		||||
 
 | 
			
		||||
@@ -12,13 +12,6 @@ import java.util.List;
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询部门管理数据
 | 
			
		||||
     *
 | 
			
		||||
     * @param dept 部门信息
 | 
			
		||||
     * @return 部门信息集合
 | 
			
		||||
     */
 | 
			
		||||
    public List<SysDept> selectDeptList(SysDept dept);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据角色ID查询部门树信息
 | 
			
		||||
@@ -29,91 +22,4 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
 | 
			
		||||
     */
 | 
			
		||||
    public List<Integer> 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 dept 部门
 | 
			
		||||
     */
 | 
			
		||||
    public void updateDeptStatus(SysDept dept);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改子元素关系
 | 
			
		||||
     *
 | 
			
		||||
     * @param depts 子元素
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int updateDeptChildren(@Param("depts") List<SysDept> depts);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除部门管理信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param deptId 部门ID
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDeptById(Long deptId);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,9 +2,6 @@ package com.ruoyi.system.mapper;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysDictData;
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 字典表 数据层
 | 
			
		||||
@@ -12,85 +9,5 @@ import java.util.List;
 | 
			
		||||
 * @author ruoyi
 | 
			
		||||
 */
 | 
			
		||||
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据条件分页查询字典数据
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictData 字典数据信息
 | 
			
		||||
     * @return 字典数据集合信息
 | 
			
		||||
     */
 | 
			
		||||
    public List<SysDictData> selectDictDataList(SysDictData dictData);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据字典类型查询字典数据
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType 字典类型
 | 
			
		||||
     * @return 字典数据集合信息
 | 
			
		||||
     */
 | 
			
		||||
    public List<SysDictData> selectDictDataByType(String dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据字典类型和字典键值查询字典数据信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType  字典类型
 | 
			
		||||
     * @param dictValue 字典键值
 | 
			
		||||
     * @return 字典标签
 | 
			
		||||
     */
 | 
			
		||||
    public String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据字典数据ID查询信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictCode 字典数据ID
 | 
			
		||||
     * @return 字典数据
 | 
			
		||||
     */
 | 
			
		||||
    public SysDictData selectDictDataById(Long dictCode);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询字典数据
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType 字典类型
 | 
			
		||||
     * @return 字典数据
 | 
			
		||||
     */
 | 
			
		||||
    public int countDictDataByType(String dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过字典ID删除字典数据信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictCode 字典数据ID
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDictDataById(Long dictCode);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除字典数据信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictCodes 需要删除的字典数据ID
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDictDataByIds(Long[] dictCodes);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增字典数据信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictData 字典数据信息
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int insertDictData(SysDictData dictData);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改字典数据信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictData 字典数据信息
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int updateDictData(SysDictData dictData);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 同步修改字典类型
 | 
			
		||||
     *
 | 
			
		||||
     * @param oldDictType 旧字典类型
 | 
			
		||||
     * @param newDictType 新旧字典类型
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,13 +13,6 @@ import java.util.List;
 | 
			
		||||
 */
 | 
			
		||||
@Mapper
 | 
			
		||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据条件分页查询字典类型
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType 字典类型信息
 | 
			
		||||
     * @return 字典类型集合信息
 | 
			
		||||
     */
 | 
			
		||||
    public List<SysDictType> selectDictTypeList(SysDictType dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据所有字典类型
 | 
			
		||||
@@ -44,38 +37,6 @@ public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
 | 
			
		||||
     */
 | 
			
		||||
    public SysDictType selectDictTypeByType(String dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过字典ID删除字典信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictId 字典ID
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDictTypeById(Long dictId);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除字典类型信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictIds 需要删除的字典ID
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int deleteDictTypeByIds(Long[] dictIds);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增字典类型信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType 字典类型信息
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int insertDictType(SysDictType dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改字典类型信息
 | 
			
		||||
     *
 | 
			
		||||
     * @param dictType 字典类型信息
 | 
			
		||||
     * @return 结果
 | 
			
		||||
     */
 | 
			
		||||
    public int updateDictType(SysDictType dictType);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 校验字典类型称是否唯一
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -91,8 +91,12 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
 | 
			
		||||
        lqw.eq(StrUtil.isNotBlank(config.getConfigType()), SysConfig::getConfigType, config.getConfigType());
 | 
			
		||||
        lqw.like(StrUtil.isNotBlank(config.getConfigKey()), SysConfig::getConfigKey, config.getConfigKey());
 | 
			
		||||
        Map<String, Object> params = config.getParams();
 | 
			
		||||
        lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
 | 
			
		||||
                SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
 | 
			
		||||
        lqw.apply(params.get("beginTime") != null,
 | 
			
		||||
                "date_format(create_time,'%y%m%d') >= date_format(#{0},'%y%m%d')",
 | 
			
		||||
                params.get("beginTime"));
 | 
			
		||||
        lqw.apply(params.get("endTime") != null,
 | 
			
		||||
                "date_format(create_time,'%y%m%d') >= date_format(#{0},'%y%m%d')",
 | 
			
		||||
                params.get("endTime"));
 | 
			
		||||
        return baseMapper.selectList(lqw);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,20 +1,26 @@
 | 
			
		||||
package com.ruoyi.system.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.lang.Validator;
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import com.ruoyi.common.annotation.DataScope;
 | 
			
		||||
import com.ruoyi.common.constant.UserConstants;
 | 
			
		||||
import com.ruoyi.common.core.domain.TreeSelect;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysDept;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysRole;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysUser;
 | 
			
		||||
import com.ruoyi.common.exception.CustomException;
 | 
			
		||||
import com.ruoyi.system.mapper.SysDeptMapper;
 | 
			
		||||
import com.ruoyi.system.mapper.SysRoleMapper;
 | 
			
		||||
import com.ruoyi.system.mapper.SysUserMapper;
 | 
			
		||||
import com.ruoyi.system.service.ISysDeptService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
@@ -32,6 +38,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private SysRoleMapper roleMapper;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private SysUserMapper userMapper;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 查询部门管理数据
 | 
			
		||||
     *
 | 
			
		||||
@@ -41,7 +50,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
    @Override
 | 
			
		||||
    @DataScope(deptAlias = "d")
 | 
			
		||||
    public List<SysDept> selectDeptList(SysDept dept) {
 | 
			
		||||
        return deptMapper.selectDeptList(dept);
 | 
			
		||||
        Object dataScope = dept.getParams().get("dataScope");
 | 
			
		||||
        return list(new LambdaQueryWrapper<SysDept>()
 | 
			
		||||
                .eq(dept.getParentId() != null && dept.getParentId() != 0,
 | 
			
		||||
                        SysDept::getParentId, dept.getParentId())
 | 
			
		||||
                .like(StrUtil.isNotBlank(dept.getDeptName()), SysDept::getDeptName, dept.getDeptName())
 | 
			
		||||
                .eq(StrUtil.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
 | 
			
		||||
                .apply(dataScope != null, dataScope != null ? dataScope.toString() : null)
 | 
			
		||||
                .orderByAsc(SysDept::getParentId)
 | 
			
		||||
                .orderByAsc(SysDept::getOrderNum));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -103,7 +120,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public SysDept selectDeptById(Long deptId) {
 | 
			
		||||
        return deptMapper.selectDeptById(deptId);
 | 
			
		||||
        return getById(deptId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -114,7 +131,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int selectNormalChildrenDeptById(Long deptId) {
 | 
			
		||||
        return deptMapper.selectNormalChildrenDeptById(deptId);
 | 
			
		||||
        return count(new LambdaQueryWrapper<SysDept>()
 | 
			
		||||
                .eq(SysDept::getStatus, 0)
 | 
			
		||||
                .apply("find_in_set({0}, ancestors)", deptId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -125,7 +144,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean hasChildByDeptId(Long deptId) {
 | 
			
		||||
        int result = deptMapper.hasChildByDeptId(deptId);
 | 
			
		||||
        int result = count(new LambdaQueryWrapper<SysDept>()
 | 
			
		||||
                .eq(SysDept::getParentId, deptId)
 | 
			
		||||
                .last("limit 1"));
 | 
			
		||||
        return result > 0 ? true : false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -137,7 +158,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean checkDeptExistUser(Long deptId) {
 | 
			
		||||
        int result = deptMapper.checkDeptExistUser(deptId);
 | 
			
		||||
        int result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
 | 
			
		||||
                .eq(SysUser::getDeptId, deptId));
 | 
			
		||||
        return result > 0 ? true : false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -150,7 +172,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
    @Override
 | 
			
		||||
    public String checkDeptNameUnique(SysDept dept) {
 | 
			
		||||
        Long deptId = Validator.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
 | 
			
		||||
        SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
 | 
			
		||||
        SysDept info = getOne(new LambdaQueryWrapper<SysDept>()
 | 
			
		||||
                .eq(SysDept::getDeptName, dept.getDeptName())
 | 
			
		||||
                .eq(SysDept::getParentId, dept.getParentId())
 | 
			
		||||
                .last("limit 1"));
 | 
			
		||||
        if (Validator.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
 | 
			
		||||
            return UserConstants.NOT_UNIQUE;
 | 
			
		||||
        }
 | 
			
		||||
@@ -165,13 +190,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int insertDept(SysDept dept) {
 | 
			
		||||
        SysDept info = deptMapper.selectDeptById(dept.getParentId());
 | 
			
		||||
        SysDept info = getById(dept.getParentId());
 | 
			
		||||
        // 如果父节点不为正常状态,则不允许新增子节点
 | 
			
		||||
        if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
 | 
			
		||||
            throw new CustomException("部门停用,不允许新增");
 | 
			
		||||
        }
 | 
			
		||||
        dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
 | 
			
		||||
        return deptMapper.insertDept(dept);
 | 
			
		||||
        return baseMapper.insert(dept);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -182,15 +207,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateDept(SysDept dept) {
 | 
			
		||||
        SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
 | 
			
		||||
        SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
 | 
			
		||||
        SysDept newParentDept = getById(dept.getParentId());
 | 
			
		||||
        SysDept oldDept = getById(dept.getDeptId());
 | 
			
		||||
        if (Validator.isNotNull(newParentDept) && Validator.isNotNull(oldDept)) {
 | 
			
		||||
            String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
 | 
			
		||||
            String oldAncestors = oldDept.getAncestors();
 | 
			
		||||
            dept.setAncestors(newAncestors);
 | 
			
		||||
            updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
 | 
			
		||||
        }
 | 
			
		||||
        int result = deptMapper.updateDept(dept);
 | 
			
		||||
        int result = baseMapper.updateById(dept);
 | 
			
		||||
        if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) {
 | 
			
		||||
            // 如果该部门是启用状态,则启用该部门的所有上级部门
 | 
			
		||||
            updateParentDeptStatus(dept);
 | 
			
		||||
@@ -205,9 +230,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    private void updateParentDeptStatus(SysDept dept) {
 | 
			
		||||
        String updateBy = dept.getUpdateBy();
 | 
			
		||||
        dept = deptMapper.selectDeptById(dept.getDeptId());
 | 
			
		||||
        dept = getById(dept.getDeptId());
 | 
			
		||||
        dept.setUpdateBy(updateBy);
 | 
			
		||||
        deptMapper.updateDeptStatus(dept);
 | 
			
		||||
        update(null,new LambdaUpdateWrapper<SysDept>()
 | 
			
		||||
                .set(StrUtil.isNotBlank(dept.getStatus()),
 | 
			
		||||
                        SysDept::getStatus,dept.getStatus())
 | 
			
		||||
                .set(StrUtil.isNotBlank(dept.getUpdateBy()),
 | 
			
		||||
                        SysDept::getUpdateBy,dept.getUpdateBy())
 | 
			
		||||
                .in(SysDept::getDeptId, Arrays.asList(dept.getAncestors().split(","))));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -218,12 +248,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     * @param oldAncestors 旧的父ID集合
 | 
			
		||||
     */
 | 
			
		||||
    public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
 | 
			
		||||
        List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
 | 
			
		||||
        List<SysDept> children = list(new LambdaQueryWrapper<SysDept>()
 | 
			
		||||
                .apply("find_in_set({0},ancestors)",deptId));
 | 
			
		||||
        for (SysDept child : children) {
 | 
			
		||||
            child.setAncestors(child.getAncestors().replace(oldAncestors, newAncestors));
 | 
			
		||||
        }
 | 
			
		||||
        if (children.size() > 0) {
 | 
			
		||||
            deptMapper.updateDeptChildren(children);
 | 
			
		||||
            updateBatchById(children);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -235,7 +266,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int deleteDeptById(Long deptId) {
 | 
			
		||||
        return deptMapper.deleteDeptById(deptId);
 | 
			
		||||
        return baseMapper.deleteById(deptId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
package com.ruoyi.system.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysDictData;
 | 
			
		||||
import com.ruoyi.common.utils.DictUtils;
 | 
			
		||||
import com.ruoyi.system.mapper.SysDictDataMapper;
 | 
			
		||||
import com.ruoyi.system.service.ISysDictDataService;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -17,8 +19,6 @@ import java.util.List;
 | 
			
		||||
 */
 | 
			
		||||
@Service
 | 
			
		||||
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private SysDictDataMapper dictDataMapper;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 根据条件分页查询字典数据
 | 
			
		||||
@@ -28,7 +28,10 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<SysDictData> selectDictDataList(SysDictData dictData) {
 | 
			
		||||
        return dictDataMapper.selectDictDataList(dictData);
 | 
			
		||||
        return list(new LambdaQueryWrapper<SysDictData>().eq(StrUtil.isNotBlank(dictData.getDictType()), SysDictData::getDictType, dictData.getDictType())
 | 
			
		||||
                .like(StrUtil.isNotBlank(dictData.getDictLabel()), SysDictData::getDictLabel, dictData.getDictLabel())
 | 
			
		||||
                .eq(StrUtil.isNotBlank(dictData.getStatus()), SysDictData::getStatus, dictData.getStatus())
 | 
			
		||||
                .orderByAsc(SysDictData::getDictSort));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -40,7 +43,11 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String selectDictLabel(String dictType, String dictValue) {
 | 
			
		||||
        return dictDataMapper.selectDictLabel(dictType, dictValue);
 | 
			
		||||
        return getOne(new LambdaQueryWrapper<SysDictData>()
 | 
			
		||||
                .select(SysDictData::getDictLabel)
 | 
			
		||||
                .eq(SysDictData::getDictType, dictType)
 | 
			
		||||
                .eq(SysDictData::getDictValue, dictValue))
 | 
			
		||||
                .getDictLabel();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -51,7 +58,7 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public SysDictData selectDictDataById(Long dictCode) {
 | 
			
		||||
        return dictDataMapper.selectDictDataById(dictCode);
 | 
			
		||||
        return getById(dictCode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -62,7 +69,7 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int deleteDictDataByIds(Long[] dictCodes) {
 | 
			
		||||
        int row = dictDataMapper.deleteDictDataByIds(dictCodes);
 | 
			
		||||
        int row = baseMapper.deleteBatchIds(Arrays.asList(dictCodes));
 | 
			
		||||
        if (row > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
@@ -77,7 +84,7 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int insertDictData(SysDictData dictData) {
 | 
			
		||||
        int row = dictDataMapper.insertDictData(dictData);
 | 
			
		||||
        int row = baseMapper.insert(dictData);
 | 
			
		||||
        if (row > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
@@ -92,7 +99,7 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateDictData(SysDictData dictData) {
 | 
			
		||||
        int row = dictDataMapper.updateDictData(dictData);
 | 
			
		||||
        int row = baseMapper.updateById(dictData);
 | 
			
		||||
        if (row > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@ package com.ruoyi.system.service.impl;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.collection.CollUtil;
 | 
			
		||||
import cn.hutool.core.lang.Validator;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 | 
			
		||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
			
		||||
import com.ruoyi.common.constant.UserConstants;
 | 
			
		||||
import com.ruoyi.common.core.domain.entity.SysDictData;
 | 
			
		||||
@@ -16,7 +18,9 @@ import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.PostConstruct;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 字典 业务层处理
 | 
			
		||||
@@ -36,9 +40,13 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @PostConstruct
 | 
			
		||||
    public void init() {
 | 
			
		||||
        List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
 | 
			
		||||
        List<SysDictType> dictTypeList = list();
 | 
			
		||||
        for (SysDictType dictType : dictTypeList) {
 | 
			
		||||
            List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
 | 
			
		||||
            List<SysDictData> dictDatas = dictDataMapper.selectList(
 | 
			
		||||
                    new LambdaQueryWrapper<SysDictData>()
 | 
			
		||||
                            .eq(SysDictData::getStatus, 0)
 | 
			
		||||
                            .eq(SysDictData::getDictType, dictType)
 | 
			
		||||
                            .orderByAsc(SysDictData::getDictSort));
 | 
			
		||||
            DictUtils.setDictCache(dictType.getDictType(), dictDatas);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -51,7 +59,17 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<SysDictType> selectDictTypeList(SysDictType dictType) {
 | 
			
		||||
        return dictTypeMapper.selectDictTypeList(dictType);
 | 
			
		||||
        Map<String, Object> params = dictType.getParams();
 | 
			
		||||
        return list(new LambdaQueryWrapper<SysDictType>()
 | 
			
		||||
                .like(SysDictType::getDictName, dictType.getDictName())
 | 
			
		||||
                .eq(SysDictType::getStatus, dictType.getStatus())
 | 
			
		||||
                .like(SysDictType::getDictType, dictType.getDictType())
 | 
			
		||||
                .apply(params.get("beginTime") != null,
 | 
			
		||||
                        "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')",
 | 
			
		||||
                        params.get("beginTime"))
 | 
			
		||||
                .apply(params.get("endTime") != null,
 | 
			
		||||
                        "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')",
 | 
			
		||||
                        params.get("endTime")));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -61,7 +79,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<SysDictType> selectDictTypeAll() {
 | 
			
		||||
        return dictTypeMapper.selectDictTypeAll();
 | 
			
		||||
        return list();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -76,7 +94,10 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
        if (CollUtil.isNotEmpty(dictDatas)) {
 | 
			
		||||
            return dictDatas;
 | 
			
		||||
        }
 | 
			
		||||
        dictDatas = dictDataMapper.selectDictDataByType(dictType);
 | 
			
		||||
        dictDatas = dictDataMapper.selectList(new LambdaQueryWrapper<SysDictData>()
 | 
			
		||||
                .eq(SysDictData::getStatus, 0)
 | 
			
		||||
                .eq(SysDictData::getDictType, dictType)
 | 
			
		||||
                .orderByAsc(SysDictData::getDictSort));
 | 
			
		||||
        if (CollUtil.isNotEmpty(dictDatas)) {
 | 
			
		||||
            DictUtils.setDictCache(dictType, dictDatas);
 | 
			
		||||
            return dictDatas;
 | 
			
		||||
@@ -92,7 +113,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public SysDictType selectDictTypeById(Long dictId) {
 | 
			
		||||
        return dictTypeMapper.selectDictTypeById(dictId);
 | 
			
		||||
        return getById(dictId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -103,7 +124,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public SysDictType selectDictTypeByType(String dictType) {
 | 
			
		||||
        return dictTypeMapper.selectDictTypeByType(dictType);
 | 
			
		||||
        return getOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -116,11 +137,12 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
    public int deleteDictTypeByIds(Long[] dictIds) {
 | 
			
		||||
        for (Long dictId : dictIds) {
 | 
			
		||||
            SysDictType dictType = selectDictTypeById(dictId);
 | 
			
		||||
            if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0) {
 | 
			
		||||
            if (dictDataMapper.selectCount(new LambdaQueryWrapper<SysDictData>()
 | 
			
		||||
                    .eq(SysDictData::getDictType, dictType.getDictType())) > 0) {
 | 
			
		||||
                throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        int count = dictTypeMapper.deleteDictTypeByIds(dictIds);
 | 
			
		||||
        int count = baseMapper.deleteBatchIds(Arrays.asList(dictIds));
 | 
			
		||||
        if (count > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
@@ -143,7 +165,7 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public int insertDictType(SysDictType dictType) {
 | 
			
		||||
        int row = dictTypeMapper.insertDictType(dictType);
 | 
			
		||||
        int row = dictTypeMapper.insert(dictType);
 | 
			
		||||
        if (row > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
@@ -159,9 +181,11 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
    @Override
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public int updateDictType(SysDictType dictType) {
 | 
			
		||||
        SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
 | 
			
		||||
        dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
 | 
			
		||||
        int row = dictTypeMapper.updateDictType(dictType);
 | 
			
		||||
        SysDictType oldDict = getById(dictType.getDictId());
 | 
			
		||||
        dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
 | 
			
		||||
                .set(SysDictData::getDictType, dictType.getDictType())
 | 
			
		||||
                .eq(SysDictData::getDictType, oldDict.getDictType()));
 | 
			
		||||
        int row = dictTypeMapper.updateById(dictType);
 | 
			
		||||
        if (row > 0) {
 | 
			
		||||
            DictUtils.clearDictCache();
 | 
			
		||||
        }
 | 
			
		||||
@@ -177,7 +201,9 @@ public class SysDictTypeServiceImpl extends ServiceImpl<SysDictTypeMapper, SysDi
 | 
			
		||||
    @Override
 | 
			
		||||
    public String checkDictTypeUnique(SysDictType dict) {
 | 
			
		||||
        Long dictId = Validator.isNull(dict.getDictId()) ? -1L : dict.getDictId();
 | 
			
		||||
        SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
 | 
			
		||||
        SysDictType dictType = getOne(new LambdaQueryWrapper<SysDictType>()
 | 
			
		||||
                .eq(SysDictType::getDictType, dict.getDictType())
 | 
			
		||||
                .last("limit 1"));
 | 
			
		||||
        if (Validator.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue()) {
 | 
			
		||||
            return UserConstants.NOT_UNIQUE;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -22,39 +22,6 @@
 | 
			
		||||
        <result property="updateTime" column="update_time"/>
 | 
			
		||||
    </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
 | 
			
		||||
        from sys_dept d
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
 | 
			
		||||
        <include refid="selectDeptVo"/>
 | 
			
		||||
        where d.del_flag = '0'
 | 
			
		||||
        <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>
 | 
			
		||||
        <!-- 数据范围过滤 -->
 | 
			
		||||
        ${params.dataScope}
 | 
			
		||||
        order by d.parent_id, d.order_num
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDeptListByRoleId" resultType="Integer">
 | 
			
		||||
        select d.dept_id
 | 
			
		||||
        from sys_dept d
 | 
			
		||||
@@ -67,116 +34,4 @@
 | 
			
		||||
        order by d.parent_id, d.order_num
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
 | 
			
		||||
        <include refid="selectDeptVo"/>
 | 
			
		||||
        where dept_id = #{deptId}
 | 
			
		||||
    </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} limit 1
 | 
			
		||||
    </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 and orderNum != ''">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>
 | 
			
		||||
        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 and orderNum != ''">#{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>
 | 
			
		||||
        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 and orderNum != ''">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>
 | 
			
		||||
            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>
 | 
			
		||||
        where dept_id in
 | 
			
		||||
        <foreach collection="depts" item="item" index="index"
 | 
			
		||||
                 separator="," open="(" close=")">
 | 
			
		||||
            #{item.deptId}
 | 
			
		||||
        </foreach>
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <update id="updateDeptStatus" parameterType="SysDept">
 | 
			
		||||
        update sys_dept
 | 
			
		||||
        <set>
 | 
			
		||||
            <if test="status != null and status != ''">status = #{status},</if>
 | 
			
		||||
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 | 
			
		||||
            update_time = sysdate()
 | 
			
		||||
        </set>
 | 
			
		||||
        where dept_id in (${ancestors})
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDeptById" parameterType="Long">
 | 
			
		||||
        update sys_dept
 | 
			
		||||
        set del_flag = '2'
 | 
			
		||||
        where dept_id = #{deptId}
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
</mapper> 
 | 
			
		||||
@@ -20,124 +20,4 @@
 | 
			
		||||
        <result property="updateTime" column="update_time"/>
 | 
			
		||||
    </resultMap>
 | 
			
		||||
 | 
			
		||||
    <sql id="selectDictDataVo">
 | 
			
		||||
        select dict_code,
 | 
			
		||||
               dict_sort,
 | 
			
		||||
               dict_label,
 | 
			
		||||
               dict_value,
 | 
			
		||||
               dict_type,
 | 
			
		||||
               css_class,
 | 
			
		||||
               list_class,
 | 
			
		||||
               is_default,
 | 
			
		||||
               status,
 | 
			
		||||
               create_by,
 | 
			
		||||
               create_time,
 | 
			
		||||
               remark
 | 
			
		||||
        from sys_dict_data
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictDataList" parameterType="SysDictData" resultMap="SysDictDataResult">
 | 
			
		||||
        <include refid="selectDictDataVo"/>
 | 
			
		||||
        <where>
 | 
			
		||||
            <if test="dictType != null and dictType != ''">
 | 
			
		||||
                AND dict_type = #{dictType}
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="dictLabel != null and dictLabel != ''">
 | 
			
		||||
                AND dict_label like concat('%', #{dictLabel}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="status != null and status != ''">
 | 
			
		||||
                AND status = #{status}
 | 
			
		||||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
        order by dict_sort asc
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult">
 | 
			
		||||
        <include refid="selectDictDataVo"/>
 | 
			
		||||
        where status = '0' and dict_type = #{dictType} order by dict_sort asc
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictLabel" resultType="String">
 | 
			
		||||
        select dict_label
 | 
			
		||||
        from sys_dict_data
 | 
			
		||||
        where dict_type = #{dictType}
 | 
			
		||||
          and dict_value = #{dictValue}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
 | 
			
		||||
        <include refid="selectDictDataVo"/>
 | 
			
		||||
        where dict_code = #{dictCode}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="countDictDataByType" resultType="Integer">
 | 
			
		||||
        select count(1)
 | 
			
		||||
        from sys_dict_data
 | 
			
		||||
        where dict_type = #{dictType}
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDictDataById" parameterType="Long">
 | 
			
		||||
        delete
 | 
			
		||||
        from sys_dict_data
 | 
			
		||||
        where dict_code = #{dictCode}
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDictDataByIds" parameterType="Long">
 | 
			
		||||
        delete from sys_dict_data where dict_code in
 | 
			
		||||
        <foreach collection="array" item="dictCode" open="(" separator="," close=")">
 | 
			
		||||
            #{dictCode}
 | 
			
		||||
        </foreach>
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
    <update id="updateDictData" parameterType="SysDictData">
 | 
			
		||||
        update sys_dict_data
 | 
			
		||||
        <set>
 | 
			
		||||
            <if test="dictSort != null">dict_sort = #{dictSort},</if>
 | 
			
		||||
            <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
 | 
			
		||||
            <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
 | 
			
		||||
            <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
 | 
			
		||||
            <if test="cssClass != null">css_class = #{cssClass},</if>
 | 
			
		||||
            <if test="listClass != null">list_class = #{listClass},</if>
 | 
			
		||||
            <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
 | 
			
		||||
            <if test="status != null">status = #{status},</if>
 | 
			
		||||
            <if test="remark != null">remark = #{remark},</if>
 | 
			
		||||
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 | 
			
		||||
            update_time = sysdate()
 | 
			
		||||
        </set>
 | 
			
		||||
        where dict_code = #{dictCode}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <update id="updateDictDataType" parameterType="String">
 | 
			
		||||
        update sys_dict_data
 | 
			
		||||
        set dict_type = #{newDictType}
 | 
			
		||||
        where dict_type = #{oldDictType}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <insert id="insertDictData" parameterType="SysDictData">
 | 
			
		||||
        insert into sys_dict_data(
 | 
			
		||||
        <if test="dictSort != null">dict_sort,</if>
 | 
			
		||||
        <if test="dictLabel != null and dictLabel != ''">dict_label,</if>
 | 
			
		||||
        <if test="dictValue != null and dictValue != ''">dict_value,</if>
 | 
			
		||||
        <if test="dictType != null and dictType != ''">dict_type,</if>
 | 
			
		||||
        <if test="cssClass != null and cssClass != ''">css_class,</if>
 | 
			
		||||
        <if test="listClass != null and listClass != ''">list_class,</if>
 | 
			
		||||
        <if test="isDefault != null and isDefault != ''">is_default,</if>
 | 
			
		||||
        <if test="status != null">status,</if>
 | 
			
		||||
        <if test="remark != null and remark != ''">remark,</if>
 | 
			
		||||
        <if test="createBy != null and createBy != ''">create_by,</if>
 | 
			
		||||
        create_time
 | 
			
		||||
        )values(
 | 
			
		||||
        <if test="dictSort != null">#{dictSort},</if>
 | 
			
		||||
        <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
 | 
			
		||||
        <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
 | 
			
		||||
        <if test="dictType != null and dictType != ''">#{dictType},</if>
 | 
			
		||||
        <if test="cssClass != null and cssClass != ''">#{cssClass},</if>
 | 
			
		||||
        <if test="listClass != null and listClass != ''">#{listClass},</if>
 | 
			
		||||
        <if test="isDefault != null and isDefault != ''">#{isDefault},</if>
 | 
			
		||||
        <if test="status != null">#{status},</if>
 | 
			
		||||
        <if test="remark != null and remark != ''">#{remark},</if>
 | 
			
		||||
        <if test="createBy != null and createBy != ''">#{createBy},</if>
 | 
			
		||||
        sysdate()
 | 
			
		||||
        )
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
</mapper> 
 | 
			
		||||
@@ -20,27 +20,6 @@
 | 
			
		||||
        from sys_dict_type
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictTypeList" parameterType="SysDictType" resultMap="SysDictTypeResult">
 | 
			
		||||
        <include refid="selectDictTypeVo"/>
 | 
			
		||||
        <where>
 | 
			
		||||
            <if test="dictName != null and dictName != ''">
 | 
			
		||||
                AND dict_name like concat('%', #{dictName}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="status != null and status != ''">
 | 
			
		||||
                AND status = #{status}
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="dictType != null and dictType != ''">
 | 
			
		||||
                AND dict_type like concat('%', #{dictType}, '%')
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
 | 
			
		||||
                and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
 | 
			
		||||
            </if>
 | 
			
		||||
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
 | 
			
		||||
                and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
 | 
			
		||||
            </if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <select id="selectDictTypeAll" resultMap="SysDictTypeResult">
 | 
			
		||||
        <include refid="selectDictTypeVo"/>
 | 
			
		||||
    </select>
 | 
			
		||||
@@ -60,48 +39,4 @@
 | 
			
		||||
        where dict_type = #{dictType} limit 1
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDictTypeById" parameterType="Long">
 | 
			
		||||
        delete
 | 
			
		||||
        from sys_dict_type
 | 
			
		||||
        where dict_id = #{dictId}
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
    <delete id="deleteDictTypeByIds" parameterType="Long">
 | 
			
		||||
        delete from sys_dict_type where dict_id in
 | 
			
		||||
        <foreach collection="array" item="dictId" open="(" separator="," close=")">
 | 
			
		||||
            #{dictId}
 | 
			
		||||
        </foreach>
 | 
			
		||||
    </delete>
 | 
			
		||||
 | 
			
		||||
    <update id="updateDictType" parameterType="SysDictType">
 | 
			
		||||
        update sys_dict_type
 | 
			
		||||
        <set>
 | 
			
		||||
            <if test="dictName != null and dictName != ''">dict_name = #{dictName},</if>
 | 
			
		||||
            <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
 | 
			
		||||
            <if test="status != null">status = #{status},</if>
 | 
			
		||||
            <if test="remark != null">remark = #{remark},</if>
 | 
			
		||||
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 | 
			
		||||
            update_time = sysdate()
 | 
			
		||||
        </set>
 | 
			
		||||
        where dict_id = #{dictId}
 | 
			
		||||
    </update>
 | 
			
		||||
 | 
			
		||||
    <insert id="insertDictType" parameterType="SysDictType">
 | 
			
		||||
        insert into sys_dict_type(
 | 
			
		||||
        <if test="dictName != null and dictName != ''">dict_name,</if>
 | 
			
		||||
        <if test="dictType != null and dictType != ''">dict_type,</if>
 | 
			
		||||
        <if test="status != null">status,</if>
 | 
			
		||||
        <if test="remark != null and remark != ''">remark,</if>
 | 
			
		||||
        <if test="createBy != null and createBy != ''">create_by,</if>
 | 
			
		||||
        create_time
 | 
			
		||||
        )values(
 | 
			
		||||
        <if test="dictName != null and dictName != ''">#{dictName},</if>
 | 
			
		||||
        <if test="dictType != null and dictType != ''">#{dictType},</if>
 | 
			
		||||
        <if test="status != null">#{status},</if>
 | 
			
		||||
        <if test="remark != null and remark != ''">#{remark},</if>
 | 
			
		||||
        <if test="createBy != null and createBy != ''">#{createBy},</if>
 | 
			
		||||
        sysdate()
 | 
			
		||||
        )
 | 
			
		||||
    </insert>
 | 
			
		||||
 | 
			
		||||
</mapper> 
 | 
			
		||||
		Reference in New Issue
	
	Block a user