<?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.ZoneSpecialProjectRelevancyMapper">

    <resultMap type="ZoneSpecialProjectRelevancy" id="ZoneSpecialProjectRelevancyResult">
        <result property="id" column="id"/>
        <result property="type" column="type"/>
        <result property="author" column="author"/>
        <result property="relevancyId" column="relevancy_id"/>
        <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="company" column="company"/>
    </resultMap>

    <sql id="selectZoneSpecialProjectRelevancyVo">
        select id,
               type,
               author,
               relevancy_id,
               special_project_id,
               sort,
               zone_id,
               dept_id,
               del_flag,
               create_by,
               create_time,
               update_by,
               update_time,
               reserved_field_1,
               company
        from zone_special_project_relevancy
    </sql>

    <select id="selectZoneSpecialProjectRelevancyList" parameterType="ZoneSpecialProjectRelevancy"
            resultMap="ZoneSpecialProjectRelevancyResult">
        <include refid="selectZoneSpecialProjectRelevancyVo"/>
        <where>
            <if test="type != null  and type != ''">and type = #{type}</if>
            <if test="author != null  and author != ''">and author = #{author}</if>
            <if test="relevancyId != null  and relevancyId != ''">and relevancy_id = #{relevancyId}</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="company != null  and company != ''">and company = #{company}</if>
        </where>
        ORDER BY sort ASC
    </select>

    <select id="selectZoneSpecialProjectRelevancyById" parameterType="Long"
            resultMap="ZoneSpecialProjectRelevancyResult">
        <include refid="selectZoneSpecialProjectRelevancyVo"/>
        where id = #{id}
    </select>

    <insert id="insertZoneSpecialProjectRelevancy" parameterType="ZoneSpecialProjectRelevancy" useGeneratedKeys="true"
            keyProperty="id">
        insert into zone_special_project_relevancy
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">type,</if>
            <if test="author != null">author,</if>
            <if test="relevancyId != null">relevancy_id,</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="company != null">company,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">#{type},</if>
            <if test="author != null">#{author},</if>
            <if test="relevancyId != null">#{relevancyId},</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="company != null">#{company},</if>
        </trim>
    </insert>

    <update id="updateZoneSpecialProjectRelevancy" parameterType="ZoneSpecialProjectRelevancy">
        update zone_special_project_relevancy
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="author != null">author = #{author},</if>
            <if test="relevancyId != null">relevancy_id = #{relevancyId},</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="company != null">company = #{company},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteZoneSpecialProjectRelevancyById" parameterType="Long">
        delete
        from zone_special_project_relevancy
        where id = #{id}
    </delete>

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