<?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.bonus.system.att.dao.AttendanceMachineDao">

	<select id="selectAttendanceMachineList" resultType="com.bonus.system.att.entity.AttendanceMachineBean">
		select * from att_machine where is_active = 1
		<if test="machineName != null and machineName != ''">
			AND machine_name like concat('%', #{machineName}, '%')
		</if>
		<if test="attAddress != null and attAddress != ''">
			AND att_address like concat('%', #{attAddress}, '%')
		</if>
	</select>

	<select id="selectAttendanceMachineById" resultType="com.bonus.system.att.entity.AttendanceMachineBean">
		select * from att_machine where is_active = 1 and id = #{machineId}
	</select>

	<insert id="insertAttendanceMachine">
		insert into att_machine(machine_name, model, machine_code, ip, port,
								att_address, status, create_user_id)
		values (#{machineName}, #{model}, #{machineCode}, #{ip}, #{port},
		        #{attAddress}, #{status}, #{createUserId})
	</insert>

	<update id="updateAttendanceMachine">
		update att_machine set machine_name = #{machineName}, model = #{model},
		machine_code = #{machineCode}, ip = #{ip}, port = #{port}, att_address = #{attAddress},
		status = #{status}, update_user_id = #{updateUserId} where id = #{id}
	</update>

	<delete id="deleteAttendanceMachine">
		update att_machine set is_active = 0, update_user_id = #{updateUserId}
		where id = #{machineId}
	</delete>
</mapper>