You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.3 KiB

<?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.daqing.financial.hrms.dao.DeptDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.DeptEntity" id="deptMap">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="parentId" column="parent_id"/>
<result property="level" column="level"/>
<result property="sort" column="sort"/>
<result property="createTime" column="create_time"/>
<result property="motifyTime" column="motify_time"/>
</resultMap>
<!-- 部门树及各级部门下的员工 -->
<select id="getMaxSort" parameterType="java.lang.Long" resultType="java.lang.Integer">
SELECT MAX(sort) FROM hrms_dept WHERE parent_id = #{parentId}
</select>
<select id="getEmpDeptCount" parameterType="java.lang.Long" resultType="java.lang.Integer">
SELECT count(1) FROM hrms_employee_dept AS ed
LEFT JOIN hrms_employee AS e
ON ed.employee_id = e.id
LEFT JOIN hrms_user AS u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND dept_id = #{deptId}
</select>
<select id="getByPositionId" resultType="com.daqing.framework.domain.hrms.DeptEntity">
SELECT
d.*
FROM
hrms_dept d
INNER JOIN hrms_dept_position dp ON d.id = dp.dept_id
WHERE
dp.position_id = #{positionId}
</select>
<select id="listDepartment" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name,parent_id,sort
FROM hrms_dept
</select>
<select id="getDepartmentByParentId" parameterType="long" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name,parent_id,sort
FROM hrms_dept WHERE parent_id = #{parentId}
</select>
<select id="listDepartmentIdAndName" resultType="com.daqing.framework.domain.hrms.DepartmentVO">
SELECT id,name FROM hrms_dept
</select>
<select id="listEmployeeById" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO">
SELECT DISTINCT e.id id,e.name name
FROM hrms_employee e
LEFT JOIN hrms_user u
ON e.user_id = u.id
LEFT JOIN hrms_employee_dept ed
ON e.id = ed.employee_id
LEFT JOIN hrms_dept d
ON d.id = ed.dept_id
WHERE u.del_or_not = 0
AND d.id IN
( SELECT d.id
FROM hrms_dept d
LEFT JOIN hrms_employee_dept ed
ON d.id = ed.dept_id
LEFT JOIN hrms_employee e
ON e.id = ed.employee_id
WHERE e.id = #{id}
)
</select>
<select id="listEmployeeByDeptId" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO">
SELECT e.id id,e.name name
FROM hrms_employee e
LEFT JOIN hrms_employee_dept ed
ON e.id = ed.employee_id
LEFT JOIN hrms_dept d
ON ed.dept_id = d.id
LEFT JOIN hrms_user u
ON e.user_id = u.id
WHERE u.del_or_not = 0
AND d.id = #{deptId}
</select>
<select id="listDepartments" resultType="java.util.Map">
SELECT id,name FROM hrms_dept
</select>
</mapper>