<?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.yonge.cooleshow.biz.dal.dao.PianoRoomSettingsDao">
	<resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.PianoRoomSettings">
            <result column="id_" property="id" />
	        <result column="times_" property="times" />
	        <result column="sale_price_" property="salePrice" />
	        <result column="original_price_" property="originalPrice" />
	        <result column="description_" property="description" />
            <result column="status_" property="status" />
	        <result column="create_by_" property="createBy" />
	        <result column="create_time_" property="createTime" />
	        <result column="update_by_" property="updateBy" />
	        <result column="update_time_" property="updateTime" />
	        <result column="cover_url_" property="coverUrl" />
		</resultMap>
    
    <!-- 表字段 -->
    <sql id="baseColumns">
         t.id_ as id
        , t.times_ as times
        , t.sale_price_ as salePrice
        , t.original_price_ as originalPrice
        , t.description_ as description
        , t.status_ as status
        , t.create_by_ as createBy
        , t.create_time_ as createTime
        , t.update_by_ as updateBy
        , t.update_time_ as updateTime
        , t.cover_url_ as coverUrl
        </sql>

    <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.PianoRoomSettingsVo">
        SELECT
            <include refid="baseColumns"/>,
            ifnull(u.real_name_,u.username_) modifierName
        FROM piano_room_settings t
        LEFT JOIN sys_user u on t.update_by_ = u.id_
        where t.del_flag_ = 0 and t.id_ = #{id}
    </select>

    <sql id="selectSql">
        SELECT
            <include refid="baseColumns" />,
            ifnull(u.real_name_,u.username_) modifierName
        FROM piano_room_settings t
        LEFT JOIN sys_user u on t.update_by_ = u.id_
        where t.del_flag_ = 0
        <if test="param.status != null">
            and t.status_ = #{param.status}
        </if>
    </sql>

    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.PianoRoomSettingsVo">
        <include refid="selectSql"/>
    </select>

    <select id="selectList" resultType="com.yonge.cooleshow.biz.dal.vo.PianoRoomSettingsVo">
        <include refid="selectSql"/>
    </select>

    <update id="changeStatus">
        update piano_room_settings set status_ = #{status} where id_ = #{id}
    </update>

    <update id="removeByIds">
        UPDATE piano_room_settings SET del_flag_ = 1 WHERE id_ IN
        <foreach collection="idList" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
    </update>
</mapper>