<?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.TplPcWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.TplPc">
    <id column="tpl_pc_id" property="tplPcId" />
    <result column="type" property="type" />
    <result column="code" property="code" />
    <result column="type_name" property="typeName" />
    <result column="name" property="name" />
    <result column="sort" property="sort" />
    <result column="is_enable" property="isEnable" />
    <result column="client" property="client" />
    <result column="is_instance" property="isInstance" />
    <result column="image" property="image" />
    <result column="desc" property="desc" />
    <result column="data" property="data" />
    <result column="default_data" property="defaultData" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="type != null">
        `type`,
      </if>
      <if test="code != null">
        `code`,
      </if>
      <if test="typeName != null">
        `type_name`,
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="sort != null">
        `sort`,
      </if>
      <if test="isEnable != null">
        `is_enable`,
      </if>
      <if test="client != null">
        `client`,
      </if>
      <if test="isInstance != null">
        `is_instance`,
      </if>
      <if test="image != null">
        `image`,
      </if>
      <if test="desc != null">
        `desc`,
      </if>
      <if test="data != null">
        `data`,
      </if>
      <if test="defaultData != null">
        `default_data`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `tpl_pc_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.tplPcIdNotEquals != null">
          AND `tpl_pc_id` != #{example.tplPcIdNotEquals}
        </if>
        <if test="example.tplPcIdIn != null">
          AND `tpl_pc_id` in (${example.tplPcIdIn})
        </if>
        <if test="example.type != null">
          AND `type` = #{example.type}
        </if>
        <if test="example.code != null">
          AND `code` = #{example.code}
        </if>
        <if test="example.typeName != null">
          AND `type_name` = #{example.typeName}
        </if>
        <if test="example.typeNameLike != null">
          AND `type_name` like concat('%',#{example.typeNameLike},'%')
        </if>
        <if test="example.name != null">
          AND `name` = #{example.name}
        </if>
        <if test="example.nameLike != null">
          AND `name` like concat('%',#{example.nameLike},'%')
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
        <if test="example.isEnable != null">
          AND `is_enable` = #{example.isEnable}
        </if>
        <if test="example.client != null">
          AND `client` = #{example.client}
        </if>
        <if test="example.isInstance != null">
          AND `is_instance` = #{example.isInstance}
        </if>
        <if test="example.image != null">
          AND `image` = #{example.image}
        </if>
        <if test="example.desc != null">
          AND `desc` = #{example.desc}
        </if>
        <if test="example.data != null">
          AND `data` = #{example.data}
        </if>
        <if test="example.defaultData != null">
          AND `default_data` = #{example.defaultData}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `tpl_pc_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.TplPcExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `sys_tpl_pc`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `sys_tpl_pc`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_tpl_pc`
    <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`
    <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`
    <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`
    <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`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `sys_tpl_pc`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="tpl_pc_id" keyProperty="tplPcId" parameterType="com.slodon.b2b2c.system.pojo.TplPc" useGeneratedKeys="true">
    INSERT INTO `sys_tpl_pc`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="type != null">
        #{type},
      </if>
      <if test="code != null">
        #{code},
      </if>
      <if test="typeName != null">
        #{typeName},
      </if>
      <if test="name != null">
        #{name},
      </if>
      <if test="sort != null">
        #{sort},
      </if>
      <if test="isEnable != null">
        #{isEnable},
      </if>
      <if test="client != null">
        #{client},
      </if>
      <if test="isInstance != null">
        #{isInstance},
      </if>
      <if test="image != null">
        #{image},
      </if>
      <if test="desc != null">
        #{desc},
      </if>
      <if test="data != null">
        #{data},
      </if>
      <if test="defaultData != null">
        #{defaultData},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `sys_tpl_pc`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.type != null">
        `type` = #{record.type},
      </if>
      <if test="record.code != null">
        `code` = #{record.code},
      </if>
      <if test="record.typeName != null">
        `type_name` = #{record.typeName},
      </if>
      <if test="record.name != null">
        `name` = #{record.name},
      </if>
      <if test="record.sort != null">
        `sort` = #{record.sort},
      </if>
      <if test="record.isEnable != null">
        `is_enable` = #{record.isEnable},
      </if>
      <if test="record.client != null">
        `client` = #{record.client},
      </if>
      <if test="record.isInstance != null">
        `is_instance` = #{record.isInstance},
      </if>
      <if test="record.image != null">
        `image` = #{record.image},
      </if>
      <if test="record.desc != null">
        `desc` = #{record.desc},
      </if>
      <if test="record.data != null">
        `data` = #{record.data},
      </if>
      <if test="record.defaultData != null">
        `default_data` = #{record.defaultData},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `sys_tpl_pc`
    <trim prefix="SET" suffixOverrides=",">
      <if test="type != null">
        `type` = #{type},
      </if>
      <if test="code != null">
        `code` = #{code},
      </if>
      <if test="typeName != null">
        `type_name` = #{typeName},
      </if>
      <if test="name != null">
        `name` = #{name},
      </if>
      <if test="sort != null">
        `sort` = #{sort},
      </if>
      <if test="isEnable != null">
        `is_enable` = #{isEnable},
      </if>
      <if test="client != null">
        `client` = #{client},
      </if>
      <if test="isInstance != null">
        `is_instance` = #{isInstance},
      </if>
      <if test="image != null">
        `image` = #{image},
      </if>
      <if test="desc != null">
        `desc` = #{desc},
      </if>
      <if test="data != null">
        `data` = #{data},
      </if>
      <if test="defaultData != null">
        `default_data` = #{defaultData},
      </if>
    </trim>
    WHERE `tpl_pc_id` = #{tplPcId}
  </update>
</mapper>