<?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.nantian.cloud.jljc.mapper.TPolicyMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.TPolicy">
        <id column="id" property="id" />
        <result column="userid" property="userid" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="dept_id" property="deptId" />
        <result column="policy_title" property="policyTitle" />
        <result column="creat_time" property="creatTime" />
        <result column="publisher" property="publisher" />
        <result column="issued" property="issued" />
        <result column="user_dept" property="userDept" />
        <result column="policy_content" property="policyContent" />
        <result column="file_url" property="fileUrl" />
        <result column="file_name" property="fileName" />
        <result column="keyword" property="keyword" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, userid, update_time, del_flag, dept_id, policy_title, creat_time, publisher,keyword, issued, user_dept, policy_content, file_url, file_name
    </sql>

    <select id="getPageGov" resultType="com.nantian.cloud.jljc.entity.TPolicy">
        select <include refid="Base_Column_List"></include>
        from t_policy
        where del_flag = "1"
        <if test="query.userDept != null and query.userDept != '' and query.userDept != '0'.toString()">
            and user_dept = #{query.userDept}
        </if>
        <if test="query.policyTitle != null and query.policyTitle != ''">
            and policy_title like concat("%",#{query.policyTitle},"%")
        </if>
        <if test="query.publisher != null and query.publisher != ''">
            and publisher like concat("%",#{query.publisher},"%")
        </if>
        <if test="query.issued != null and query.issued != ''">
            and issued like concat("%",#{query.issued},"%")
        </if>
        <if test="query.fileName != null and query.fileName != ''">
            and file_name like concat("%",#{query.fileName},"%")
        </if>
        order by creat_time desc
    </select>

    <select id="getPageCmp" resultType="com.nantian.cloud.jljc.entity.TPolicy">
        select <include refid="Base_Column_List"></include>
        from t_policy
        where del_flag = "1"
        <if test="query.policyTitle != null and query.policyTitle != ''">
            and policy_title like concat("%",#{query.policyTitle},"%")
        </if>
        <if test="query.publisher != null and query.publisher != ''">
            and publisher like concat("%",#{query.publisher},"%")
        </if>
        <if test="query.issued != null and query.issued != ''">
            and issued like concat("%",#{query.issued},"%")
        </if>
        <if test="query.fileName != null and query.fileName != ''">
            and file_name like concat("%",#{query.fileName},"%")
        </if>
        order by creat_time desc
    </select>

</mapper>
