<?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.njcn.gather.tool.parsepqdif.mapper.CsPqdifPathMapper">

    <resultMap id="CsPqdifPathVOResultMap"
               type="com.njcn.gather.tool.parsepqdif.pojo.vo.CsPqdifPathVO">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="filePath" property="filePath"/>
        <result column="recordCount" property="recordCount"/>
        <result column="observationCount" property="observationCount"/>
        <result column="sampleValueCount" property="sampleValueCount"/>
        <result column="state" property="state"/>
        <result column="result" property="result"/>
        <result column="msg" property="msg"
                typeHandler="com.njcn.gather.tool.parsepqdif.typehandler.JsonNodeTypeHandler"/>
        <result column="createBy" property="createBy"/>
        <result column="createTime" property="createTime"/>
        <result column="updateBy" property="updateBy"/>
        <result column="updateTime" property="updateTime"/>
    </resultMap>

    <select id="selectPqdifPathList"
            resultMap="CsPqdifPathVOResultMap">
        SELECT
            ID AS id,
            Name AS name,
            File_Path AS filePath,
            Record_Count AS recordCount,
            Observation_Count AS observationCount,
            Sample_Value_Count AS sampleValueCount,
            State AS state,
            Result AS result,
            Create_By AS createBy,
            Create_Time AS createTime,
            Update_By AS updateBy,
            Update_Time AS updateTime
        FROM cs_pqdif_path
        WHERE State = 1
        <if test="keyword != null and keyword != ''">
            AND Name LIKE CONCAT('%', #{keyword}, '%')
        </if>
        <if test="result != null">
            AND Result = #{result}
        </if>
        ORDER BY Update_Time DESC, Create_Time DESC
    </select>

    <select id="selectPqdifParseMsgById"
            resultMap="CsPqdifPathVOResultMap">
        SELECT Msg AS msg
        FROM cs_pqdif_path
        WHERE ID = #{id}
          AND State = 1
    </select>

    <select id="selectPqdifPathDetailById"
            resultType="com.njcn.gather.tool.parsepqdif.pojo.vo.CsPqdifPathDetailVO">
        SELECT
            ID AS id,
            Name AS name,
            File_Path AS filePath
        FROM cs_pqdif_path
        WHERE ID = #{id}
          AND State = 1
    </select>

</mapper>
