<?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.da.dangan.mapper.DaUserCatalogMapper">
    
    <resultMap type="DaUserCatalog" id="DaUserCatalogResult">
        <result property="userId"    column="user_id"    />
        <result property="muId"    column="mu_id"    />
    </resultMap>

    <sql id="selectDaUserCatalogVo">
        select user_id, mu_id from da_user_catalog
    </sql>

    <select id="selectDaUserCatalogList" parameterType="DaUserCatalog" resultMap="DaUserCatalogResult">
        <include refid="selectDaUserCatalogVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectDaUserCatalogByUserId" parameterType="Long" resultMap="DaUserCatalogResult">
        <include refid="selectDaUserCatalogVo"/>
        where user_id = #{userId}
    </select>
        
    <insert id="insertDaUserCatalog" parameterType="DaUserCatalog">
        insert into da_user_catalog
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="muId != null">mu_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="muId != null">#{muId},</if>
         </trim>
    </insert>

    <update id="updateDaUserCatalog" parameterType="DaUserCatalog">
        update da_user_catalog
        <trim prefix="SET" suffixOverrides=",">
            <if test="muId != null">mu_id = #{muId},</if>
        </trim>
        where user_id = #{userId}
    </update>

    <delete id="deleteDaUserCatalogByUserId" parameterType="Long">
        delete from da_user_catalog where user_id = #{userId}
    </delete>

    <delete id="deleteDaUserCatalogByUserIds" parameterType="String">
        delete from da_user_catalog where user_id in 
        <foreach item="userId" collection="array" open="(" separator="," close=")">
            #{userId}
        </foreach>
    </delete>
</mapper>