|
|
|
<?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>
|
|
|
|
|
|
|
|
<!-- 不含部门id时列表 -->
|
|
|
|
<resultMap id="employeeList" type="com.daqing.framework.domain.hrms.ext.EmployeeListVO">
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="jobNumber" column="job_number"/>
|
|
|
|
<association property="account" javaType="string">
|
|
|
|
<result column="account"/>
|
|
|
|
</association>
|
|
|
|
<association property="createTime" javaType="java.util.Date">
|
|
|
|
<result column="create_time"/>
|
|
|
|
</association>
|
|
|
|
<association property="status" javaType="integer">
|
|
|
|
<result column="status"/>
|
|
|
|
</association>
|
|
|
|
<collection property="departmentNameList" ofType="string" column="id" select="departmentList"/>
|
|
|
|
<collection property="positionNameList" ofType="string" column="id" select="positionList"/>
|
|
|
|
<collection property="roleNameList" ofType="string" column="id" select="roleList"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 含有部门时列表 -->
|
|
|
|
<resultMap id="employeeAndDeptList" type="com.daqing.framework.domain.hrms.ext.EmployeeListVO">
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="jobNumber" column="job_number"/>
|
|
|
|
<association property="account" javaType="string">
|
|
|
|
<result column="account"/>
|
|
|
|
</association>
|
|
|
|
<association property="createTime" javaType="java.util.Date">
|
|
|
|
<result column="create_time"/>
|
|
|
|
</association>
|
|
|
|
<association property="status" javaType="integer">
|
|
|
|
<result column="status"/>
|
|
|
|
</association>
|
|
|
|
<collection property="departmentNameList" ofType="string" column="id" select="departmentList"/>
|
|
|
|
<collection property="positionNameList" ofType="string" column="id" select="positionList"/>
|
|
|
|
<collection property="roleNameList" ofType="string" column="id" select="roleList"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 员工详情(人力后台展示) -->
|
|
|
|
<resultMap id="employeeInfo" type="com.daqing.framework.domain.hrms.ext.EmployeeInfoVO">
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="jobNumber" column="job_number"/>
|
|
|
|
<result property="gender" column="gender"/>
|
|
|
|
<result property="birthday" column="birthday"/>
|
|
|
|
<result property="phone" column="phone"/>
|
|
|
|
<result property="companyMail" column="company_mail"/>
|
|
|
|
<association property="account" javaType="string">
|
|
|
|
<result column="account"/>
|
|
|
|
</association>
|
|
|
|
<association property="status" javaType="integer">
|
|
|
|
<result column="status"/>
|
|
|
|
</association>
|
|
|
|
<collection property="departments" ofType="com.daqing.framework.domain.hrms.DeptEntity">
|
|
|
|
<id property="id" column="dept_id"/>
|
|
|
|
<result property="name" column="dept_name"/>
|
|
|
|
</collection>
|
|
|
|
<collection property="positions" ofType="com.daqing.framework.domain.hrms.PositionEntity">
|
|
|
|
<id property="id" column="position_id"/>
|
|
|
|
<result property="name" column="position_name"/>
|
|
|
|
</collection>
|
|
|
|
<collection property="roles" ofType="com.daqing.framework.domain.hrms.RoleEntity">
|
|
|
|
<id property="id" column="role_id"/>
|
|
|
|
<result property="name" column="role_name"/>
|
|
|
|
</collection>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 员工详情(人力工作台展示) -->
|
|
|
|
<resultMap id="employeeInfoByUserId" type="com.daqing.framework.domain.hrms.ext.EmployeeAndUserVO">
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
<result property="name" column="name"/>
|
|
|
|
<result property="jobNumber" column="job_number"/>
|
|
|
|
<result property="gender" column="gender"/>
|
|
|
|
<result property="birthday" column="birthday"/>
|
|
|
|
<result property="phone" column="phone"/>
|
|
|
|
<result property="companyMail" column="company_mail"/>
|
|
|
|
<result property="spareMail" column="spare_mail"/>
|
|
|
|
<result property="officePhone" column="office_phone"/>
|
|
|
|
<result property="positionDescription" column="position_description"/>
|
|
|
|
<result property="headPortaritUrl" column="head_portarit_url"/>
|
|
|
|
<result property="userId" column="user_id"/>
|
|
|
|
<association property="account" javaType="string">
|
|
|
|
<result column="account"/>
|
|
|
|
</association>
|
|
|
|
<association property="password" javaType="string">
|
|
|
|
<result column="password"/>
|
|
|
|
</association>
|
|
|
|
<association property="loginNum" javaType="integer">
|
|
|
|
<result column="login_num"/>
|
|
|
|
</association>
|
|
|
|
<association property="lasttime" javaType="java.util.Date">
|
|
|
|
<result column="lasttime"/>
|
|
|
|
</association>
|
|
|
|
<association property="phoneAccount" javaType="string">
|
|
|
|
<result column="phone_account"/>
|
|
|
|
</association>
|
|
|
|
<association property="wechatId" javaType="string">
|
|
|
|
<result column="wechat_id"/>
|
|
|
|
</association>
|
|
|
|
<collection property="departments" ofType="string">
|
|
|
|
<result column="dept_name"/>
|
|
|
|
</collection>
|
|
|
|
<collection property="positions" ofType="string">
|
|
|
|
<result column="position_name"/>
|
|
|
|
</collection>
|
|
|
|
<collection property="roles" ofType="string">
|
|
|
|
<result column="role_name"/>
|
|
|
|
</collection>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
<!-- 映射user实体类和数据库表主键,使之能获取到新增的主键 -->
|
|
|
|
<resultMap type="com.daqing.framework.domain.hrms.UserEntity" id="userMap">
|
|
|
|
<result property="id" column="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="listEmployeeByDeptIdAndEmpId" 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}
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
AND e.name LIKE CONCAT('%',#{name},'%')
|
|
|
|
</if>
|
|
|
|
<if test="empIds != null and empIds != ''">
|
|
|
|
AND e.id NOT IN
|
|
|
|
<foreach collection="empIds" item="empId" open="(" separator="," close=")">
|
|
|
|
#{empId}
|
|
|
|
</foreach>
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据部门id获取该部门下面所有的员工 -->
|
|
|
|
<select id="employeeListByDeptId" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.UserDeptVO">
|
|
|
|
SELECT
|
|
|
|
u.id,
|
|
|
|
e.name as account , GROUP_CONCAT(er.role_id SEPARATOR ',') roleId
|
|
|
|
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
|
|
|
|
left join hrms_employee_role er on e.user_id = er.user_id
|
|
|
|
WHERE
|
|
|
|
u.del_or_not = 0
|
|
|
|
AND d.id = #{id}
|
|
|
|
<if test="account != null">
|
|
|
|
AND e.name LIKE CONCAT('%',#{account},'%')
|
|
|
|
</if>
|
|
|
|
GROUP BY u.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>
|
|
|
|
|
|
|
|
<select id="pageList" parameterType="com.daqing.framework.domain.hrms.request.EmployeeRequest"
|
|
|
|
resultMap="employeeList">
|
|
|
|
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
|
|
|
|
u.create_time create_time,u.status status
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
<if test="employee.codeOrName != null and employee.codeOrName != ''">
|
|
|
|
AND (e.name LIKE CONCAT('%',#{employee.codeOrName},'%') OR u.account LIKE
|
|
|
|
CONCAT('%',#{employee.codeOrName},'%')
|
|
|
|
OR e.job_number LIKE CONCAT('%',#{employee.codeOrName},'%'))
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="excelList" resultMap="employeeList">
|
|
|
|
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
|
|
|
|
u.create_time create_time,u.status status
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="pageListByDept" parameterType="com.daqing.framework.domain.hrms.request.EmployeeRequest"
|
|
|
|
resultMap="employeeList">
|
|
|
|
SELECT e.id id,e.name name,u.account account,e.job_number job_number,
|
|
|
|
u.create_time create_time,u.status status
|
|
|
|
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 ed.dept_id = d.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
<if test="employee.id != null and employee.id != ''">
|
|
|
|
AND d.id = #{employee.id}
|
|
|
|
</if>
|
|
|
|
<if test="employee.codeOrName != null and employee.codeOrName != ''">
|
|
|
|
AND (e.name LIKE CONCAT('%',#{employee.codeOrName},'%') OR u.account LIKE
|
|
|
|
CONCAT('%',#{employee.codeOrName},'%')
|
|
|
|
OR e.job_number LIKE CONCAT('%',#{employee.codeOrName},'%'))
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="departmentList" parameterType="long" resultType="string">
|
|
|
|
SELECT d.name
|
|
|
|
FROM hrms_dept d
|
|
|
|
LEFT JOIN hrms_employee_dept ed
|
|
|
|
ON d.id = ed.dept_id
|
|
|
|
LEFT JOIN hrms_employee e
|
|
|
|
ON ed.employee_id = e.id
|
|
|
|
WHERE e.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="positionList" parameterType="long" resultType="string">
|
|
|
|
SELECT p.name
|
|
|
|
FROM hrms_position p
|
|
|
|
LEFT JOIN hrms_employee_position ep
|
|
|
|
ON p.id = ep.position_id
|
|
|
|
LEFT JOIN hrms_employee e
|
|
|
|
ON ep.emp_id = e.id
|
|
|
|
WHERE e.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="roleList" parameterType="long" resultType="string">
|
|
|
|
SELECT r.name
|
|
|
|
FROM hrms_role r
|
|
|
|
LEFT JOIN hrms_employee_role er
|
|
|
|
ON r.id = er.role_id
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON u.id = er.user_id
|
|
|
|
LEFT JOIN hrms_employee e
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE e.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 根据employee id得到 user_id-->
|
|
|
|
<select id="queryIds" parameterType="long" resultType="long">
|
|
|
|
SELECT user_id FROM hrms_employee e
|
|
|
|
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>
|
|
|
|
|
|
|
|
<!-- 删除:del_or_not = 1 -->
|
|
|
|
<delete id="deleteByIds" parameterType="long">
|
|
|
|
UPDATE hrms_user SET del_or_not = 1 WHERE id IN
|
|
|
|
<foreach collection="ids" open="(" separator="," close=")" item="id">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<select id="getStatus" parameterType="long" resultType="integer">
|
|
|
|
SELECT u.status status FROM hrms_user u
|
|
|
|
LEFT JOIN hrms_employee e
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND e.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 启用或者禁用 -->
|
|
|
|
<update id="startOrStop" parameterType="com.daqing.framework.domain.hrms.UserEntity">
|
|
|
|
UPDATE hrms_user SET status = #{status},disable_start_time = #{disableStartTime},
|
|
|
|
disable_end_time = #{disableEndTime},disable_cause = #{disableCause}
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 禁用详情-->
|
|
|
|
<select id="forbidInfo" parameterType="long" resultType="com.daqing.framework.domain.hrms.UserEntity">
|
|
|
|
SELECT disable_start_time,disable_end_time,disable_cause
|
|
|
|
FROM hrms_user WHERE id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 所有的禁用时间 -->
|
|
|
|
<select id="listDisableTime" resultType="com.daqing.framework.domain.hrms.UserEntity">
|
|
|
|
SELECT id,disable_start_time,disable_end_time,disable_cause
|
|
|
|
FROM hrms_user WHERE status = 1 OR status = 2
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 获取user_id-->
|
|
|
|
<select id="getUserId" resultType="long">
|
|
|
|
SELECT user_id FROM hrms_employee WHERE id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 重置密码 -->
|
|
|
|
<update id="updatePassword">
|
|
|
|
UPDATE hrms_user SET password = #{password} WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<select id="getInfo" resultMap="employeeInfo" parameterType="long">
|
|
|
|
SELECT e.id id,e.name name,e.job_number job_number,e.phone phone,e.gender gender,
|
|
|
|
e.birthday birthday,e.company_mail company_mail,u.account account,u.status status,
|
|
|
|
d.id dept_id,d.name dept_name,r.id role_id,r.name role_name,po.id position_id,
|
|
|
|
po.name position_name
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
LEFT JOIN hrms_employee_dept ed
|
|
|
|
ON ed.employee_id = e.id
|
|
|
|
LEFT JOIN hrms_dept d
|
|
|
|
ON ed.dept_id = d.id
|
|
|
|
LEFT JOIN hrms_employee_role er
|
|
|
|
ON er.user_id = u.id
|
|
|
|
LEFT JOIN hrms_role r
|
|
|
|
ON er.role_id = r.id
|
|
|
|
LEFT JOIN hrms_employee_position ep
|
|
|
|
ON ep.emp_id = e.id
|
|
|
|
LEFT JOIN hrms_position po
|
|
|
|
ON ep.position_id = po.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND e.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<update id="updateEmployee" parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
|
|
|
|
UPDATE hrms_employee SET name = #{name},job_number = #{jobNumber},gender = #{gender},birthday = #{birthday},
|
|
|
|
phone = #{phone},company_mail = #{companyMail}
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="updateUser">
|
|
|
|
UPDATE hrms_user SET account = #{account},motify_time = #{modifyTime} WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<delete id="deleteDepartment" parameterType="long">
|
|
|
|
DELETE FROM hrms_employee_dept WHERE employee_id = #{id}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deletePosition" parameterType="long">
|
|
|
|
DELETE FROM hrms_employee_position WHERE emp_id = #{id}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteRole" parameterType="long">
|
|
|
|
DELETE FROM hrms_employee_role WHERE user_id = #{id}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<insert id="insertDepartment">
|
|
|
|
INSERT INTO hrms_employee_dept
|
|
|
|
(employee_id,dept_id)
|
|
|
|
VALUES
|
|
|
|
<foreach collection="deptIds" item="deptId" separator=",">
|
|
|
|
(#{id},#{deptId})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertPosition">
|
|
|
|
INSERT INTO hrms_employee_position
|
|
|
|
(emp_id,position_id)
|
|
|
|
VALUES
|
|
|
|
<foreach collection="positionIds" item="positionId" separator=",">
|
|
|
|
(#{id},#{positionId})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertRole">
|
|
|
|
INSERT INTO hrms_employee_role
|
|
|
|
(user_id,role_id)
|
|
|
|
VALUES
|
|
|
|
<foreach collection="roleIds" item="roleId" separator=",">
|
|
|
|
(#{id},#{roleId})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertUsrRole">
|
|
|
|
INSERT INTO hrms_employee_role
|
|
|
|
(user_id,role_id)
|
|
|
|
VALUES
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
(#{item.userId},#{item.roleId})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertUserRole">
|
|
|
|
INSERT INTO hrms_employee_role
|
|
|
|
(user_id,role_id)
|
|
|
|
VALUES (#{userId},#{roleId})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="saveUserRole">
|
|
|
|
INSERT INTO hrms_employee_role
|
|
|
|
(user_id,role_id)
|
|
|
|
VALUES (#{userId},#{roleId})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertEmployee" keyProperty="id" useGeneratedKeys="true"
|
|
|
|
parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
|
|
|
|
INSERT INTO hrms_employee (name,job_number,gender,birthday,phone,company_mail,user_id)
|
|
|
|
VALUES (#{name},#{jobNumber},#{gender},#{birthday},#{phone},#{companyMail},#{userId})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<insert id="insertUser" keyProperty="id" useGeneratedKeys="true"
|
|
|
|
parameterType="com.daqing.framework.domain.hrms.UserEntity">
|
|
|
|
INSERT INTO hrms_user (account,create_time,motify_time) VALUES (#{account},#{createTime},#{motifyTime})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="getEmployeeByUserId" parameterType="long" resultMap="employeeInfoByUserId">
|
|
|
|
SELECT e.id id,e.name name,e.job_number job_number,e.phone phone,e.gender gender,
|
|
|
|
e.birthday birthday,e.company_mail company_mail,e.spare_mail spare_mail,
|
|
|
|
e.office_phone office_phone,e.position_description position_description,
|
|
|
|
e.head_portarit_url head_portarit_url,e.user_id user_id,u.account account,
|
|
|
|
u.password password,u.login_num login_num,u.lasttime lasttime,u.phone_account
|
|
|
|
phone_account,u.wechat_id wechat_id,d.name dept_name,r.name role_name,
|
|
|
|
po.name position_name
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
LEFT JOIN hrms_employee_dept ed
|
|
|
|
ON ed.employee_id = e.id
|
|
|
|
LEFT JOIN hrms_dept d
|
|
|
|
ON ed.dept_id = d.id
|
|
|
|
LEFT JOIN hrms_employee_role er
|
|
|
|
ON er.user_id = u.id
|
|
|
|
LEFT JOIN hrms_role r
|
|
|
|
ON er.role_id = r.id
|
|
|
|
LEFT JOIN hrms_employee_position ep
|
|
|
|
ON ep.emp_id = e.id
|
|
|
|
LEFT JOIN hrms_position po
|
|
|
|
ON ep.position_id = po.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND u.id = #{id}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<update id="updateEmployeeAndUser" parameterType="com.daqing.framework.domain.hrms.EmployeeEntity">
|
|
|
|
UPDATE hrms_employee SET gender = #{gender},office_phone = #{officePhone},phone = #{phone},
|
|
|
|
company_mail = #{companyMail},spare_mail = #{spareMail}
|
|
|
|
<if test="headPortaritUrl != null and headPortaritUrl != ''">
|
|
|
|
,head_portarit_url = #{headPortaritUrl}
|
|
|
|
</if>
|
|
|
|
WHERE id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 根据id查询员工头像 -->
|
|
|
|
<select id="getEmployeeEntityByUserId" parameterType="long"
|
|
|
|
resultType="com.daqing.framework.domain.hrms.EmployeeEntity">
|
|
|
|
SELECT head_portarit_url
|
|
|
|
FROM hrms_employee
|
|
|
|
WHERE user_id = #{userId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 新增员工时判断姓名、工号、账号是否存在 -->
|
|
|
|
<select id="employeeNameCount" parameterType="string" resultType="integer">
|
|
|
|
SELECT COUNT(e.id)
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND e.name = #{name}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="userAccountCount" parameterType="string" resultType="integer">
|
|
|
|
SELECT COUNT(id) FROM hrms_user WHERE del_or_not = 0 AND account = #{account}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="employeeJobNumberCount" parameterType="string" resultType="integer">
|
|
|
|
SELECT COUNT(e.id)
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND e.job_number = #{jobNumber}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getEmployeeRepetitionByEmpId" parameterType="long"
|
|
|
|
resultType="com.daqing.framework.domain.hrms.ext.EmployeeRepetition">
|
|
|
|
SELECT e.name name,e.job_number job_number,u.account account
|
|
|
|
FROM hrms_employee e
|
|
|
|
LEFT JOIN hrms_user u
|
|
|
|
ON e.user_id = u.id
|
|
|
|
WHERE u.del_or_not = 0
|
|
|
|
AND e.id = #{empId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getAccountAndDeptNameById"
|
|
|
|
resultType="com.daqing.framework.domain.guarantee.response.EmployeeMessageResponse">
|
|
|
|
select hu.id, hu.account, GROUP_CONCAT(hd.`name` SEPARATOR '/')deptName
|
|
|
|
from hrms_employee_dept ed
|
|
|
|
LEFT JOIN hrms_dept hd on hd.id=ed.dept_id
|
|
|
|
LEFT JOIN hrms_employee he on he.id=ed.employee_id
|
|
|
|
LEFT JOIN hrms_user hu on hu.id = he.user_id
|
|
|
|
where hu.id IN
|
|
|
|
<foreach collection="ids" open="(" separator="," close=")" item="id">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
GROUP BY hu.id
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 根据userId查询对应的员工姓名 -->
|
|
|
|
<select id="listEmpNameByUserId" parameterType="integer" resultType="com.daqing.framework.domain.hrms.ext.EmployeeVO">
|
|
|
|
SELECT u.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
|
|
|
|
AND u.id IN
|
|
|
|
<foreach collection="userIds" open="(" separator="," close=")" item="userId">
|
|
|
|
#{userId}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="getListEmployeeTrees" parameterType="long" resultType="com.daqing.framework.domain.hrms.ext.UserDeptVO">
|
|
|
|
SELECT
|
|
|
|
u.id,
|
|
|
|
e.name as account
|
|
|
|
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}
|
|
|
|
<if test="account != null">
|
|
|
|
AND e.name LIKE CONCAT('%',#{account},'%')
|
|
|
|
</if>
|
|
|
|
</select>
|
|
|
|
<select id="selectUserRole" resultType="java.lang.Integer">
|
|
|
|
select COUNT(0) from hrms_employee_role where user_id=#{userId} and role_id=#{roleId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<select id="countUserIdAndRoleId" resultType="integer">
|
|
|
|
SELECT COUNT(id) FROM hrms_employee_role WHERE user_id = #{userId} AND role_id = #{roleId}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
</mapper>
|