<?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.BWwwGkmcMapper">

  <resultMap type="BWwwGkmc" id="BWwwGkmcResult">
    <result property="id" column="id" />
    <result property="type" column="type" />
    <result property="name" column="name" />
    <result property="f" column="f" />
    <result property="sendDate" column="sendDate" />
    <result property="content" column="content" />
    <result property="createTime" column="createTime" />
    <result property="clicked" column="clicked" />
    <result property="status" column="status" />
  </resultMap>

  <sql id="selectBWwwGkmcVo">
    select id, type, name, f, sendDate, content, createTime, clicked, status from b_www_gkmc
  </sql>

  <select id="selectBWwwGkmcList" parameterType="BWwwGkmc" resultMap="BWwwGkmcResult">
    select id, type, name, f, sendDate,  createTime, clicked, status from b_www_gkmc
    <where>
      <if test="type != null  and type != ''"> and type = #{type}</if>
      <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
      <if test="f != null  and f != ''"> and f = #{f}</if>
      <if test="sendDate != null "> and sendDate = #{sendDate}</if>
      <if test="content != null  and content != ''"> and content = #{content}</if>
      <if test="createTime != null "> and createTime = #{createTime}</if>
      <if test="clicked != null "> and clicked = #{clicked}</if>
      <if test="status != null "> and status = #{status}</if>
    </where>
    order by id
  </select>
  

  <select id="selectBWwwGkmcById" parameterType="Long" resultMap="BWwwGkmcResult">
    <include refid="selectBWwwGkmcVo" />
    where id = #{id}
  </select>
  
  <select id="prev" parameterType="Long" resultMap="BWwwGkmcResult">
     select id,name from b_www_gkmc where type=(select type from b_www_gkmc where id=#{id}) and id &lt; #{id} order by id desc limit 1
  </select>
  
  <select id="next" parameterType="Long" resultMap="BWwwGkmcResult">
     select id,name from b_www_gkmc where type=(select type from b_www_gkmc where id=#{id}) and id &gt; #{id} order by id limit 1
  </select>
  

  <insert id="insertBWwwGkmc" parameterType="BWwwGkmc" useGeneratedKeys="true" keyProperty="id">
    insert into b_www_gkmc
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="type != null">type,</if>
      <if test="name != null">name,</if>
      <if test="f != null">f,</if>
      <if test="sendDate != null">sendDate,</if>
      <if test="content != null">content,</if>
      <if test="createTime != null">createTime,</if>
      <if test="clicked != null">clicked,</if>
      <if test="status != null">status,</if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="type != null">#{type},</if>
      <if test="name != null">#{name},</if>
      <if test="f != null">#{f},</if>
      <if test="sendDate != null">#{sendDate},</if>
      <if test="content != null">#{content},</if>
      <if test="createTime != null">#{createTime},</if>
      <if test="clicked != null">#{clicked},</if>
      <if test="status != null">#{status},</if>
    </trim>
  </insert>

  <update id="updateBWwwGkmc" parameterType="BWwwGkmc">
    update b_www_gkmc
    <trim prefix="SET" suffixOverrides=",">
      <if test="type != null">type = #{type},</if>
      <if test="name != null">name = #{name},</if>
      <if test="f != null">f = #{f},</if>
      <if test="sendDate != null">sendDate = #{sendDate},</if>
      <if test="content != null">content = #{content},</if>
      <if test="createTime != null">createTime = #{createTime},</if>
      <if test="clicked != null">clicked = #{clicked},</if>
      <if test="status != null">status = #{status},</if>
    </trim>
    where id = #{id}
  </update>

  <delete id="deleteBWwwGkmcById" parameterType="Long">
    delete from b_www_gkmc where id = #{id}
  </delete>

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