<?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.pm.subsystem.mapper.IbmsBroadcastContentMapper">

    <resultMap type="pd" id="IbmsBroadcastContentResult">
        <result property="id"    column="id"    />
        <result property="contentCode"    column="content_code"    />
        <result property="contentName"    column="content_name"    />
        <result property="contentType"    column="content_type"    />
        <result property="filePath"    column="file_path"    />
        <result property="duration"    column="duration"    />
        <result property="priority"    column="priority"    />
        <result property="isLoop"    column="is_loop"    />
        <result property="description"    column="description"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectIbmsBroadcastContentVo">
        select id, content_code, content_name, content_type, file_path, duration,
        priority, is_loop, description, create_time
        from ibms_broadcast_content
    </sql>

    <select id="selectIbmsBroadcastContentList" parameterType="pd" resultMap="IbmsBroadcastContentResult">
        <include refid="selectIbmsBroadcastContentVo"/>
        <where>
            <if test="contentType != null and contentType != ''">
                and content_type in
                <foreach item="type" collection="contentType.split(',')" open="(" separator="," close=")">
                    #{type}
                </foreach>
            </if>
            <if test="contentName != null and contentName != ''">
                and content_name like concat('%', #{contentName}, '%')
            </if>
        </where>
        order by content_type, priority desc, content_code
    </select>

</mapper>