<?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.yifu.cloud.plus.v1.business.mapper.TPolicyMapper">
    <resultMap id="tPolicyMap" type="com.yifu.cloud.plus.v1.business.entity.TPolicy">
        <id property="id" column="ID"/>
        <result property="title" column="TITLE"/>
        <result property="content" column="CONTENT"/>
        <result property="province" column="PROVINCE"/>
        <result property="city" column="CITY"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="readings" column="READINGS"/>
    </resultMap>
    <sql id="Base_Column_List">
             a.ID,
                  a.TITLE,
                  a.CONTENT,
                  a.PROVINCE,
                  a.CITY,
                  a.CREATE_USER,
                  a.CREATE_TIME,
                  a.READINGS
         </sql>
    <sql id="tPolicy_where">
        <if test="tPolicy != null">
            <if test="tPolicy.id != null and tPolicy.id.trim() != ''">
                AND a.ID = #{tPolicy.id}
            </if>
            <if test="tPolicy.title != null and tPolicy.title.trim() != ''">
                AND a.TITLE = #{tPolicy.title}
            </if>
            <if test="tPolicy.content != null and tPolicy.content.trim() != ''">
                AND a.CONTENT = #{tPolicy.content}
            </if>
            <if test="tPolicy.province != null">
                AND a.PROVINCE = #{tPolicy.province}
            </if>
            <if test="tPolicy.city != null and tPolicy.city.trim() != ''">
                AND a.CITY like '%${tPolicy.city}%'
            </if>
            <if test="tPolicy.createUser != null and tPolicy.createUser.trim() != ''">
                AND a.CREATE_USER = #{tPolicy.createUser}
            </if>
            <if test="tPolicy.createTime != null">
                AND a.CREATE_TIME = #{tPolicy.createTime}
            </if>
        </if>
    </sql>
    <!--tPolicy简单分页查询-->
    <select id="getTPolicyPage" resultMap="tPolicyMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_policy a
        <where>
            1=1
            <include refid="tPolicy_where"/>
        </where>
    </select>
</mapper>
