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.
101 lines
4.0 KiB
101 lines
4.0 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.EmployeeDao"> |
|
|
|
<!-- 可根据自己的需求,是否要使用 --> |
|
<resultMap type="com.daqing.framework.domain.hrms.EmployeeEntity" id="employeeMap"> |
|
<result property="id" column="id"/> |
|
<result property="name" column="name"/> |
|
<result property="gender" column="gender"/> |
|
<result property="birthday" column="birthday"/> |
|
<result property="officePhone" column="office_phone"/> |
|
<result property="phone" column="phone"/> |
|
<result property="companyMail" column="company_mail"/> |
|
<result property="spareMail" column="spare_mail"/> |
|
<result property="positionDescription" column="position_description"/> |
|
<result property="jobNumber" column="job_number"/> |
|
<result property="headPortaritUrl" column="head_portarit_url"/> |
|
<result property="userId" column="user_id"/> |
|
</resultMap> |
|
|
|
<resultMap type="com.daqing.framework.domain.hrms.ext.EmployeeTO" id="employeeTO"> |
|
<id property="id" column="eid"/> |
|
<result property="empName" column="emp_name"/> |
|
<collection property="deptNames" ofType="string"> |
|
<result column="dept_name"/> <!-- 员工和部门是多对多,从单个员工的角度看为一对多 --> |
|
</collection> |
|
</resultMap> |
|
|
|
<!-- 根据员工id查询员工的姓名和部门信息 --> |
|
<select id="getEmployeeAndDeptById" resultMap="employeeTO"> |
|
SELECT e.id eid,e.name emp_name,d.name dept_name |
|
FROM hrms_employee e |
|
LEFT JOIN hrms_employee_dept ed |
|
ON e.id = ed.employee_id |
|
LEFT JOIN hrms_dept d |
|
ON d.id = ed.dept_id |
|
LEFT JOIN hrms_user u |
|
ON e.user_id = u.id |
|
WHERE u.del_or_not = 0 |
|
AND e.id |
|
IN |
|
<foreach collection="ids" open="(" separator="," close=")" item="id"> |
|
#{id} |
|
</foreach> |
|
</select> |
|
|
|
<!-- 根据id查询员工姓名 --> |
|
<select id="getEmployeeById" parameterType="long" resultType="com.daqing.framework.domain.hrms.EmployeeEntity"> |
|
SELECT e.name name |
|
FROM hrms_employee e |
|
LEFT JOIN hrms_user u |
|
ON e.user_id = u.id |
|
WHERE u.del_or_not = 0 |
|
AND e.id = #{id} |
|
</select> |
|
|
|
<!-- 根据部门id获取该部门下面所有的员工 --> |
|
<select id="listEmployeeByDeptId" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO"> |
|
SELECT e.id,e.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 = #{id} |
|
</select> |
|
|
|
<!-- 查询所有的员工姓名和id --> |
|
<select id="listEmployeeName" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO"> |
|
SELECT e.id id,e.name name |
|
FROM hrms_employee e |
|
LEFT JOIN hrms_user u |
|
ON e.user_id = u.id |
|
WHERE u.del_or_not = 0 |
|
</select> |
|
|
|
<!-- //TODO 修改查询员工为user表的del_or_not = 0的员工 --> |
|
<select id="pageByCondition" resultMap="employeeMap"> |
|
SELECT e.id eid,e.name emp_name,d.name |
|
,u.account,e.job_number,u.create_time,p.name pos_name |
|
FROM hrms_employee e |
|
LEFT JOIN hrms_employee_dept ed ON e.id = ed.employee_id |
|
LEFT JOIN hrms_dept d ON d.id = ed.dept_id |
|
LEFT JOIN hrms_user u ON e.user_id = u.id |
|
LEFT JOIN hrms_employee_position ep ON e.id = ep.emp_id |
|
LEFT JOIN hrms_position p ON p.id = ep.position_id |
|
<where> |
|
<if test="employee.name != null and employee.name != ''"> |
|
e.`name` LIKE CONCAT('%',#{employee.name},'%') |
|
</if> |
|
<if test="employee.jobNumber != null and employee.jobNumber != ''"> |
|
AND e.job_number = #{employee.jobNumber} |
|
</if> |
|
AND u.del_or_not = 0 |
|
</where> |
|
</select> |
|
</mapper> |