<?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.PluginConfigWriteMapper">
  <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.PluginConfig">
    <id column="p_id" property="pId" />
    <result column="plugin_id" property="pluginId" />
    <result column="plugin_config" property="pluginConfig" />
    <result column="version" property="version" />
    <result column="is_enable" property="isEnable" />
    <result column="install_date" property="installDate" />
    <result column="update_date" property="updateDate" />
    <result column="sort" property="sort" />
  </resultMap>
  <!--除主键外的所有字段，用于插入操作-->
  <sql id="columns">
    <trim suffixOverrides=",">
      <if test="pId != null">
        `p_id`,
      </if>
      <if test="pluginId != null">
        `plugin_id`,
      </if>
      <if test="pluginConfig != null">
        `plugin_config`,
      </if>
      <if test="version != null">
        `version`,
      </if>
      <if test="isEnable != null">
        `is_enable`,
      </if>
      <if test="installDate != null">
        `install_date`,
      </if>
      <if test="updateDate != null">
        `update_date`,
      </if>
      <if test="sort != null">
        `sort`,
      </if>
    </trim>
  </sql>
  <!--按照主键值进行操作-->
  <sql id="pkWhere">
    WHERE `p_id` = #{primaryKey}
  </sql>
  <!--操作条件-->
  <sql id="whereCondition">
    <if test="example != null">
      <trim prefix="WHERE" prefixOverrides="AND|OR">
        <if test="example.pIdNotEquals != null">
          AND `p_id` != #{example.pIdNotEquals}
        </if>
        <if test="example.pIdIn != null">
          AND `p_id` in (${example.pIdIn})
        </if>
        <if test="example.pluginId != null">
          AND `plugin_id` = #{example.pluginId}
        </if>
        <if test="example.pluginConfig != null">
          AND `plugin_config` = #{example.pluginConfig}
        </if>
        <if test="example.version != null">
          AND `version` = #{example.version}
        </if>
        <if test="example.isEnable != null">
          AND `is_enable` = #{example.isEnable}
        </if>
        <if test="example.installDateAfter != null">
          AND `install_date` <![CDATA[ >= ]]> #{example.installDateAfter}
        </if>
        <if test="example.installDateBefore != null">
          AND `install_date` <![CDATA[ <= ]]> #{example.installDateBefore}
        </if>
        <if test="example.updateDateAfter != null">
          AND `update_date` <![CDATA[ >= ]]> #{example.updateDateAfter}
        </if>
        <if test="example.updateDateBefore != null">
          AND `update_date` <![CDATA[ <= ]]> #{example.updateDateBefore}
        </if>
        <if test="example.sort != null">
          AND `sort` = #{example.sort}
        </if>
      </trim>
    </if>
  </sql>
  <!--排序条件-->
  <sql id="orderBy">
    ORDER BY `p_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.PluginConfigExample" resultType="java.lang.Integer">
    SELECT
      COUNT(*)
    FROM `sys_plugin_config`
    <include refid="whereCondition" />
  </select>
  <!--根据主键查询记录-->
  <select id="getByPrimaryKey" resultMap="resultMap">
    SELECT
      *
    FROM `sys_plugin_config`
    <include refid="pkWhere" />
  </select>
  <!--查询符合条件的记录(所有字段)-->
  <select id="listByExample" resultMap="resultMap">
    SELECT
      *
    FROM `sys_plugin_config`
    <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_plugin_config`
    <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_plugin_config`
    <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_plugin_config`
    <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_plugin_config`
    <include refid="whereCondition" />
  </delete>
  <!--根据主键删除记录-->
  <delete id="deleteByPrimaryKey">
    DELETE FROM `sys_plugin_config`
    <include refid="pkWhere" />
  </delete>
  <!--插入一条记录-->
  <insert id="insert" keyColumn="p_id" keyProperty="pId" parameterType="com.slodon.b2b2c.system.pojo.PluginConfig" useGeneratedKeys="true">
    INSERT INTO `sys_plugin_config`(
    <include refid="columns" />
    )
    VALUES(
    <trim suffixOverrides=",">
      <if test="pId != null">
        #{pId},
      </if>
      <if test="pluginId != null">
        #{pluginId},
      </if>
      <if test="pluginConfig != null">
        #{pluginConfig},
      </if>
      <if test="version != null">
        #{version},
      </if>
      <if test="isEnable != null">
        #{isEnable},
      </if>
      <if test="installDate != null">
        #{installDate},
      </if>
      <if test="updateDate != null">
        #{updateDate},
      </if>
      <if test="sort != null">
        #{sort},
      </if>
    </trim>
    )
  </insert>
  <!--按条件更新记录中不为空的字段-->
  <update id="updateByExampleSelective">
    UPDATE `sys_plugin_config`
    <trim prefix="SET" suffixOverrides=",">
      <if test="record.pluginId != null">
        `plugin_id` = #{record.pluginId},
      </if>
      <if test="record.pluginConfig != null">
        `plugin_config` = #{record.pluginConfig},
      </if>
      <if test="record.version != null">
        `version` = #{record.version},
      </if>
      <if test="record.isEnable != null">
        `is_enable` = #{record.isEnable},
      </if>
      <if test="record.installDate != null">
        `install_date` = #{record.installDate},
      </if>
      <if test="record.updateDate != null">
        `update_date` = #{record.updateDate},
      </if>
      <if test="record.sort != null">
        `sort` = #{record.sort},
      </if>
    </trim>
    <include refid="whereCondition" />
  </update>
  <!--按照主键更新记录中不为空的字段-->
  <update id="updateByPrimaryKeySelective">
    UPDATE `sys_plugin_config`
    <trim prefix="SET" suffixOverrides=",">
      <if test="pluginId != null">
        `plugin_id` = #{pluginId},
      </if>
      <if test="pluginConfig != null">
        `plugin_config` = #{pluginConfig},
      </if>
      <if test="version != null">
        `version` = #{version},
      </if>
      <if test="isEnable != null">
        `is_enable` = #{isEnable},
      </if>
      <if test="installDate != null">
        `install_date` = #{installDate},
      </if>
      <if test="updateDate != null">
        `update_date` = #{updateDate},
      </if>
      <if test="sort != null">
        `sort` = #{sort},
      </if>
    </trim>
    WHERE `p_id` = #{pId}
  </update>
</mapper>