<?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.djhk.uav.sysPolice.mapper.SysPoliceFlyMapper">

	<resultMap type="com.djhk.common.api.domain.SysPoliceFly" id="SyspoliceResult">
		<id     property="id"     column="id"     />
		<result property="userName"   column="user_name"   />
		<result property="policeNo"  column="police_no"   />
		<result property="IDNo"   column="id_no"   />
		<result property="phoneNo"   column="phone_no"   />
		<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>

	<sql id="selectPoliceVo">
        select id, user_name, police_no, id_no, phone_no,create_by,create_time,update_by,update_time
        from sys_police_fly
    </sql>

	<select id="selectPoliceList" parameterType="com.djhk.common.api.domain.SysPoliceFly" resultMap="SyspoliceResult">
        <include refid="selectPoliceVo"/>
		<where>
			<if test="userName != null and userName != ''">
				AND user_name like concat('%', #{userName}, '%')
			</if>
			<if test="policeNo != null and policeNo != ''">
				AND police_no = #{policeNo}
			</if>
			<if test="IDNo != null and IDNo != ''">
				AND id_no = #{IDNo}
			</if>
			<if test="phoneNo != null and phoneNo != ''">
				AND phone_no = #{phoneNo}
			</if>
		</where>
    </select>

    <select id="selectPoliceById" parameterType="Long" resultMap="SyspoliceResult">
		<include refid="selectPoliceVo"/>
		where id = #{id}
	</select>


    <insert id="insertPolice" parameterType="com.djhk.common.api.domain.SysPoliceFly" useGeneratedKeys="true" keyProperty="id">
 		insert into sys_police_fly(
 			<if test="userName != null and userName != ''">user_name,</if>
 			<if test="policeNo != null and policeNo != ''">police_no,</if>
			<if test="IDNo != null and IDNo != ''">id_no,</if>
			<if test="phoneNo != null and phoneNo != ''">phone_no,</if>
 			<if test="createBy != null and createBy != ''">create_by,</if>
 			create_time
 		)values(
 			<if test="userName != null and userName != ''">#{userName},</if>
 			<if test="policeNo != null and policeNo != ''">#{policeNo},</if>
			<if test="IDNo != null and IDNo != ''">#{IDNo},</if>
			<if test="phoneNo != null and phoneNo != ''">#{phoneNo},</if>
 			<if test="createBy != null and createBy != ''">#{createBy},</if>
 			sysdate()
 		)
	</insert>

	<update id="updatePolice" parameterType="com.djhk.common.api.domain.SysPoliceFly">
 		update sys_police_fly
 		<set>
			<if test="userName != null and userName != ''">user_name = #{userName},</if>
			<if test="policeNo != null and policeNo != ''">police_no = #{policeNo},</if>
 			<if test="IDNo != null and IDNo  != 0">id_no = #{IDNo},</if>
 			<if test="phoneNo != null and phoneNo != ''">phone_no = #{phoneNo},</if>
 			<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
 			update_time = sysdate()
 		</set>
 		where id = #{id}
	</update>


	<delete id="deletePoliceById" parameterType="Long">
		DELETE sys_police_fly where id = #{id}
	</delete>

</mapper>
