<?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.huashe.park.core.mapper.ParkAttendUsrDetailMapper">
    
    <resultMap type="ParkAttendUsrDetail" id="ParkAttendUsrDetailResult">
        <result property="id"    column="id"    />
        <result property="usrId"    column="usr_id"    />
        <result property="usrName"    column="usr_name"    />
        <result property="attendStart"    column="attend_start"    />
        <result property="attendEnd"    column="attend_end"    />
        <result property="dt"    column="dt"    />
        <result property="startAttendStat"    column="start_attend_stat"    />
        <result property="endAttendStat"    column="end_attend_stat"    />
        <result property="attendGroupId"    column="attend_group_id"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="tenantId"    column="tenant_id"    />
    </resultMap>

    <sql id="selectParkAttendUsrDetailVo">
        select id, usr_id, usr_name, attend_start, attend_end, dt, start_attend_stat,
            end_attend_stat, attend_group_id, update_time, create_time, create_by, update_by, tenant_id from park_attend_usr_detail
    </sql>

    <select id="selectParkAttendUsrDetailList" parameterType="ParkAttendUsrDetail" resultMap="ParkAttendUsrDetailResult">
        <include refid="selectParkAttendUsrDetailVo"/>
        <where>
            <if test="usrName != null  and usrName != ''">and usr_name like concat('%', #{usrName}, '%')</if>
            <if test="startAttendStat != null ">and start_attend_stat = #{startAttendStat}</if>
            <if test="endAttendStat != null ">and end_attend_stat = #{endAttendStat}</if>
            <if test="attendEnd != null ">and attend_end = #{attendEnd}</if>
            <if test="attendStart != null ">and attend_start = #{attendStart}</if>
            <if test="attendGroupId != null ">and attend_group_id = #{attendGroupId}</if>
            <if test="tenantId != null  and tenantId != ''">and tenant_id = #{tenantId}</if>
        </where>
    </select>
    
    <select id="selectParkAttendUsrDetailById" parameterType="Long" resultMap="ParkAttendUsrDetailResult">
        <include refid="selectParkAttendUsrDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertParkAttendUsrDetail" parameterType="ParkAttendUsrDetail" useGeneratedKeys="true" keyProperty="id">
        insert into park_attend_usr_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="usrId != null">usr_id,</if>
            <if test="usrName != null and usrName != ''">usr_name,</if>
            <if test="startAttendStat != null">attend_start,</if>
            <if test="endAttendStat != null">attend_end,</if>
            <if test="attendEnd != null">attend_end,</if>
            <if test="attendStart != null">attend_start,</if>
            <if test="dt != null">dt,</if>
            <if test="attendGroupId != null">attend_group_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="tenantId != null">tenant_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="usrId != null">#{usrId},</if>
            <if test="usrName != null and usrName != ''">#{usrName},</if>
            <if test="endAttendStat != null">#{endAttendStat},</if>
            <if test="startAttendStat != null">#{startAttendStat},</if>
            <if test="attendEnd != null">#{attendEnd},</if>
            <if test="attendStart != null">#{attendStart},</if>
            <if test="dt != null">#{dt},</if>
            <if test="attendGroupId != null">#{attendGroupId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="tenantId != null">#{tenantId},</if>
        </trim>
    </insert>

    <update id="updateParkAttendUsrDetail" parameterType="ParkAttendUsrDetail">
        update park_attend_usr_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="usrId != null">usr_id = #{usrId},</if>
            <if test="usrName != null and usrName != ''">usr_name = #{usrName},</if>
            <if test="startAttendStat != null">start_attend_start = #{startAttendStat},</if>
            <if test="endAttendStat != null">end_attend_end = #{endAttendStat},</if>
            <if test="attendStart != null">attend_start = #{attendStart},</if>
            <if test="attendEnd != null">attend_end = #{attendEnd},</if>
            <if test="attendStart != null">attend_start = #{attendStart},</if>
            <if test="dt != null">dt = #{dt},</if>
            <if test="attendGroupId != null">attend_group_id = #{attendGroupId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="tenantId != null">tenant_id = #{tenantId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteParkAttendUsrDetailById" parameterType="Long">
        delete from park_attend_usr_detail where id = #{id}
    </delete>

    <delete id="deleteParkAttendUsrDetailByIds" parameterType="String">
        delete from park_attend_usr_detail where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>