<?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.energy.manage.service.mappers.analysis.AnalysisOptionRecordsMapper">
    <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysis.AnalysisOptionRecordsPo">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="option_content" property="optionContent" jdbcType="VARCHAR"/>
        <result column="option_by" property="optionBy" jdbcType="INTEGER"/>
        <result column="option_by_name" property="optionByName" jdbcType="VARCHAR"/>
        <result column="field_code" property="fieldCode" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <select id="selectAllByTimeDesc" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisOptionRecordsVo">
        select
               option_by_name,
               option_content,
               create_time
        from analysis_option_records
        where field_code in
        <foreach collection="fieldCodes" item="fieldCode" separator="," open="(" close=")">
            #{fieldCode,jdbcType=VARCHAR}
        </foreach>
        <if test="startTime != null and startTime != ''">
            and create_time &gt;= #{startTime,jdbcType=VARCHAR}
        </if>
        <if test="endTime != null and endTime != ''">
            and create_time &lt;= #{endTime,jdbcType=VARCHAR}
        </if>
        order by create_time desc
    </select>
</mapper>
