<?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.system.TplPcMallDecoWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.TplPcMallDeco">
    <id column="deco_id" property="decoId" />
    <result column="deco_type" property="decoType" />
    <result column="deco_name" property="decoName" />
    <result column="data" property="data" />
    <result column="is_enable" property="isEnable" />
    <result column="create_user_id" property="createUserId" />
    <result column="create_user_name" property="createUserName" />
    <result column="create_time" property="createTime" />
    <result column="update_user_id" property="updateUserId" />
    <result column="update_user_name" property="updateUserName" />
    <result column="update_time" property="updateTime" />
    <result column="store_id" property="storeId" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="decoType != null">
        `deco_type`,
      </if>
      <if test="decoName != null">
        `deco_name`,
      </if>
      <if test="data != null">
        `data`,
      </if>
      <if test="isEnable != null">
        `is_enable`,
      </if>
      <if test="createUserId != null">
        `create_user_id`,
      </if>
      <if test="createUserName != null">
        `create_user_name`,
      </if>
      <if test="createTime != null">
        `create_time`,
      </if>
      <if test="updateUserId != null">
        `update_user_id`,
      </if>
      <if test="updateUserName != null">
        `update_user_name`,
      </if>
      <if test="updateTime != null">
        `update_time`,
      </if>
      <if test="storeId != null">
        `store_id`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `deco_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.decoIdNotEquals != null">
          AND `deco_id` != #{example.decoIdNotEquals}
        </if>
        <if test="example.decoIdIn != null">
          AND `deco_id` in (${example.decoIdIn})
        </if>
        <if test="example.decoType != null">
          AND `deco_type` = #{example.decoType}
        </if>
        <if test="example.decoName != null">
          AND `deco_name` = #{example.decoName}
        </if>
        <if test="example.decoNameLike != null">
          AND `deco_name` like concat('%',#{example.decoNameLike},'%')
        </if>
        <if test="example.data != null">
          AND `data` = #{example.data}
        </if>
        <if test="example.isEnable != null">
          AND `is_enable` = #{example.isEnable}
        </if>
        <if test="example.createUserId != null">
          AND `create_user_id` = #{example.createUserId}
        </if>
        <if test="example.createUserName != null">
          AND `create_user_name` = #{example.createUserName}
        </if>
        <if test="example.createUserNameLike != null">
          AND `create_user_name` like concat('%',#{example.createUserNameLike},'%')
        </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.updateUserId != null">
          AND `update_user_id` = #{example.updateUserId}
        </if>
        <if test="example.updateUserName != null">
          AND `update_user_name` = #{example.updateUserName}
        </if>
        <if test="example.updateUserNameLike != null">
          AND `update_user_name` like concat('%',#{example.updateUserNameLike},'%')
        </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.storeId != null">
          AND `store_id` = #{example.storeId}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `deco_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.system.example.TplPcMallDecoExample" resultType="java.lang.Integer">
    SELECT
    COUNT(*)
    FROM `sys_tpl_pc_mall_deco`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
    *
    FROM `sys_tpl_pc_mall_deco`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
    *
    FROM `sys_tpl_pc_mall_deco`
    <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 `sys_tpl_pc_mall_deco`
    <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 `sys_tpl_pc_mall_deco`
    <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 `sys_tpl_pc_mall_deco`
    <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 `sys_tpl_pc_mall_deco`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `sys_tpl_pc_mall_deco`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="deco_id" keyProperty="decoId" parameterType="com.slodon.b2b2c.system.pojo.TplPcMallDeco" useGeneratedKeys="true">
    INSERT INTO `sys_tpl_pc_mall_deco`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="decoType != null">
        #{decoType},
      </if>
      <if test="decoName != null">
        #{decoName},
      </if>
      <if test="data != null">
        #{data},
      </if>
      <if test="isEnable != null">
        #{isEnable},
      </if>
      <if test="createUserId != null">
        #{createUserId},
      </if>
      <if test="createUserName != null">
        #{createUserName},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="updateUserId != null">
        #{updateUserId},
      </if>
      <if test="updateUserName != null">
        #{updateUserName},
      </if>
      <if test="updateTime != null">
        #{updateTime},
      </if>
      <if test="storeId != null">
        #{storeId},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `sys_tpl_pc_mall_deco`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.decoType != null">
        `deco_type` = #{record.decoType},
      </if>
      <if test="record.decoName != null">
        `deco_name` = #{record.decoName},
      </if>
      <if test="record.data != null">
        `data` = #{record.data},
      </if>
      <if test="record.isEnable != null">
        `is_enable` = #{record.isEnable},
      </if>
      <if test="record.createUserId != null">
        `create_user_id` = #{record.createUserId},
      </if>
      <if test="record.createUserName != null">
        `create_user_name` = #{record.createUserName},
      </if>
      <if test="record.createTime != null">
        `create_time` = #{record.createTime},
      </if>
      <if test="record.updateUserId != null">
        `update_user_id` = #{record.updateUserId},
      </if>
      <if test="record.updateUserName != null">
        `update_user_name` = #{record.updateUserName},
      </if>
      <if test="record.updateTime != null">
        `update_time` = #{record.updateTime},
      </if>
      <if test="record.storeId != null">
        `store_id` = #{record.storeId},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `sys_tpl_pc_mall_deco`
    <trim prefix="SET" suffixOverrides=",">
      <if test="decoType != null">
        `deco_type` = #{decoType},
      </if>
      <if test="decoName != null">
        `deco_name` = #{decoName},
      </if>
      <if test="data != null">
        `data` = #{data},
      </if>
      <if test="isEnable != null">
        `is_enable` = #{isEnable},
      </if>
      <if test="createUserId != null">
        `create_user_id` = #{createUserId},
      </if>
      <if test="createUserName != null">
        `create_user_name` = #{createUserName},
      </if>
      <if test="createTime != null">
        `create_time` = #{createTime},
      </if>
      <if test="updateUserId != null">
        `update_user_id` = #{updateUserId},
      </if>
      <if test="updateUserName != null">
        `update_user_name` = #{updateUserName},
      </if>
      <if test="updateTime != null">
        `update_time` = #{updateTime},
      </if>
      <if test="storeId != null">
        `store_id` = #{storeId},
      </if>
    </trim>
    WHERE `deco_id` = #{decoId}
  </update>
</mapper>