<?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.boman.web.core.mapper.YmjzImportErrorLogMapper">

    <resultMap type="com.boman.domain.YmjzImportErrorLog" id="YmjzImportErrorLogResult">
        <result property="id"    column="id"    />
        <result property="username"    column="username"    />
        <result property="town"    column="town"    />
        <result property="vaccineName"    column="vaccine_name"    />
        <result property="jici"    column="jici"    />
        <result property="vaccinationTime"    column="vaccination_time"    />
        <result property="vaccinationPlace"    column="vaccination_place"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectYmjzImportErrorLogVo">
        select id,username,town,vaccine_name,jici,vaccination_time,vaccination_place,create_by,create_time,update_by,update_time,is_del
        from ymjz_import_error_log

    </sql>

    <select id="selectYmjzImportErrorLogList" resultMap="YmjzImportErrorLogResult">
        <include refid="selectYmjzImportErrorLogVo"/>
        <where>
            is_del = 'N'
            <if test="username != null  and username != ''"> and username = #{username}</if>
            <if test="jici != null  and jici != ''"> and jici &lt;= #{jici}</if>
            <if test="vaccineName != null  and vaccineName != ''"> and vaccine_name like concat('%', #{vaccineName}, '%')</if>
            <if test="vaccinationTime != null "> and DATE_FORMAT(vaccination_time,'%Y-%m-%d') = DATE_FORMAT(#{vaccinationTime},'%Y-%m-%d')</if>
        </where>
        order by create_time DESC
    </select>


    <insert id="insertErrorLog" parameterType="com.boman.domain.YmjzImportErrorLog">
        insert into ymjz_import_error_log (
            <if test="username != null and username != ''">username,</if>
            <if test="town != null and town != ''">town,</if>
            <if test="vaccineName != null and vaccineName != ''">vaccine_name,</if>
            <if test="jici != null and remark != ''">jici,</if>
            <if test="vaccinationTime != null and vaccinationTime != ''">vaccination_time,</if>
            <if test="vaccinationPlace != null and vaccinationPlace != ''">vaccination_place,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            create_time, updateTime
        )values(
            <if test="username != null and username != ''">#{username},</if>
            <if test="town != null and town != ''">#{town},</if>
            <if test="vaccineName != null and vaccineName != ''">#{vaccine_name},</if>
            <if test="jici != null and remark != ''">#{jici},</if>
            <if test="vaccinationTime != null and vaccinationTime != ''">#{vaccination_time},</if>
            <if test="vaccinationPlace != null and vaccinationPlace != ''">#{vaccination_place},</if>
            <if test="createBy != null and createBy != ''">#{create_by},</if>
            <if test="updateBy != null and updateBy != ''">#{update_by},</if>
            sysdate(), sysdate()
        )
    </insert>

</mapper>