<?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.slodon.b2b2c.dao.write.msg.NoticeCheckStatusWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.msg.pojo.NoticeCheckStatus">
    <id column="check_status_id" property="checkStatusId" />
    <result column="store_id" property="storeId" />
    <result column="notice_id" property="noticeId" />
    <result column="view_time" property="viewTime" />
    <result column="state" property="state" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="noticeId != null">
        `notice_id`,
      </if>
      <if test="viewTime != null">
        `view_time`,
      </if>
      <if test="state != null">
        `state`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `check_status_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.checkStatusIdNotEquals != null">
          AND `check_status_id` != #{example.checkStatusIdNotEquals}
        </if>
        <if test="example.checkStatusIdIn != null">
          AND `check_status_id` in (${example.checkStatusIdIn})
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.noticeId != null">
          AND `notice_id` = #{example.noticeId}
        </if>
        <if test="example.viewTimeAfter != null">
          AND `view_time` <![CDATA[ >= ]]> #{example.viewTimeAfter}
        </if>
        <if test="example.viewTimeBefore != null">
          AND `view_time` <![CDATA[ <= ]]> #{example.viewTimeBefore}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `check_status_id` DESC
  </sql>
  <sql id="orderByOther">
    order by ${example.orderBy}
  </sql>
  <!--分组条件-->
  <sql id="groupBy">
    group by ${example.groupBy}
  </sql>
  <!--分页条件-->
  <sql id="limit">
    <if test="size != null and size &gt; 0">
      limit #{startRow},#{size}
    </if>
  </sql>
  <!--查询符合条件的记录数-->
  <select id="countByExample" parameterType="com.slodon.b2b2c.msg.example.NoticeCheckStatusExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `msg_notice_check_status`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `msg_notice_check_status`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `msg_notice_check_status`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(所有字段)-->
  <select id="listPageByExample" resultMap="resultMap">
    SELECT
      *
    FROM `msg_notice_check_status`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--查询符合条件的记录(指定字段)-->
  <select id="listFieldsByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `msg_notice_check_status`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
  </select>
  <!--分页查询符合条件的记录(指定字段)-->
  <select id="listFieldsPageByExample" resultMap="resultMap">
    SELECT
      ${fields}
    FROM `msg_notice_check_status`
    <include refid="whereCondition" />
    <if test="example.groupBy != null">
      <include refid="groupBy" />
    </if>
    <choose>
      <when test="example.orderBy != null">
        <include refid="orderByOther" />
      </when>
      <otherwise>
        <include refid="orderBy" />
      </otherwise>
    </choose>
    <include refid="limit" />
  </select>
  <!--根据条件删除记录，可多条删除-->
  <delete id="deleteByExample">
    DELETE FROM `msg_notice_check_status`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `msg_notice_check_status`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="check_status_id" keyProperty="checkStatusId" parameterType="com.slodon.b2b2c.msg.pojo.NoticeCheckStatus" useGeneratedKeys="true">
    INSERT INTO `msg_notice_check_status`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="noticeId != null">
        #{noticeId},
      </if>
      <if test="viewTime != null">
        #{viewTime},
      </if>
      <if test="state != null">
        #{state},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `msg_notice_check_status`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.noticeId != null">
        `notice_id` = #{record.noticeId},
      </if>
      <if test="record.viewTime != null">
        `view_time` = #{record.viewTime},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `msg_notice_check_status`
    <trim prefix="SET" suffixOverrides=",">
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="noticeId != null">
        `notice_id` = #{noticeId},
      </if>
      <if test="viewTime != null">
        `view_time` = #{viewTime},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
    </trim>
    WHERE `check_status_id` = #{checkStatusId}
  </update>
</mapper>