<?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.member.MemberGoodsAskWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.member.pojo.MemberGoodsAsk">
    <id column="ask_id" property="askId" />
    <result column="store_id" property="storeId" />
    <result column="goods_id" property="goodsId" />
    <result column="member_id" property="memberId" />
    <result column="member_name" property="memberName" />
    <result column="ask_content" property="askContent" />
    <result column="reply_vendor_id" property="replyVendorId" />
    <result column="reply_vendor_name" property="replyVendorName" />
    <result column="reply_content" property="replyContent" />
    <result column="create_time" property="createTime" />
    <result column="reply_time" property="replyTime" />
    <result column="state" property="state" />
    <result column="is_anonymous" property="isAnonymous" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="storeId != null">
        `store_id`,
      </if>
      <if test="goodsId != null">
        `goods_id`,
      </if>
      <if test="memberId != null">
        `member_id`,
      </if>
      <if test="memberName != null">
        `member_name`,
      </if>
      <if test="askContent != null">
        `ask_content`,
      </if>
      <if test="replyVendorId != null">
        `reply_vendor_id`,
      </if>
      <if test="replyVendorName != null">
        `reply_vendor_name`,
      </if>
      <if test="replyContent != null">
        `reply_content`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="replyTime != null">
        `reply_time`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="isAnonymous != null">
        `is_anonymous`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `ask_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.askIdNotEquals != null">
          AND `ask_id` != #{example.askIdNotEquals}
        </if>
        <if test="example.askIdIn != null">
          AND `ask_id` in (${example.askIdIn})
        </if>
        <if test="example.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
        <if test="example.goodsId != null">
          AND `goods_id` = #{example.goodsId}
        </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.askContent != null">
          AND `ask_content` = #{example.askContent}
        </if>
        <if test="example.askContentLike != null">
          AND `ask_content` like concat('%',#{example.askContentLike},'%')
        </if>
        <if test="example.replyVendorId != null">
          AND `reply_vendor_id` = #{example.replyVendorId}
        </if>
        <if test="example.replyVendorName != null">
          AND `reply_vendor_name` = #{example.replyVendorName}
        </if>
        <if test="example.replyVendorNameLike != null">
          AND `reply_vendor_name` like concat('%',#{example.replyVendorNameLike},'%')
        </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.createTimeAfter != null">
          AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
        </if>
        <if test="example.createTimeBefore != null">
          AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
        </if>
        <if test="example.replyTimeAfter != null">
          AND `reply_time` <![CDATA[ >= ]]> #{example.replyTimeAfter}
        </if>
        <if test="example.replyTimeBefore != null">
          AND `reply_time` <![CDATA[ <= ]]> #{example.replyTimeBefore}
        </if>
        <if test="example.state != null">
          AND `state` = #{example.state}
        </if>
        <if test="example.isAnonymous != null">
          AND `is_anonymous` = #{example.isAnonymous}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `ask_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.member.example.MemberGoodsAskExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `member_goods_ask`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `member_goods_ask`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `member_goods_ask`
    <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 `member_goods_ask`
    <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 `member_goods_ask`
    <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 `member_goods_ask`
    <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 `member_goods_ask`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `member_goods_ask`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="ask_id" keyProperty="askId" parameterType="com.slodon.b2b2c.member.pojo.MemberGoodsAsk" useGeneratedKeys="true">
    INSERT INTO `member_goods_ask`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="storeId != null">
        #{storeId},
      </if>
      <if test="goodsId != null">
        #{goodsId},
      </if>
      <if test="memberId != null">
        #{memberId},
      </if>
      <if test="memberName != null">
        #{memberName},
      </if>
      <if test="askContent != null">
        #{askContent},
      </if>
      <if test="replyVendorId != null">
        #{replyVendorId},
      </if>
      <if test="replyVendorName != null">
        #{replyVendorName},
      </if>
      <if test="replyContent != null">
        #{replyContent},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="replyTime != null">
        #{replyTime},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="isAnonymous != null">
        #{isAnonymous},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `member_goods_ask`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
      <if test="record.goodsId != null">
        `goods_id` = #{record.goodsId},
      </if>
      <if test="record.memberId != null">
        `member_id` = #{record.memberId},
      </if>
      <if test="record.memberName != null">
        `member_name` = #{record.memberName},
      </if>
      <if test="record.askContent != null">
        `ask_content` = #{record.askContent},
      </if>
      <if test="record.replyVendorId != null">
        `reply_vendor_id` = #{record.replyVendorId},
      </if>
      <if test="record.replyVendorName != null">
        `reply_vendor_name` = #{record.replyVendorName},
      </if>
      <if test="record.replyContent != null">
        `reply_content` = #{record.replyContent},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.replyTime != null">
        `reply_time` = #{record.replyTime},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.isAnonymous != null">
        `is_anonymous` = #{record.isAnonymous},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `member_goods_ask`
    <trim prefix="SET" suffixOverrides=",">
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
      <if test="goodsId != null">
        `goods_id` = #{goodsId},
      </if>
      <if test="memberId != null">
        `member_id` = #{memberId},
      </if>
      <if test="memberName != null">
        `member_name` = #{memberName},
      </if>
      <if test="askContent != null">
        `ask_content` = #{askContent},
      </if>
      <if test="replyVendorId != null">
        `reply_vendor_id` = #{replyVendorId},
      </if>
      <if test="replyVendorName != null">
        `reply_vendor_name` = #{replyVendorName},
      </if>
      <if test="replyContent != null">
        `reply_content` = #{replyContent},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="replyTime != null">
        `reply_time` = #{replyTime},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="isAnonymous != null">
        `is_anonymous` = #{isAnonymous},
      </if>
    </trim>
    WHERE `ask_id` = #{askId}
  </update>
</mapper>