<?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.cms.InformationCategoryWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.cms.pojo.InformationCategory">
    <id column="cate_id" property="cateId" />
    <result column="cate_name" property="cateName" />
    <result column="sort" property="sort" />
    <result column="is_show" property="isShow" />
    <result column="create_time" property="createTime" />
    <result column="create_admin_id" property="createAdminId" />
    <result column="create_admin_name" property="createAdminName" />
    <result column="update_time" property="updateTime" />
    <result column="update_admin_id" property="updateAdminId" />
    <result column="update_admin_name" property="updateAdminName" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="cateName != null">
        `cate_name`,
      </if>
      <if test="sort != null">
        `sort`,
      </if>
      <if test="isShow != null">
        `is_show`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="createAdminId != null">
        `create_admin_id`,
      </if>
      <if test="createAdminName != null">
        `create_admin_name`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
      <if test="updateAdminId != null">
        `update_admin_id`,
      </if>
      <if test="updateAdminName != null">
        `update_admin_name`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `cate_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.cateIdNotEquals != null">
          AND `cate_id` != #{example.cateIdNotEquals}
        </if>
        <if test="example.cateIdIn != null">
          AND `cate_id` in (${example.cateIdIn})
        </if>
        <if test="example.cateName != null">
          AND `cate_name` = #{example.cateName}
        </if>
        <if test="example.cateNameLike != null">
          AND `cate_name` like concat('%',#{example.cateNameLike},'%')
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
        <if test="example.isShow != null">
          AND `is_show` = #{example.isShow}
        </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.createAdminId != null">
          AND `create_admin_id` = #{example.createAdminId}
        </if>
        <if test="example.createAdminName != null">
          AND `create_admin_name` = #{example.createAdminName}
        </if>
        <if test="example.createAdminNameLike != null">
          AND `create_admin_name` like concat('%',#{example.createAdminNameLike},'%')
        </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.updateAdminId != null">
          AND `update_admin_id` = #{example.updateAdminId}
        </if>
        <if test="example.updateAdminName != null">
          AND `update_admin_name` = #{example.updateAdminName}
        </if>
        <if test="example.updateAdminNameLike != null">
          AND `update_admin_name` like concat('%',#{example.updateAdminNameLike},'%')
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `cate_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.cms.example.InformationCategoryExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `cms_information_category`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `cms_information_category`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `cms_information_category`
    <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 `cms_information_category`
    <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 `cms_information_category`
    <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 `cms_information_category`
    <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 `cms_information_category`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `cms_information_category`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="cate_id" keyProperty="cateId" parameterType="com.slodon.b2b2c.cms.pojo.InformationCategory" useGeneratedKeys="true">
    INSERT INTO `cms_information_category`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="cateName != null">
        #{cateName},
      </if>
      <if test="sort != null">
        #{sort},
      </if>
      <if test="isShow != null">
        #{isShow},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="createAdminId != null">
        #{createAdminId},
      </if>
      <if test="createAdminName != null">
        #{createAdminName},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
      <if test="updateAdminId != null">
        #{updateAdminId},
      </if>
      <if test="updateAdminName != null">
        #{updateAdminName},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `cms_information_category`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.cateName != null">
        `cate_name` = #{record.cateName},
      </if>
      <if test="record.sort != null">
        `sort` = #{record.sort},
      </if>
      <if test="record.isShow != null">
        `is_show` = #{record.isShow},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.createAdminId != null">
        `create_admin_id` = #{record.createAdminId},
      </if>
      <if test="record.createAdminName != null">
        `create_admin_name` = #{record.createAdminName},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
      <if test="record.updateAdminId != null">
        `update_admin_id` = #{record.updateAdminId},
      </if>
      <if test="record.updateAdminName != null">
        `update_admin_name` = #{record.updateAdminName},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `cms_information_category`
    <trim prefix="SET" suffixOverrides=",">
      <if test="cateName != null">
        `cate_name` = #{cateName},
      </if>
      <if test="sort != null">
        `sort` = #{sort},
      </if>
      <if test="isShow != null">
        `is_show` = #{isShow},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="createAdminId != null">
        `create_admin_id` = #{createAdminId},
      </if>
      <if test="createAdminName != null">
        `create_admin_name` = #{createAdminName},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
      <if test="updateAdminId != null">
        `update_admin_id` = #{updateAdminId},
      </if>
      <if test="updateAdminName != null">
        `update_admin_name` = #{updateAdminName},
      </if>
    </trim>
    WHERE `cate_id` = #{cateId}
  </update>
</mapper>