<?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.integral.IntegralGoodsLabelWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.integral.pojo.IntegralGoodsLabel">
    <id column="label_id" property="labelId" />
    <result column="label_name" property="labelName" />
    <result column="sort" property="sort" />
    <result column="parent_label_id" property="parentLabelId" />
    <result column="grade" property="grade" />
    <result column="image" property="image" />
    <result column="state" property="state" />
    <result column="create_admin_id" property="createAdminId" />
    <result column="create_time" property="createTime" />
    <result column="update_admin_id" property="updateAdminId" />
    <result column="update_time" property="updateTime" />
    <result column="data" property="data" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="labelName != null">
        `label_name`,
      </if>
      <if test="sort != null">
        `sort`,
      </if>
      <if test="parentLabelId != null">
        `parent_label_id`,
      </if>
      <if test="grade != null">
        `grade`,
      </if>
      <if test="image != null">
        `image`,
      </if>
      <if test="state != null">
        `state`,
      </if>
      <if test="createAdminId != null">
        `create_admin_id`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="updateAdminId != null">
        `update_admin_id`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
      <if test="data != null">
        `data`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `label_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.labelIdNotEquals != null">
          AND `label_id` != #{example.labelIdNotEquals}
        </if>
        <if test="example.labelIdIn != null">
          AND `label_id` in (${example.labelIdIn})
        </if>
        <if test="example.labelName != null">
          AND `label_name` = #{example.labelName}
        </if>
        <if test="example.labelNameLike != null">
          AND `label_name` like concat('%',#{example.labelNameLike},'%')
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
        <if test="example.parentLabelId != null">
          AND `parent_label_id` = #{example.parentLabelId}
        </if>
        <if test="example.grade != null">
          AND `grade` = #{example.grade}
        </if>
        <if test="example.image != null">
          AND `image` = #{example.image}
        </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.createAdminId != null">
          AND `create_admin_id` = #{example.createAdminId}
        </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.updateAdminId != null">
          AND `update_admin_id` = #{example.updateAdminId}
        </if>
        <if test="example.updateTimeAfter != null">
          AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
        </if>
        <if test="example.updateTimeBefore != null">
          AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
        </if>
        <if test="example.data != null">
          AND `data` = #{example.data}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `label_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.integral.example.IntegralGoodsLabelExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `integral_goods_label`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `integral_goods_label`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `integral_goods_label`
    <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 `integral_goods_label`
    <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 `integral_goods_label`
    <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 `integral_goods_label`
    <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 `integral_goods_label`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `integral_goods_label`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="label_id" keyProperty="labelId" parameterType="com.slodon.b2b2c.integral.pojo.IntegralGoodsLabel" useGeneratedKeys="true">
    INSERT INTO `integral_goods_label`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="labelName != null">
        #{labelName},
      </if>
      <if test="sort != null">
        #{sort},
      </if>
      <if test="parentLabelId != null">
        #{parentLabelId},
      </if>
      <if test="grade != null">
        #{grade},
      </if>
      <if test="image != null">
        #{image},
      </if>
      <if test="state != null">
        #{state},
      </if>
      <if test="createAdminId != null">
        #{createAdminId},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="updateAdminId != null">
        #{updateAdminId},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
      <if test="data != null">
        #{data},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `integral_goods_label`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.labelName != null">
        `label_name` = #{record.labelName},
      </if>
      <if test="record.sort != null">
        `sort` = #{record.sort},
      </if>
      <if test="record.parentLabelId != null">
        `parent_label_id` = #{record.parentLabelId},
      </if>
      <if test="record.grade != null">
        `grade` = #{record.grade},
      </if>
      <if test="record.image != null">
        `image` = #{record.image},
      </if>
      <if test="record.state != null">
        `state` = #{record.state},
      </if>
      <if test="record.createAdminId != null">
        `create_admin_id` = #{record.createAdminId},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.updateAdminId != null">
        `update_admin_id` = #{record.updateAdminId},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
      <if test="record.data != null">
        `data` = #{record.data},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `integral_goods_label`
    <trim prefix="SET" suffixOverrides=",">
      <if test="labelName != null">
        `label_name` = #{labelName},
      </if>
      <if test="sort != null">
        `sort` = #{sort},
      </if>
      <if test="parentLabelId != null">
        `parent_label_id` = #{parentLabelId},
      </if>
      <if test="grade != null">
        `grade` = #{grade},
      </if>
      <if test="image != null">
        `image` = #{image},
      </if>
      <if test="state != null">
        `state` = #{state},
      </if>
      <if test="createAdminId != null">
        `create_admin_id` = #{createAdminId},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="updateAdminId != null">
        `update_admin_id` = #{updateAdminId},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
      <if test="data != null">
        `data` = #{data},
      </if>
    </trim>
    WHERE `label_id` = #{labelId}
  </update>
</mapper>