<?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.huijy.management.mapper.MarkerContentMapper">

    <resultMap type="MarkerContent" id="MarkerContentResult">
        <result property="markerContent"    column="marker_content"    />
        <result property="markerId"    column="marker_id"    />
        <result property="contentId"    column="content_id"    />
    </resultMap>

    <sql id="selectMarkerContentVo">
        select marker_content, marker_id, content_id from t_marker_content
    </sql>

    <select id="selectMarkerContentList" parameterType="MarkerContent" resultMap="MarkerContentResult">
        <include refid="selectMarkerContentVo"/>
        <where>
            <if test="markerId != null "> and marker_id = #{markerId}</if>
            <if test="contentId != null "> and content_id = #{contentId}</if>
        </where>
    </select>

    <select id="selectMarkerContentByMarkerContent" parameterType="Long" resultMap="MarkerContentResult">
        <include refid="selectMarkerContentVo"/>
        where marker_content = #{markerContent}
    </select>

    <insert id="insertMarkerContent" parameterType="MarkerContent" useGeneratedKeys="true" keyProperty="markerContent">
        insert into t_marker_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="markerId != null">marker_id,</if>
            <if test="contentId != null">content_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="markerId != null">#{markerId},</if>
            <if test="contentId != null">#{contentId},</if>
         </trim>
    </insert>

    <update id="updateMarkerContent" parameterType="MarkerContent">
        update t_marker_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="markerId != null">marker_id = #{markerId},</if>
            <if test="contentId != null">content_id = #{contentId},</if>
        </trim>
        where marker_content = #{markerContent}
    </update>

    <delete id="deleteMarkerContentByMarkerContent" parameterType="Long">
        delete from t_marker_content where marker_content = #{markerContent}
    </delete>

    <delete id="deleteMarkerContentByMarkerContents" parameterType="String">
        delete from t_marker_content where marker_content in
        <foreach item="markerContent" collection="array" open="(" separator="," close=")">
            #{markerContent}
        </foreach>
    </delete>

    <select id="selectContentIdListByMarkerId" parameterType="Long" resultType="Long">
        select content_id from t_marker_content where marker_id = #{markerId}
    </select>

    <delete id="deleteMarkerContentByMarkerId" parameterType="Long">
        delete from t_marker_content where marker_id = #{markerId}
    </delete>
</mapper>
