<?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.MemberBalanceLogWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.member.pojo.MemberBalanceLog">
    <id column="log_id" property="logId" />
    <result column="member_id" property="memberId" />
    <result column="member_name" property="memberName" />
    <result column="after_change_amount" property="afterChangeAmount" />
    <result column="change_value" property="changeValue" />
    <result column="freeze_amount" property="freezeAmount" />
    <result column="freeze_value" property="freezeValue" />
    <result column="create_time" property="createTime" />
    <result column="type" property="type" />
    <result column="description" property="description" />
    <result column="admin_id" property="adminId" />
    <result column="admin_name" property="adminName" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="memberId != null">
        `member_id`,
      </if>
      <if test="memberName != null">
        `member_name`,
      </if>
      <if test="afterChangeAmount != null">
        `after_change_amount`,
      </if>
      <if test="changeValue != null">
        `change_value`,
      </if>
      <if test="freezeAmount != null">
        `freeze_amount`,
      </if>
      <if test="freezeValue != null">
        `freeze_value`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="type != null">
        `type`,
      </if>
      <if test="description != null">
        `description`,
      </if>
      <if test="adminId != null">
        `admin_id`,
      </if>
      <if test="adminName != null">
        `admin_name`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `log_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.logIdNotEquals != null">
          AND `log_id` != #{example.logIdNotEquals}
        </if>
        <if test="example.logIdIn != null">
          AND `log_id` in (${example.logIdIn})
        </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.afterChangeAmount != null">
          AND `after_change_amount` = #{example.afterChangeAmount}
        </if>
        <if test="example.changeValue != null">
          AND `change_value` = #{example.changeValue}
        </if>
        <if test="example.freezeAmount != null">
          AND `freeze_amount` = #{example.freezeAmount}
        </if>
        <if test="example.freezeValue != null">
          AND `freeze_value` = #{example.freezeValue}
        </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.type != null">
          AND `type` = #{example.type}
        </if>
        <if test="example.description != null">
          AND `description` = #{example.description}
        </if>
        <if test="example.adminId != null">
          AND `admin_id` = #{example.adminId}
        </if>
        <if test="example.adminName != null">
          AND `admin_name` = #{example.adminName}
        </if>
        <if test="example.adminNameLike != null">
          AND `admin_name` like concat('%',#{example.adminNameLike},'%')
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `log_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.MemberBalanceLogExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `member_balance_log`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `member_balance_log`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `member_balance_log`
    <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_balance_log`
    <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_balance_log`
    <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_balance_log`
    <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_balance_log`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `member_balance_log`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="log_id" keyProperty="logId" parameterType="com.slodon.b2b2c.member.pojo.MemberBalanceLog" useGeneratedKeys="true">
    INSERT INTO `member_balance_log`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="memberId != null">
        #{memberId},
      </if>
      <if test="memberName != null">
        #{memberName},
      </if>
      <if test="afterChangeAmount != null">
        #{afterChangeAmount},
      </if>
      <if test="changeValue != null">
        #{changeValue},
      </if>
      <if test="freezeAmount != null">
        #{freezeAmount},
      </if>
      <if test="freezeValue != null">
        #{freezeValue},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="type != null">
        #{type},
      </if>
      <if test="description != null">
        #{description},
      </if>
      <if test="adminId != null">
        #{adminId},
      </if>
      <if test="adminName != null">
        #{adminName},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `member_balance_log`
    <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.afterChangeAmount != null">
        `after_change_amount` = #{record.afterChangeAmount},
      </if>
      <if test="record.changeValue != null">
        `change_value` = #{record.changeValue},
      </if>
      <if test="record.freezeAmount != null">
        `freeze_amount` = #{record.freezeAmount},
      </if>
      <if test="record.freezeValue != null">
        `freeze_value` = #{record.freezeValue},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.type != null">
        `type` = #{record.type},
      </if>
      <if test="record.description != null">
        `description` = #{record.description},
      </if>
      <if test="record.adminId != null">
        `admin_id` = #{record.adminId},
      </if>
      <if test="record.adminName != null">
        `admin_name` = #{record.adminName},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `member_balance_log`
    <trim prefix="SET" suffixOverrides=",">
      <if test="memberId != null">
        `member_id` = #{memberId},
      </if>
      <if test="memberName != null">
        `member_name` = #{memberName},
      </if>
      <if test="afterChangeAmount != null">
        `after_change_amount` = #{afterChangeAmount},
      </if>
      <if test="changeValue != null">
        `change_value` = #{changeValue},
      </if>
      <if test="freezeAmount != null">
        `freeze_amount` = #{freezeAmount},
      </if>
      <if test="freezeValue != null">
        `freeze_value` = #{freezeValue},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="type != null">
        `type` = #{type},
      </if>
      <if test="description != null">
        `description` = #{description},
      </if>
      <if test="adminId != null">
        `admin_id` = #{adminId},
      </if>
      <if test="adminName != null">
        `admin_name` = #{adminName},
      </if>
    </trim>
    WHERE `log_id` = #{logId}
  </update>
</mapper>