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


    <sql id = "BaseSql">
        PPGK.POLICY_GROUP_KPI_ID,
        PPGK.POLICY_GROUP_ID,
        PPGK.KPI_TYPE,
        PPGK.KPI_PERCENT,
        PPGK.TENANT_ID,
        PPGK.ATTRIBUTE1,
        PPGK.ATTRIBUTE2,
        PPGK.ATTRIBUTE3,
        PPGK.ATTRIBUTE4,
        PPGK.ATTRIBUTE5,
        PPGK.creation_date,        PPGK.created_by,       PPGK.last_updated_by,        PPGK.last_update_date,        PPGK.object_version_number
    </sql>

    <select id = "selectList" resultType = "com.xisc.pm.domain.entity.PmPolicyGrKpi">
        select
        <include refid = "BaseSql"/>
        from PM_POLICY_GR_KPI PPGK
        <where>
            <if test="policyGroupKpiId !=null">
                and PPGK.POLICY_GROUP_KPI_ID = #{policyGroupKpiId,jdbcType = INTEGER}
            </if>
            <if test="policyGroupId !=null">
                and PPGK.POLICY_GROUP_ID = #{policyGroupId,jdbcType = INTEGER}
            </if>
            <if test="kpiType !=null">
                and PPGK.KPI_TYPE = #{kpiType,jdbcType = VARCHAR}
            </if>
            <if test="kpiPercent !=null">
                and PPGK.KPI_PERCENT = #{kpiPercent,jdbcType = INTEGER}
            </if>
            <if test="tenantId !=null">
                and PPGK.TENANT_ID = #{tenantId,jdbcType = INTEGER}
            </if>
            <if test="attribute1 !=null">
                and PPGK.ATTRIBUTE1 = #{attribute1,jdbcType = VARCHAR}
            </if>
            <if test="attribute2 !=null">
                and PPGK.ATTRIBUTE2 = #{attribute2,jdbcType = VARCHAR}
            </if>
            <if test="attribute3 !=null">
                and PPGK.ATTRIBUTE3 = #{attribute3,jdbcType = VARCHAR}
            </if>
            <if test="attribute4 !=null">
                and PPGK.ATTRIBUTE4 = #{attribute4,jdbcType = VARCHAR}
            </if>
            <if test="attribute5 !=null">
                and PPGK.ATTRIBUTE5 = #{attribute5,jdbcType = VARCHAR}
            </if>
        </where>
    </select>
</mapper>

