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'
insert into t_card (card_no, employee_id, bind_time, create_by, create_time)
values (#{cardNo}, #{employeeId},
sysdate()
null
,
#{createBy}, sysdate())
update t_card
set card_no = #{cardNo},
update_by = #{updateBy},
update_time = sysdate()
where card_id = #{cardId}
and del_flag = '0'
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 t_card
set employee_id = null,
bind_time = null,
update_by = #{updateBy},
update_time = sysdate()
where employee_id = #{employeeId}
and del_flag = '0'
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 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
#{cardId}