<?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="cn.superdesk.uniorder.dao.mapper.sys.SysConfigMapper">
  <resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.sys.SysConfig">

    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="value_date" jdbcType="TIMESTAMP" property="valueDate" />
    <result column="value_int" jdbcType="INTEGER" property="valueInt" />
    <result column="value_str1" jdbcType="VARCHAR" property="valueStr1" />
    <result column="value_str2" jdbcType="VARCHAR" property="valueStr2" />
    <result column="value_str3" jdbcType="VARCHAR" property="valueStr3" />
    <result column="value_double" jdbcType="DECIMAL" property="valueDouble" />
  </resultMap>
  <sql id="Example_Where_Clause">

    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">

    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">

    id, code, description, value_date, value_int, value_str1, value_str2, value_str3, 
    value_double
  </sql>
  <select id="selectByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfigExample" resultMap="BaseResultMap">

    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from sys_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">

    select 
    <include refid="Base_Column_List" />
    from sys_config
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">

    delete from sys_config
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfigExample">

    delete from sys_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfig">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_config (code, description, value_date, 
      value_int, value_str1, value_str2, 
      value_str3, value_double)
    values (#{code,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{valueDate,jdbcType=TIMESTAMP}, 
      #{valueInt,jdbcType=INTEGER}, #{valueStr1,jdbcType=VARCHAR}, #{valueStr2,jdbcType=VARCHAR}, 
      #{valueStr3,jdbcType=VARCHAR}, #{valueDouble,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfig">

    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into sys_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="valueDate != null">
        value_date,
      </if>
      <if test="valueInt != null">
        value_int,
      </if>
      <if test="valueStr1 != null">
        value_str1,
      </if>
      <if test="valueStr2 != null">
        value_str2,
      </if>
      <if test="valueStr3 != null">
        value_str3,
      </if>
      <if test="valueDouble != null">
        value_double,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="valueDate != null">
        #{valueDate,jdbcType=TIMESTAMP},
      </if>
      <if test="valueInt != null">
        #{valueInt,jdbcType=INTEGER},
      </if>
      <if test="valueStr1 != null">
        #{valueStr1,jdbcType=VARCHAR},
      </if>
      <if test="valueStr2 != null">
        #{valueStr2,jdbcType=VARCHAR},
      </if>
      <if test="valueStr3 != null">
        #{valueStr3,jdbcType=VARCHAR},
      </if>
      <if test="valueDouble != null">
        #{valueDouble,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfigExample" resultType="java.lang.Long">

    select count(*) from sys_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">

    update sys_config
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.code != null">
        code = #{record.code,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null">
        description = #{record.description,jdbcType=VARCHAR},
      </if>
      <if test="record.valueDate != null">
        value_date = #{record.valueDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.valueInt != null">
        value_int = #{record.valueInt,jdbcType=INTEGER},
      </if>
      <if test="record.valueStr1 != null">
        value_str1 = #{record.valueStr1,jdbcType=VARCHAR},
      </if>
      <if test="record.valueStr2 != null">
        value_str2 = #{record.valueStr2,jdbcType=VARCHAR},
      </if>
      <if test="record.valueStr3 != null">
        value_str3 = #{record.valueStr3,jdbcType=VARCHAR},
      </if>
      <if test="record.valueDouble != null">
        value_double = #{record.valueDouble,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">

    update sys_config
    set id = #{record.id,jdbcType=BIGINT},
      code = #{record.code,jdbcType=VARCHAR},
      description = #{record.description,jdbcType=VARCHAR},
      value_date = #{record.valueDate,jdbcType=TIMESTAMP},
      value_int = #{record.valueInt,jdbcType=INTEGER},
      value_str1 = #{record.valueStr1,jdbcType=VARCHAR},
      value_str2 = #{record.valueStr2,jdbcType=VARCHAR},
      value_str3 = #{record.valueStr3,jdbcType=VARCHAR},
      value_double = #{record.valueDouble,jdbcType=DECIMAL}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfig">

    update sys_config
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="valueDate != null">
        value_date = #{valueDate,jdbcType=TIMESTAMP},
      </if>
      <if test="valueInt != null">
        value_int = #{valueInt,jdbcType=INTEGER},
      </if>
      <if test="valueStr1 != null">
        value_str1 = #{valueStr1,jdbcType=VARCHAR},
      </if>
      <if test="valueStr2 != null">
        value_str2 = #{valueStr2,jdbcType=VARCHAR},
      </if>
      <if test="valueStr3 != null">
        value_str3 = #{valueStr3,jdbcType=VARCHAR},
      </if>
      <if test="valueDouble != null">
        value_double = #{valueDouble,jdbcType=DECIMAL},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.sys.SysConfig">

    update sys_config
    set code = #{code,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      value_date = #{valueDate,jdbcType=TIMESTAMP},
      value_int = #{valueInt,jdbcType=INTEGER},
      value_str1 = #{valueStr1,jdbcType=VARCHAR},
      value_str2 = #{valueStr2,jdbcType=VARCHAR},
      value_str3 = #{valueStr3,jdbcType=VARCHAR},
      value_double = #{valueDouble,jdbcType=DECIMAL}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>