<?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.yinet.review.mapper.FormReviewMapper">
    
    <resultMap type="FormReview" id="FormReviewResult">
        <result property="id"    column="ID"    />
        <result property="number"    column="Number"    />
        <result property="projectname"    column="ProjectName"    />
        <result property="projectcontent"    column="ProjectContent"    />
        <result property="entrustdate"    column="EntrustDate"    />
        <result property="limitdate"    column="LimitDate"    />
        <result property="category"    column="Category"    />
        <result property="entrustmoney"    column="EntrustMoney"    />
        <result property="reviewmoney"    column="ReviewMoney"    />
        <result property="reviewapprovalmoney"    column="ReviewApprovalMoney"    />
        <result property="reviewrate"    column="ReviewRate"    />
        <result property="projecthead"    column="ProjectHead"    />
        <result property="projectunit"    column="ProjectUnit"    />
        <result property="lianxiren"    column="LianXiRen"    />
        <result property="phone"    column="Phone"    />
        <result property="mediationname"    column="MediationName"    />
        <result property="mediationphone"    column="MediationPhone"    />
        <result property="addtime"    column="AddTime"    />
        <result property="adduserid"    column="AddUserId"    />
        <result property="addname"    column="AddName"    />
        <result property="modifytime"    column="ModifyTime"    />
        <result property="modifyuserid"    column="ModifyUserId"    />
        <result property="modifyname"    column="ModifyName"    />
        <result property="deleteproject"    column="DeleteProject"    />
        <result property="deletedate"    column="DeleteDate"    />
        <result property="deletecontent"    column="DeleteContent"    />
        <result property="deleteuserid"    column="DeleteUserId"    />
        <result property="deletename"    column="DeleteName"    />
    </resultMap>

    <sql id="selectFormReviewVo">
        select ID, Number, ProjectName, ProjectContent, EntrustDate, LimitDate, Category, EntrustMoney, ReviewMoney, ReviewApprovalMoney, ReviewRate, ProjectHead, ProjectUnit, LianXiRen, Phone, MediationName, MediationPhone, AddTime, AddUserId, AddName, ModifyTime, ModifyUserId, ModifyName, DeleteProject, DeleteDate, DeleteContent, DeleteUserId, DeleteName from form_review
    </sql>

    <select id="selectFormReviewList" parameterType="FormReview" resultMap="FormReviewResult">
        <include refid="selectFormReviewVo"/>
        <where>  
            <if test="number != null "> and Number = #{number}</if>
            <if test="projectname != null  and projectname != ''"> and ProjectName like concat('%', #{projectname}, '%')</if>
            <if test="projectcontent != null  and projectcontent != ''"> and ProjectContent = #{projectcontent}</if>
            <if test="entrustdate != null "> and EntrustDate = #{entrustdate}</if>
            <if test="limitdate != null  and limitdate != ''"> and LimitDate = #{limitdate}</if>
            <if test="category != null  and category != ''"> and Category = #{category}</if>
            <if test="entrustmoney != null  and entrustmoney != ''"> and EntrustMoney = #{entrustmoney}</if>
            <if test="reviewmoney != null  and reviewmoney != ''"> and ReviewMoney = #{reviewmoney}</if>
            <if test="reviewapprovalmoney != null  and reviewapprovalmoney != ''"> and ReviewApprovalMoney = #{reviewapprovalmoney}</if>
            <if test="reviewrate != null  and reviewrate != ''"> and ReviewRate = #{reviewrate}</if>
            <if test="projecthead != null  and projecthead != ''"> and ProjectHead = #{projecthead}</if>
            <if test="projectunit != null  and projectunit != ''"> and ProjectUnit = #{projectunit}</if>
            <if test="lianxiren != null  and lianxiren != ''"> and LianXiRen = #{lianxiren}</if>
            <if test="phone != null  and phone != ''"> and Phone = #{phone}</if>
            <if test="mediationname != null  and mediationname != ''"> and MediationName like concat('%', #{mediationname}, '%')</if>
            <if test="mediationphone != null  and mediationphone != ''"> and MediationPhone = #{mediationphone}</if>
            <if test="addtime != null "> and AddTime = #{addtime}</if>
            <if test="adduserid != null "> and AddUserId = #{adduserid}</if>
            <if test="addname != null  and addname != ''"> and AddName like concat('%', #{addname}, '%')</if>
            <if test="modifytime != null "> and ModifyTime = #{modifytime}</if>
            <if test="modifyuserid != null "> and ModifyUserId = #{modifyuserid}</if>
            <if test="modifyname != null  and modifyname != ''"> and ModifyName like concat('%', #{modifyname}, '%')</if>
            <if test="deleteproject != null  and deleteproject != ''"> and DeleteProject = #{deleteproject}</if>
            <if test="deletedate != null "> and DeleteDate = #{deletedate}</if>
            <if test="deletecontent != null  and deletecontent != ''"> and DeleteContent = #{deletecontent}</if>
            <if test="deleteuserid != null "> and DeleteUserId = #{deleteuserid}</if>
            <if test="deletename != null  and deletename != ''"> and DeleteName like concat('%', #{deletename}, '%')</if>
        </where>
    </select>
    
    <select id="selectFormReviewById" parameterType="Long" resultMap="FormReviewResult">
        <include refid="selectFormReviewVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertFormReview" parameterType="FormReview" useGeneratedKeys="true" keyProperty="id">
        insert into form_review
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="number != null ">Number,</if>
            <if test="projectname != null  and projectname != ''">ProjectName,</if>
            <if test="projectcontent != null  and projectcontent != ''">ProjectContent,</if>
            <if test="entrustdate != null ">EntrustDate,</if>
            <if test="limitdate != null  and limitdate != ''">LimitDate,</if>
            <if test="category != null  and category != ''">Category,</if>
            <if test="entrustmoney != null  and entrustmoney != ''">EntrustMoney,</if>
            <if test="reviewmoney != null  and reviewmoney != ''">ReviewMoney,</if>
            <if test="reviewapprovalmoney != null  and reviewapprovalmoney != ''">ReviewApprovalMoney,</if>
            <if test="reviewrate != null  and reviewrate != ''">ReviewRate,</if>
            <if test="projecthead != null  and projecthead != ''">ProjectHead,</if>
            <if test="projectunit != null  and projectunit != ''">ProjectUnit,</if>
            <if test="lianxiren != null  and lianxiren != ''">LianXiRen,</if>
            <if test="phone != null  and phone != ''">Phone,</if>
            <if test="mediationname != null  and mediationname != ''">MediationName,</if>
            <if test="mediationphone != null  and mediationphone != ''">MediationPhone,</if>
<!--            <if test="addtime != null ">AddTime,</if>-->
            <if test="adduserid != null ">AddUserId,</if>
            <if test="addname != null  and addname != ''">AddName,</if>
            <if test="modifytime != null ">ModifyTime,</if>
            <if test="modifyuserid != null ">ModifyUserId,</if>
            <if test="modifyname != null  and modifyname != ''">ModifyName,</if>
            <if test="deleteproject != null  and deleteproject != ''">DeleteProject,</if>
            <if test="deletedate != null ">DeleteDate,</if>
            <if test="deletecontent != null  and deletecontent != ''">DeleteContent,</if>
            <if test="deleteuserid != null ">DeleteUserId,</if>
            <if test="deletename != null  and deletename != ''">DeleteName,</if>
            addtime
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="number != null ">#{number},</if>
            <if test="projectname != null  and projectname != ''">#{projectname},</if>
            <if test="projectcontent != null  and projectcontent != ''">#{projectcontent},</if>
            <if test="entrustdate != null ">#{entrustdate},</if>
            <if test="limitdate != null  and limitdate != ''">#{limitdate},</if>
            <if test="category != null  and category != ''">#{category},</if>
            <if test="entrustmoney != null  and entrustmoney != ''">#{entrustmoney},</if>
            <if test="reviewmoney != null  and reviewmoney != ''">#{reviewmoney},</if>
            <if test="reviewapprovalmoney != null  and reviewapprovalmoney != ''">#{reviewapprovalmoney},</if>
            <if test="reviewrate != null  and reviewrate != ''">#{reviewrate},</if>
            <if test="projecthead != null  and projecthead != ''">#{projecthead},</if>
            <if test="projectunit != null  and projectunit != ''">#{projectunit},</if>
            <if test="lianxiren != null  and lianxiren != ''">#{lianxiren},</if>
            <if test="phone != null  and phone != ''">#{phone},</if>
            <if test="mediationname != null  and mediationname != ''">#{mediationname},</if>
            <if test="mediationphone != null  and mediationphone != ''">#{mediationphone},</if>
<!--            <if test="addtime != null ">#{addtime},</if>-->
            <if test="adduserid != null ">#{adduserid},</if>
            <if test="addname != null  and addname != ''">#{addname},</if>
            <if test="modifytime != null ">#{modifytime},</if>
            <if test="modifyuserid != null ">#{modifyuserid},</if>
            <if test="modifyname != null  and modifyname != ''">#{modifyname},</if>
            <if test="deleteproject != null  and deleteproject != ''">#{deleteproject},</if>
            <if test="deletedate != null ">#{deletedate},</if>
            <if test="deletecontent != null  and deletecontent != ''">#{deletecontent},</if>
            <if test="deleteuserid != null ">#{deleteuserid},</if>
            <if test="deletename != null  and deletename != ''">#{deletename},</if>
            sysDate()
         </trim>
    </insert>

    <update id="updateFormReview" parameterType="FormReview">
        update form_review
        <trim prefix="SET" suffixOverrides=",">
            <if test="number != null ">Number = #{number},</if>
            <if test="projectname != null  and projectname != ''">ProjectName = #{projectname},</if>
            <if test="projectcontent != null  and projectcontent != ''">ProjectContent = #{projectcontent},</if>
            <if test="entrustdate != null ">EntrustDate = #{entrustdate},</if>
            <if test="limitdate != null  and limitdate != ''">LimitDate = #{limitdate},</if>
            <if test="category != null  and category != ''">Category = #{category},</if>
            <if test="entrustmoney != null  and entrustmoney != ''">EntrustMoney = #{entrustmoney},</if>
            <if test="reviewmoney != null  and reviewmoney != ''">ReviewMoney = #{reviewmoney},</if>
            <if test="reviewapprovalmoney != null  and reviewapprovalmoney != ''">ReviewApprovalMoney = #{reviewapprovalmoney},</if>
            <if test="reviewrate != null  and reviewrate != ''">ReviewRate = #{reviewrate},</if>
            <if test="projecthead != null  and projecthead != ''">ProjectHead = #{projecthead},</if>
            <if test="projectunit != null  and projectunit != ''">ProjectUnit = #{projectunit},</if>
            <if test="lianxiren != null  and lianxiren != ''">LianXiRen = #{lianxiren},</if>
            <if test="phone != null  and phone != ''">Phone = #{phone},</if>
            <if test="mediationname != null  and mediationname != ''">MediationName = #{mediationname},</if>
            <if test="mediationphone != null  and mediationphone != ''">MediationPhone = #{mediationphone},</if>
            <if test="addtime != null ">AddTime = #{addtime},</if>
            <if test="adduserid != null ">AddUserId = #{adduserid},</if>
            <if test="addname != null  and addname != ''">AddName = #{addname},</if>
<!--            <if test="modifytime != null ">ModifyTime = #{modifytime},</if>-->
            <if test="modifyuserid != null ">ModifyUserId = #{modifyuserid},</if>
            <if test="modifyname != null  and modifyname != ''">ModifyName = #{modifyname},</if>
            <if test="deleteproject != null  and deleteproject != ''">DeleteProject = #{deleteproject},</if>
            <if test="deletedate != null ">DeleteDate = #{deletedate},</if>
            <if test="deletecontent != null  and deletecontent != ''">DeleteContent = #{deletecontent},</if>
            <if test="deleteuserid != null ">DeleteUserId = #{deleteuserid},</if>
            <if test="deletename != null  and deletename != ''">DeleteName = #{deletename},</if>
            modifytime=sysDate(),
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteFormReviewById" parameterType="Long">
        delete from form_review where ID = #{id}
    </delete>

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


    
</mapper>