<?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.ruoyi.interfaces.mapper.PtReportDAO">
    <resultMap id="BaseResultMap" type="com.ruoyi.interfaces.domain.PtReport">
        <id column="CODE" jdbcType="VARCHAR" property="code"/>
        <result column="TITLE" jdbcType="VARCHAR" property="title"/>
        <result column="CATE" jdbcType="VARCHAR" property="cate"/>
        <result column="URL" jdbcType="VARCHAR" property="url"/>
        <result column="NOTE" jdbcType="VARCHAR" property="note"/>
        <result column="STATUS" jdbcType="VARCHAR" property="status"/>
        <result column="SUPPLY" jdbcType="VARCHAR" property="supply"/>
        <result column="PUB_USER" jdbcType="VARCHAR" property="pubUser"/>
        <result column="PUB_TIME" jdbcType="TIMESTAMP" property="pubTime"/>

        <result column="TYPE" jdbcType="VARCHAR" property="type"/>
        <result column="DATABASE" jdbcType="VARCHAR" property="database"/>
        <result column="SQL" jdbcType="VARCHAR" property="sql"/>
        <result column="LIST_SQL" jdbcType="TIMESTAMP" property="listSql"/>
        <result column="STYLE" jdbcType="TIMESTAMP" property="style"/>

        <result column="FILE_ID" property="fileId"/>
        <result column="FILE_PATH" property="filePath"/>
        <result column="FILE_VIEWNAME" property="fileViewname"/>

        <!-- private String fileId;

private String filePath;

private String fileSavename;-->
    </resultMap>

    <sql id="Base_Column_List">
        CODE
        , TITLE, CATE, URL, NOTE, STATUS, SUPPLY, PUB_USER, PUB_TIME , TYPE  , DATABASE , SQL  , LIST_SQL , STYLE
    </sql>

    <insert id="insert" parameterType="com.ruoyi.interfaces.domain.PtReport">
        INSERT INTO PT_REPORT(CODE, TITLE, CATE, URL, NOTE, STATUS, SUPPLY, PUB_USER, PUB_TIME, TYPE, DATABASE, SQL,
                              LIST_SQL, STYLE)
        VALUES (#{code}, #{title}, #{cate}, #{url}, #{note}, #{status}, #{supply}, #{pubUser}, #{pubTime},
                #{type}, #{database}, #{sql}, #{listSql}, #{style})
    </insert>

    <select id="selectAll" parameterType="com.ruoyi.interfaces.domain.PtReport" resultMap="BaseResultMap">
        select
        r.CODE, r.TITLE, r.CATE, r.URL, r.NOTE, r.STATUS, r.SUPPLY, r.PUB_USER, r.PUB_TIME,
        f.FILE_ID , f.FILE_PATH , f.FILE_VIEWNAME , r.TYPE , r.DATABASE , r.SQL , r.LIST_SQL , r.STYLE
        from PT_REPORT r left join PT_REPORT_FILE f on r.CODE = f.CODE
        <where>
            <if test="code != null and code != ''">
                and r.CODE = #{code}
            </if>
            <if test="cate != null and cate != ''">
                and r.CATE = #{cate}
            </if>
        </where>
    </select>

    <update id="update" parameterType="com.ruoyi.interfaces.domain.PtReport">
        update PT_REPORT
        set TITLE    =#{title},
            CATE     = #{cate},
            URL      = #{url},
            NOTE     = #{note},
            STATUS   = #{status},
            SUPPLY   = #{supply},
            PUB_USER = #{pubUser},
            PUB_TIME = #{pubTime},
            TYPE     = #{type},
            DATABASE = #{database},
            SQL      = #{sql},
            LIST_SQL = #{listSql},
            STYLE    = #{style}
        where CODE = #{code}
    </update>

    <delete id="delete" parameterType="com.ruoyi.interfaces.domain.PtReport">
        delete
        from PT_REPORT
        where code = #{code}
    </delete>
</mapper>
