update 简化查询部门功能

This commit is contained in:
疯狂的狮子li 2022-03-03 11:15:21 +08:00
parent f41bfdb8eb
commit 00549c267f
3 changed files with 16 additions and 25 deletions

View File

@ -1,5 +1,7 @@
package com.ruoyi.system.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.common.annotation.DataColumn;
import com.ruoyi.common.annotation.DataPermission;
import com.ruoyi.common.core.domain.entity.SysDept;
@ -18,13 +20,13 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDeptMapper, SysDept, Sy
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @param queryWrapper 查询条件
* @return 部门信息集合
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id")
@DataColumn(key = "deptName", value = "dept_id")
})
List<SysDept> selectDeptList(SysDept dept);
List<SysDept> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
/**
* 根据角色ID查询部门树信息

View File

@ -46,7 +46,15 @@ public class SysDeptServiceImpl implements ISysDeptService {
*/
@Override
public List<SysDept> selectDeptList(SysDept dept) {
return baseMapper.selectDeptList(dept);
LambdaQueryWrapper<SysDept> lqw = new LambdaQueryWrapper<>();
lqw.eq(SysDept::getDelFlag, "0")
.eq(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId())
.eq(ObjectUtil.isNotNull(dept.getParentId()), SysDept::getParentId, dept.getParentId())
.like(StringUtils.isNotBlank(dept.getDeptName()), SysDept::getDeptName, dept.getDeptName())
.eq(StringUtils.isNotBlank(dept.getStatus()), SysDept::getStatus, dept.getStatus())
.orderByAsc(SysDept::getParentId)
.orderByAsc(SysDept::getOrderNum);
return baseMapper.selectDeptList(lqw);
}
/**

View File

@ -22,27 +22,8 @@
<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="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>
order by d.parent_id, d.order_num
<select id="selectDeptList" resultMap="SysDeptResult">
select * from sys_dept ${ew.getCustomSqlSegment}
</select>
<select id="selectDeptListByRoleId" resultType="Long">