<?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.amms.mapper.MuseumIntroMapper">

    <resultMap type="com.amms.domain.MuseumIntro" id="MuseumIntroResult">
        <result property="museumName"    column="museum_name"    />
        <result property="content"    column="content"    />
        <result property="logoUrl"    column="logo_url"    />
        <result property="address"    column="address"    />
        <result property="phone"    column="phone"    />
        <result property="openTime"    column="open_time"    />
        <result property="closeTime"    column="close_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
    </resultMap>

    <sql id="selectMuseumIntroVo">
        select museum_name, content, logo_url, address, phone, open_time, close_time, update_time, updater from museum_intro
    </sql>

    <select id="selectMuseumIntroList" parameterType="com.amms.domain.MuseumIntro" resultMap="MuseumIntroResult">
        <include refid="selectMuseumIntroVo"/>
        <where>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="logoUrl != null  and logoUrl != ''"> and logo_url = #{logoUrl}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="openTime != null "> and open_time = #{openTime}</if>
            <if test="closeTime != null "> and close_time = #{closeTime}</if>
            <if test="updater != null "> and updater = #{updater}</if>
        </where>
    </select>

    <select id="selectMuseumIntroByMuseumName" parameterType="String" resultMap="MuseumIntroResult">
        <include refid="selectMuseumIntroVo"/>
        where museum_name = #{museumName}
    </select>

    <insert id="insertMuseumIntro" parameterType="com.amms.domain.MuseumIntro">
        insert into museum_intro
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="museumName != null">museum_name,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="logoUrl != null">logo_url,</if>
            <if test="address != null">address,</if>
            <if test="phone != null">phone,</if>
            <if test="openTime != null">open_time,</if>
            <if test="closeTime != null">close_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="museumName != null">#{museumName},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="logoUrl != null">#{logoUrl},</if>
            <if test="address != null">#{address},</if>
            <if test="phone != null">#{phone},</if>
            <if test="openTime != null">#{openTime},</if>
            <if test="closeTime != null">#{closeTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
         </trim>
    </insert>

    <update id="updateMuseumIntro" parameterType="com.amms.domain.MuseumIntro">
        update museum_intro
        <trim prefix="SET" suffixOverrides=",">
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="logoUrl != null">logo_url = #{logoUrl},</if>
            <if test="address != null">address = #{address},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="openTime != null">open_time = #{openTime},</if>
            <if test="closeTime != null">close_time = #{closeTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
        </trim>
        where museum_name = #{museumName}
    </update>

    <delete id="deleteMuseumIntroByMuseumName" parameterType="String">
        delete from museum_intro where museum_name = #{museumName}
    </delete>
</mapper>
