<?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.dgtly.companyext.mapper.CompanyExamineMapper">
    
    <resultMap type="CompanyExamine" id="CompanyExamineResult">
        <result property="id"    column="id"    />
        <result property="companyReviewedId"    column="company_reviewed_id"    />
        <result property="status"    column="status"    />
        <result property="applyDate"    column="apply_date"    />
        <result property="examineDate"    column="examine_date"    />
        <result property="rejectReason"    column="reject_reason"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCompanyExamineVo">
        select id, company_reviewed_id, status, examine_date, reject_reason, create_by, create_time, update_by, update_time, remark from company_examine
    </sql>



    <select id="selectCompanyExamineById" parameterType="Long" resultMap="CompanyExamineResult">
        <include refid="selectCompanyExamineVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCompanyExamine" parameterType="CompanyExamine" useGeneratedKeys="true" keyProperty="id">
        insert into company_examine
        <trim prefix="(" suffix=")" suffixOverrides=",">
            examine_date,
            create_time,
            <if test="companyReviewedId != null ">company_reviewed_id,</if>
            <if test="status != null ">status,</if>
            <if test="rejectReason != null  and rejectReason != ''">reject_reason,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="updateTime != null ">update_time,</if>
            <if test="remark != null  and remark != ''">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            now(),
            now(),
            <if test="companyReviewedId != null ">#{companyReviewedId},</if>
            <if test="status != null ">#{status},</if>
            <if test="rejectReason != null  and rejectReason != ''">#{rejectReason},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCompanyExamine" parameterType="CompanyExamine">
        update company_examine
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null ">status = #{status},</if>
            <if test="rejectReason != null  and rejectReason != ''">reject_reason = #{rejectReason},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            update_time = NOW(),
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCompanyExamineById" parameterType="Long">
        delete from company_examine where id = #{id}
    </delete>

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