<?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.willalp.flow.mapper.FileApprovalMapper">

    <resultMap type="com.willalp.flow.domain.FileApproval" id="FileApprovalResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="fileList" column="file_list"/>
        <result property="imgList" column="img_list"/>
        <result property="applyUserId" column="apply_user_id"/>
        <result property="applyUserName" column="apply_user_name"/>
        <result property="endTime" column="end_time"/>
        <result property="isDelete" column="is_delete"/>
        <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="selectFileApprovalVo">
        select id,
               title,
               file_list,
               img_list,
               apply_user_id,
               apply_user_name,
               end_time,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from file_approval
    </sql>

    <select id="selectFileApprovalList" parameterType="FileApproval" resultMap="FileApprovalResult">
        <include refid="selectFileApprovalVo"/>
        <where>
            is_delete = 0
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="fileList != null  and fileList != ''">
                and file_list = #{fileList}
            </if>
            <if test="imgList != null  and imgList != ''">
                and img_list = #{imgList}
            </if>
            <if test="applyUserId != null  and applyUserId != ''">
                and apply_user_id = #{applyUserId}
            </if>
            <if test="applyUserName != null  and applyUserName != ''">
                and apply_user_name like concat('%', #{applyUserName}, '%')
            </if>
            <if test="endTime != null ">
                and end_time = #{endTime}
            </if>
            <if test="isDelete != null ">
                and is_delete = #{isDelete}
            </if>
        </where>
        order by create_time desc
    </select>
</mapper>
