<?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.microservices.zone.specialProject.mapper.ZoneSpecialProjectReportMapper">

    <resultMap type="ZoneSpecialProjectReport" id="ZoneSpecialProjectReportResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="author" column="author"/>
        <result property="remark" column="remark"/>
        <result property="link" column="link"/>
        <result property="specialProjectId" column="special_project_id"/>
        <result property="sort" column="sort"/>
        <result property="zoneId" column="zone_id"/>
        <result property="deptId" column="dept_id"/>
        <result property="delFlag" column="del_flag"/>
        <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="reservedField1" column="reserved_field_1"/>
        <result property="reservedField2" column="reserved_field_2"/>
    </resultMap>

    <sql id="selectZoneSpecialProjectReportVo">
        select id,
               name,
               author,
               remark,
               link,
               special_project_id,
               sort,
               zone_id,
               dept_id,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               reserved_field_1,
               reserved_field_2
        from zone_special_project_report
    </sql>

    <select id="selectZoneSpecialProjectReportList" parameterType="ZoneSpecialProjectReport"
            resultMap="ZoneSpecialProjectReportResult">
        <include refid="selectZoneSpecialProjectReportVo"/>
        <where>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="author != null  and author != ''">and author = #{author}</if>
            <if test="link != null  and link != ''">and link = #{link}</if>
            <if test="specialProjectId != null ">and special_project_id = #{specialProjectId}</if>
            <if test="sort != null ">and sort = #{sort}</if>
            <if test="zoneId != null ">and zone_id = #{zoneId}</if>
            <if test="deptId != null ">and dept_id = #{deptId}</if>
            <if test="reservedField1 != null  and reservedField1 != ''">and reserved_field_1 = #{reservedField1}</if>
            <if test="reservedField2 != null  and reservedField2 != ''">and reserved_field_2 = #{reservedField2}</if>
        </where>
        ORDER BY sort ASC
    </select>

    <select id="selectZoneSpecialProjectReportById" parameterType="Long" resultMap="ZoneSpecialProjectReportResult">
        <include refid="selectZoneSpecialProjectReportVo"/>
        where id = #{id}
    </select>

    <insert id="insertZoneSpecialProjectReport" parameterType="ZoneSpecialProjectReport" useGeneratedKeys="true"
            keyProperty="id">
        insert into zone_special_project_report
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="author != null and author != ''">author,</if>
            <if test="remark != null">remark,</if>
            <if test="link != null and link != ''">link,</if>
            <if test="specialProjectId != null">special_project_id,</if>
            <if test="sort != null">sort,</if>
            <if test="zoneId != null">zone_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="reservedField1 != null">reserved_field_1,</if>
            <if test="reservedField2 != null">reserved_field_2,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="author != null and author != ''">#{author},</if>
            <if test="remark != null">#{remark},</if>
            <if test="link != null and link != ''">#{link},</if>
            <if test="specialProjectId != null">#{specialProjectId},</if>
            <if test="sort != null">#{sort},</if>
            <if test="zoneId != null">#{zoneId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="reservedField1 != null">#{reservedField1},</if>
            <if test="reservedField2 != null">#{reservedField2},</if>
        </trim>
    </insert>

    <update id="updateZoneSpecialProjectReport" parameterType="ZoneSpecialProjectReport">
        update zone_special_project_report
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="author != null and author != ''">author = #{author},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="link != null and link != ''">link = #{link},</if>
            <if test="specialProjectId != null">special_project_id = #{specialProjectId},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="zoneId != null">zone_id = #{zoneId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="reservedField1 != null">reserved_field_1 = #{reservedField1},</if>
            <if test="reservedField2 != null">reserved_field_2 = #{reservedField2},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteZoneSpecialProjectReportById" parameterType="Long">
        delete
        from zone_special_project_report
        where id = #{id}
    </delete>

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