<?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.ics.admin.mapper.PolicyMapper">

    <resultMap type="com.ics.admin.domain.Policy" id="PolicyResult">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="content" column="content"/>
        <result property="isMarketable" column="is_marketable"/>
        <result property="marketableTime" column="marketable_time"/>
        <result property="version" column="version"/>
        <result property="deleteFlag" column="delete_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="parkId" column="park_id"/>

    </resultMap>

    <sql id="selectPolicyVo">
        SELECT policy.id,
               policy.name,
               policy.content,
               policy.is_marketable,
               policy.marketable_time,
               policy.version,
               policy.delete_flag,
               policy.create_by,
               policy.create_time,
               policy.update_by,
               policy.update_time,
               policy.tenant_id,
               policy.park_id
        FROM ics_policy policy
    </sql>

    <select id="selectPolicyAppList" parameterType="Policy" resultMap="PolicyResult">
        <include refid="selectPolicyVo"/>
        <where>
            <if test="isMarketable != null">and policy.is_marketable = #{isMarketable}</if>
            and policy.delete_flag = 0
        </where>
    </select>

</mapper>