<?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.ruoyi.syzy.mapper.BWwwNewsRefMapper">
    
    <resultMap type="BWwwNewsRef" id="BWwwNewsRefResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="subType"    column="subType"    />
        <result property="description"    column="description"    />
        <result property="refIds"    column="refIds"    />
        <result property="location"    column="location"    />
    </resultMap>

    <sql id="selectBWwwNewsRefVo">
        select id, type, subType, description, refIds, location from b_www_news_ref
    </sql>

    <select id="selectBWwwNewsRefList" parameterType="BWwwNewsRef" resultMap="BWwwNewsRefResult">
        <include refid="selectBWwwNewsRefVo"/>
        <where>  
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="subType != null  and subType != ''"> and subType = #{subType}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="refIds != null  and refIds != ''"> and refIds = #{refIds}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
        </where>
    </select>
    
    <select id="selectBWwwNewsRefById" parameterType="Long" resultMap="BWwwNewsRefResult">
        <include refid="selectBWwwNewsRefVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBWwwNewsRef" parameterType="BWwwNewsRef" useGeneratedKeys="true" keyProperty="id">
        insert into b_www_news_ref
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null">type,</if>
            <if test="subType != null">subType,</if>
            <if test="description != null">description,</if>
            <if test="refIds != null">refIds,</if>
            <if test="location != null">location,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null">#{type},</if>
            <if test="subType != null">#{subType},</if>
            <if test="description != null">#{description},</if>
            <if test="refIds != null">#{refIds},</if>
            <if test="location != null">#{location},</if>
         </trim>
    </insert>

    <update id="updateBWwwNewsRef" parameterType="BWwwNewsRef">
        update b_www_news_ref
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
            <if test="subType != null">subType = #{subType},</if>
            <if test="description != null">description = #{description},</if>
            <if test="refIds != null">refIds = #{refIds},</if>
            <if test="location != null">location = #{location}</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBWwwNewsRefById" parameterType="Long">
        delete from b_www_news_ref where id = #{id}
    </delete>

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