<?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.PmPolicyKpiMapper">


    <sql id = "BaseSql">
    PPK.POLICY_KPI_ID,
    PPK.POLICY_ID,
    PPK.KPI_TYPE,
    PPK.KPI_RESTRICTION,
    PPK.KPI_LIMIT_PARAMETERS,
    PPK.KPI_PERCENT,
    PPK.TENANT_ID,
    PPK.ATTRIBUTE1,
    PPK.ATTRIBUTE2,
    PPK.ATTRIBUTE3,
    PPK.ATTRIBUTE4,
    PPK.ATTRIBUTE5,
    PPK.creation_date,    PPK.created_by,    PPK.last_updated_by,    PPK.last_update_date,    PPK.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmPolicyKpi">
        select
        <include refid = "BaseSql"/>
        from PM_POLICY_KPI PPK
        <where>
            <if test="policyKpiId !=null">
                and PPK.POLICY_KPI_ID = #{policyKpiId,jdbcType = INTEGER}
            </if>
            <if test="policyId !=null">
                and PPK.POLICY_ID = #{policyId,jdbcType = INTEGER}
            </if>
            <if test="kpiType !=null">
                and PPK.KPI_TYPE = #{kpiType,jdbcType = VARCHAR}
            </if>
            <if test="kpiRestriction !=null">
                and PPK.KPI_RESTRICTION = #{kpiRestriction,jdbcType = VARCHAR}
            </if>
            <if test="kpiLimitParameters !=null">
                and PPK.KPI_LIMIT_PARAMETERS = #{kpiLimitParameters,jdbcType = INTEGER}
            </if>
            <if test="kpiPercent !=null">
                and PPK.KPI_PERCENT = #{kpiPercent,jdbcType = INTEGER}
            </if>
            <if test="tenantId !=null">
                and PPK.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PPK.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PPK.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PPK.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PPK.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PPK.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>
</mapper>

