<?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.xisc.pm.infra.mapper.PmSubLogMapper">


    <sql id = "BaseSql">
    PSL.ID,
    PSL.SUB_DATE,
    PSL.SLAB_NO,
    PSL.SUB_MODE,
    PSL.SUB_RSLT,
    PSL.SUB_LOG,
    PSL.TENANT_ID,
    PSL.ATTRIBUTE1,
    PSL.ATTRIBUTE2,
    PSL.ATTRIBUTE3,
    PSL.ATTRIBUTE4,
    PSL.ATTRIBUTE5,
    PSL.creation_date,    PSL.created_by,    PSL.last_updated_by,    PSL.last_update_date,    PSL.object_version_number
    </sql>

    <select id = "selectList" parameterType="com.xisc.pm.api.dto.PmSubLogRequestDTO" resultType = "com.xisc.pm.domain.entity.PmSubLog">
        select
        <include refid = "BaseSql"/>
        from PM_SUB_LOG PSL
        <where>
            <if test="id !=null">
                and PSL.ID = #{id,jdbcType = INTEGER}
            </if>
            <if test="slabNo !=null">
                and PSL.SLAB_NO like concat(concat('%',#{slabNo}), '%')
            </if>
            <if test="subDateFrom !=null">
                and PSL.SUB_DATE <![CDATA[ >= ]]> #{subDateFrom}
            </if>
            <if test="subDateTo !=null">
                and PSL.SUB_DATE <![CDATA[ <= ]]> #{subDateTo}
            </if>
            <if test="tenantId !=null">
                and PSL.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
        </where>
    </select>
</mapper>

