<?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.youlai.boot.system.mapper.RecordMapper">

    <!-- 获取部署记录分页列表 -->
    <select id="getRecordPage" resultType="com.youlai.boot.system.model.vo.RecordVO">
        SELECT
        t1.id,
        t1.file_name,
        t1.version,
        t1.page_type,
        t1.path,
        t1.description,
        t1.remark,
        t1.create_time,
        t1.project,
	    t1.log,
	    t1.port,
	    t1.file_type,
        t1.url,
        t2.nickname
        FROM
        deploy_record t1
        left join sys_user t2 on t1.user_id = t2.id
        <where>
            t1.is_deleted = 0
            <if test="queryParams.subIds != null and queryParams.subIds.size() > 0">
                AND folder_id IN
                <foreach collection="queryParams.subIds" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
            <if test="queryParams.pageType != null and queryParams.pageType !=''">
                and
                page_type = #{queryParams.pageType}
            </if>
            <if test="queryParams.fileName != null and queryParams.fileName !=''" >
                and
                file_name like CONCAT('%', #{queryParams.fileName}, '%')
            </if>
            <if test="queryParams.status != null and queryParams.status !=''">
                and
                t1.status = #{queryParams.status}
            </if>
            <if test="queryParams.project != null and queryParams.project !=''">
                and
                project = #{queryParams.project}
            </if>
            <if test="queryParams.version != null and queryParams.version !=''">
                and
                t1.version = #{queryParams.version}
            </if>
            <if test="queryParams.fileType != null and queryParams.fileType !=''">
                and
                t1.file_type = #{queryParams.fileType}
            </if>
            <if test="queryParams.port != null and queryParams.port !=''">
                and
                t1.port like CONCAT('%', #{queryParams.port}, '%')
            </if>
            <if test="queryParams.nickname != null and queryParams.nickname !=''">
                and
                t2.nickname  like CONCAT('%', #{queryParams.nickname}, '%')
            </if>
            <if test="queryParams.path != null and queryParams.path !=''">
                and
                t1.path like CONCAT(#{queryParams.path},SUBSTRING_INDEX(t1.file_name, '.', 1),'%' )
            </if>
        </where>
        order by create_time desc
    </select>

</mapper>
