<?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.ruoyi.system.mapper.SysCardMapper">
|
|
<resultMap type="SysCard" id="SysCardResult">
|
<id property="cardId" column="card_id" />
|
<result property="cardNo" column="card_no" />
|
<result property="employeeId" column="employee_id" />
|
<result property="delFlag" column="del_flag" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
</resultMap>
|
|
<resultMap type="SysCardVO" id="SysCardVOResult">
|
<id property="cardId" column="card_id" />
|
<result property="cardNo" column="card_no" />
|
<result property="employeeId" column="employee_id" />
|
<result property="employeeName" column="employee_name" />
|
<result property="contactPhone" column="contact_phone_cipher" />
|
<result property="deptId" column="dept_id" />
|
<result property="deptName" column="dept_name" />
|
<result property="bindTime" column="bind_time" />
|
<result property="bound" column="bound" />
|
</resultMap>
|
|
<sql id="selectCardVo">
|
select c.card_id,
|
c.card_no,
|
c.employee_id,
|
e.employee_name,
|
e.contact_phone_cipher,
|
e.dept_id,
|
d.dept_name,
|
c.bind_time,
|
case when c.employee_id is not null then 1 else 0 end as bound
|
from t_card c
|
left join t_employee e on e.employee_id = c.employee_id and e.del_flag = '0'
|
left join sys_dept d on d.dept_id = e.dept_id and d.del_flag = '0'
|
</sql>
|
|
<select id="pageList" resultMap="SysCardVOResult">
|
<include refid="selectCardVo" />
|
<where>
|
c.del_flag = '0'
|
<if test="query.cardNo != null and query.cardNo != ''">
|
and c.card_no like concat('%', #{query.cardNo}, '%')
|
</if>
|
<if test="query.employeeName != null and query.employeeName != ''">
|
and e.employee_name like concat('%', #{query.employeeName}, '%')
|
</if>
|
<if test="query.bound != null and query.bound">
|
and c.employee_id is not null
|
</if>
|
<if test="query.bound != null and !query.bound">
|
and c.employee_id is null
|
</if>
|
</where>
|
order by c.bind_time desc, c.card_id desc
|
</select>
|
|
<select id="selectList" resultMap="SysCardVOResult">
|
<include refid="selectCardVo" />
|
<where>
|
c.del_flag = '0'
|
<if test="query.cardNo != null and query.cardNo != ''">
|
and c.card_no like concat('%', #{query.cardNo}, '%')
|
</if>
|
<if test="query.employeeName != null and query.employeeName != ''">
|
and e.employee_name like concat('%', #{query.employeeName}, '%')
|
</if>
|
<if test="query.bound != null and query.bound">
|
and c.employee_id is not null
|
</if>
|
<if test="query.bound != null and !query.bound">
|
and c.employee_id is null
|
</if>
|
</where>
|
order by c.bind_time desc, c.card_id desc
|
</select>
|
|
<select id="selectVoById" parameterType="Long" resultMap="SysCardVOResult">
|
<include refid="selectCardVo" />
|
where c.card_id = #{cardId}
|
and c.del_flag = '0'
|
</select>
|
|
<select id="selectById" parameterType="Long" resultMap="SysCardResult">
|
select card_id, card_no, employee_id, del_flag, create_by, create_time, update_by, update_time
|
from t_card
|
where card_id = #{cardId}
|
and del_flag = '0'
|
</select>
|
|
<select id="selectByCardNo" resultMap="SysCardResult">
|
select card_id, card_no, employee_id, del_flag, create_by, create_time, update_by, update_time
|
from t_card
|
where card_no = #{cardNo}
|
and del_flag = '0'
|
limit 1
|
</select>
|
|
<select id="selectByEmployeeId" resultMap="SysCardResult">
|
select card_id, card_no, employee_id, del_flag, create_by, create_time, update_by, update_time
|
from t_card
|
where employee_id = #{employeeId}
|
and del_flag = '0'
|
limit 1
|
</select>
|
|
<insert id="insertCard" parameterType="SysCard" useGeneratedKeys="true" keyProperty="cardId">
|
insert into t_card (card_no, employee_id, bind_time, create_by, create_time)
|
values (#{cardNo}, #{employeeId},
|
<choose>
|
<when test="employeeId != null">sysdate()</when>
|
<otherwise>null</otherwise>
|
</choose>,
|
#{createBy}, sysdate())
|
</insert>
|
|
<update id="updateCard" parameterType="SysCard">
|
update t_card
|
set card_no = #{cardNo},
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where card_id = #{cardId}
|
and del_flag = '0'
|
</update>
|
|
<update id="bindCard">
|
update t_card
|
set employee_id = #{employeeId},
|
bind_time = sysdate(),
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where card_id = #{cardId}
|
and del_flag = '0'
|
</update>
|
|
<update id="unbindByEmployeeId">
|
update t_card
|
set employee_id = null,
|
bind_time = null,
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where employee_id = #{employeeId}
|
and del_flag = '0'
|
</update>
|
|
<update id="unbindByCardNo">
|
update t_card
|
set employee_id = null,
|
bind_time = null,
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where card_no = #{cardNo}
|
and del_flag = '0'
|
</update>
|
|
<update id="deleteByIds">
|
update t_card
|
set employee_id = null,
|
bind_time = null,
|
del_flag = '1',
|
update_by = #{updateBy},
|
update_time = sysdate()
|
where del_flag = '0'
|
and card_id in
|
<foreach collection="cardIds" item="cardId" open="(" separator="," close=")">
|
#{cardId}
|
</foreach>
|
</update>
|
</mapper>
|