<?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.goods.GoodsCommentWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.goods.pojo.GoodsComment">
    <id column="comment_id" property="commentId" />
    <result column="member_id" property="memberId" />
    <result column="member_name" property="memberName" />
    <result column="score" property="score" />
    <result column="content" property="content" />
    <result column="create_time" property="createTime" />
    <result column="goods_id" property="goodsId" />
    <result column="goods_name" property="goodsName" />
    <result column="product_id" property="productId" />
    <result column="spec_values" property="specValues" />
    <result column="store_id" property="storeId" />
    <result column="store_name" property="storeName" />
    <result column="order_sn" property="orderSn" />
    <result column="order_product_id" property="orderProductId" />
    <result column="reply_id" property="replyId" />
    <result column="reply_name" property="replyName" />
    <result column="reply_content" property="replyContent" />
    <result column="state" property="state" />
    <result column="admin_id" property="adminId" />
    <result column="image" property="image" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="memberId != null">
        `member_id`,
      </if>
      <if test="memberName != null">
        `member_name`,
      </if>
      <if test="score != null">
        `score`,
      </if>
      <if test="content != null">
        `content`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="goodsName != null">
        `goods_name`,
      </if>
      <if test="productId != null">
        `product_id`,
      </if>
      <if test="specValues != null">
        `spec_values`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="storeName != null">
        `store_name`,
      </if>
      <if test="orderSn != null">
        `order_sn`,
      </if>
      <if test="orderProductId != null">
        `order_product_id`,
      </if>
      <if test="replyId != null">
        `reply_id`,
      </if>
      <if test="replyName != null">
        `reply_name`,
      </if>
      <if test="replyContent != null">
        `reply_content`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="adminId != null">
        `admin_id`,
      </if>
      <if test="image != null">
        `image`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `comment_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.commentIdNotEquals != null">
          AND `comment_id` != #{example.commentIdNotEquals}
        </if>
        <if test="example.commentIdIn != null">
          AND `comment_id` in (${example.commentIdIn})
        </if>
        <if test="example.memberId != null">
          AND `member_id` = #{example.memberId}
        </if>
        <if test="example.memberName != null">
          AND `member_name` = #{example.memberName}
        </if>
        <if test="example.memberNameLike != null">
          AND `member_name` like concat('%',#{example.memberNameLike},'%')
        </if>
        <if test="example.score != null">
          AND `score` = #{example.score}
        </if>
        <if test="example.content != null">
          AND `content` = #{example.content}
        </if>
        <if test="example.contentLike != null">
          AND `content` like concat('%',#{example.contentLike},'%')
        </if>
        <if test="example.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </if>
        <if test="example.goodsName != null">
          AND `goods_name` = #{example.goodsName}
        </if>
        <if test="example.goodsNameLike != null">
          AND `goods_name` like concat('%',#{example.goodsNameLike},'%')
        </if>
        <if test="example.productId != null">
          AND `product_id` = #{example.productId}
        </if>
        <if test="example.specValues != null">
          AND `spec_values` = #{example.specValues}
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.storeName != null">
          AND `store_name` = #{example.storeName}
        </if>
        <if test="example.storeNameLike != null">
          AND `store_name` like concat('%',#{example.storeNameLike},'%')
        </if>
        <if test="example.orderSn != null">
          AND `order_sn` = #{example.orderSn}
        </if>
        <if test="example.orderSnLike != null">
          AND `order_sn` like concat('%',#{example.orderSnLike},'%')
        </if>
        <if test="example.orderProductId != null">
          AND `order_product_id` = #{example.orderProductId}
        </if>
        <if test="example.replyId != null">
          AND `reply_id` = #{example.replyId}
        </if>
        <if test="example.replyName != null">
          AND `reply_name` = #{example.replyName}
        </if>
        <if test="example.replyNameLike != null">
          AND `reply_name` like concat('%',#{example.replyNameLike},'%')
        </if>
        <if test="example.replyContent != null">
          AND `reply_content` = #{example.replyContent}
        </if>
        <if test="example.replyContentLike != null">
          AND `reply_content` like concat('%',#{example.replyContentLike},'%')
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.stateIn != null">
          AND `state` in (${example.stateIn})
        </if>
        <if test="example.stateNotIn != null">
          AND `state` not in (${example.stateNotIn})
        </if>
        <if test="example.stateNotEquals != null">
          AND `state` != #{example.stateNotEquals}
        </if>
        <if test="example.adminId != null">
          AND `admin_id` = #{example.adminId}
        </if>
        <if test="example.image != null">
          AND `image` = #{example.image}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `comment_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.goods.example.GoodsCommentExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `goods_comment`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `goods_comment`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `goods_comment`
    <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 `goods_comment`
    <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 `goods_comment`
    <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 `goods_comment`
    <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 `goods_comment`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `goods_comment`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="comment_id" keyProperty="commentId" parameterType="com.slodon.b2b2c.goods.pojo.GoodsComment" useGeneratedKeys="true">
    INSERT INTO `goods_comment`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="memberId != null">
        #{memberId},
      </if>
      <if test="memberName != null">
        #{memberName},
      </if>
      <if test="score != null">
        #{score},
      </if>
      <if test="content != null">
        #{content},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="goodsName != null">
        #{goodsName},
      </if>
      <if test="productId != null">
        #{productId},
      </if>
      <if test="specValues != null">
        #{specValues},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="storeName != null">
        #{storeName},
      </if>
      <if test="orderSn != null">
        #{orderSn},
      </if>
      <if test="orderProductId != null">
        #{orderProductId},
      </if>
      <if test="replyId != null">
        #{replyId},
      </if>
      <if test="replyName != null">
        #{replyName},
      </if>
      <if test="replyContent != null">
        #{replyContent},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="adminId != null">
        #{adminId},
      </if>
      <if test="image != null">
        #{image},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `goods_comment`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.memberId != null">
        `member_id` = #{record.memberId},
      </if>
      <if test="record.memberName != null">
        `member_name` = #{record.memberName},
      </if>
      <if test="record.score != null">
        `score` = #{record.score},
      </if>
      <if test="record.content != null">
        `content` = #{record.content},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.goodsName != null">
        `goods_name` = #{record.goodsName},
      </if>
      <if test="record.productId != null">
        `product_id` = #{record.productId},
      </if>
      <if test="record.specValues != null">
        `spec_values` = #{record.specValues},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.storeName != null">
        `store_name` = #{record.storeName},
      </if>
      <if test="record.orderSn != null">
        `order_sn` = #{record.orderSn},
      </if>
      <if test="record.orderProductId != null">
        `order_product_id` = #{record.orderProductId},
      </if>
      <if test="record.replyId != null">
        `reply_id` = #{record.replyId},
      </if>
      <if test="record.replyName != null">
        `reply_name` = #{record.replyName},
      </if>
      <if test="record.replyContent != null">
        `reply_content` = #{record.replyContent},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.adminId != null">
        `admin_id` = #{record.adminId},
      </if>
      <if test="record.image != null">
        `image` = #{record.image},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `goods_comment`
    <trim prefix="SET" suffixOverrides=",">
      <if test="memberId != null">
        `member_id` = #{memberId},
      </if>
      <if test="memberName != null">
        `member_name` = #{memberName},
      </if>
      <if test="score != null">
        `score` = #{score},
      </if>
      <if test="content != null">
        `content` = #{content},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="goodsName != null">
        `goods_name` = #{goodsName},
      </if>
      <if test="productId != null">
        `product_id` = #{productId},
      </if>
      <if test="specValues != null">
        `spec_values` = #{specValues},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="storeName != null">
        `store_name` = #{storeName},
      </if>
      <if test="orderSn != null">
        `order_sn` = #{orderSn},
      </if>
      <if test="orderProductId != null">
        `order_product_id` = #{orderProductId},
      </if>
      <if test="replyId != null">
        `reply_id` = #{replyId},
      </if>
      <if test="replyName != null">
        `reply_name` = #{replyName},
      </if>
      <if test="replyContent != null">
        `reply_content` = #{replyContent},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="adminId != null">
        `admin_id` = #{adminId},
      </if>
      <if test="image != null">
        `image` = #{image},
      </if>
    </trim>
    WHERE `comment_id` = #{commentId}
  </update>
</mapper>