<?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.goafanti.common.dao.AppConfigMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.AppConfig">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="release_version" jdbcType="VARCHAR" property="releaseVersion" />
    <result column="release_desc" jdbcType="VARCHAR" property="releaseDesc" />
    <result column="release_date" jdbcType="TIMESTAMP" property="releaseDate" />
    <result column="app_url" jdbcType="VARCHAR" property="appUrl" />
    <result column="force_update" jdbcType="INTEGER" property="forceUpdate" />
    <result column="release_code" jdbcType="INTEGER" property="releaseCode" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    <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">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    id, release_version, release_desc, release_date, app_url, force_update, release_code
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.AppConfigExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from app_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.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from app_config
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    delete from app_config
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.AppConfigExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    delete from app_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.AppConfig">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    insert into app_config (id, release_version, release_desc, 
      release_date, app_url, force_update, 
      release_code)
    values (#{id,jdbcType=INTEGER}, #{releaseVersion,jdbcType=VARCHAR}, #{releaseDesc,jdbcType=VARCHAR}, 
      #{releaseDate,jdbcType=TIMESTAMP}, #{appUrl,jdbcType=VARCHAR}, #{forceUpdate,jdbcType=INTEGER}, 
      #{releaseCode,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.AppConfig">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    insert into app_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="releaseVersion != null">
        release_version,
      </if>
      <if test="releaseDesc != null">
        release_desc,
      </if>
      <if test="releaseDate != null">
        release_date,
      </if>
      <if test="appUrl != null">
        app_url,
      </if>
      <if test="forceUpdate != null">
        force_update,
      </if>
      <if test="releaseCode != null">
        release_code,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="releaseVersion != null">
        #{releaseVersion,jdbcType=VARCHAR},
      </if>
      <if test="releaseDesc != null">
        #{releaseDesc,jdbcType=VARCHAR},
      </if>
      <if test="releaseDate != null">
        #{releaseDate,jdbcType=TIMESTAMP},
      </if>
      <if test="appUrl != null">
        #{appUrl,jdbcType=VARCHAR},
      </if>
      <if test="forceUpdate != null">
        #{forceUpdate,jdbcType=INTEGER},
      </if>
      <if test="releaseCode != null">
        #{releaseCode,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.AppConfigExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    select count(*) from app_config
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    update app_config
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.releaseVersion != null">
        release_version = #{record.releaseVersion,jdbcType=VARCHAR},
      </if>
      <if test="record.releaseDesc != null">
        release_desc = #{record.releaseDesc,jdbcType=VARCHAR},
      </if>
      <if test="record.releaseDate != null">
        release_date = #{record.releaseDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.appUrl != null">
        app_url = #{record.appUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.forceUpdate != null">
        force_update = #{record.forceUpdate,jdbcType=INTEGER},
      </if>
      <if test="record.releaseCode != null">
        release_code = #{record.releaseCode,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    update app_config
    set id = #{record.id,jdbcType=INTEGER},
      release_version = #{record.releaseVersion,jdbcType=VARCHAR},
      release_desc = #{record.releaseDesc,jdbcType=VARCHAR},
      release_date = #{record.releaseDate,jdbcType=TIMESTAMP},
      app_url = #{record.appUrl,jdbcType=VARCHAR},
      force_update = #{record.forceUpdate,jdbcType=INTEGER},
      release_code = #{record.releaseCode,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AppConfig">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    update app_config
    <set>
      <if test="releaseVersion != null">
        release_version = #{releaseVersion,jdbcType=VARCHAR},
      </if>
      <if test="releaseDesc != null">
        release_desc = #{releaseDesc,jdbcType=VARCHAR},
      </if>
      <if test="releaseDate != null">
        release_date = #{releaseDate,jdbcType=TIMESTAMP},
      </if>
      <if test="appUrl != null">
        app_url = #{appUrl,jdbcType=VARCHAR},
      </if>
      <if test="forceUpdate != null">
        force_update = #{forceUpdate,jdbcType=INTEGER},
      </if>
      <if test="releaseCode != null">
        release_code = #{releaseCode,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.AppConfig">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jan 24 16:21:41 CST 2018.
    -->
    update app_config
    set release_version = #{releaseVersion,jdbcType=VARCHAR},
      release_desc = #{releaseDesc,jdbcType=VARCHAR},
      release_date = #{releaseDate,jdbcType=TIMESTAMP},
      app_url = #{appUrl,jdbcType=VARCHAR},
      force_update = #{forceUpdate,jdbcType=INTEGER},
      release_code = #{releaseCode,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="getAppRelease" resultType="com.goafanti.app.bo.AppConfigBo">
  	select  
  		release_version as releaseVersion, 
	  	release_desc as releaseDesc, 
	  	date_format(release_date, '%Y-%m-%d %H:%I:%S') as releaseDate, 
	  	app_url as appUrl, 
	  	force_update forceUpdate, 
	  	release_code releaseCode
  	from 
  		app_config 
  	order by id desc limit 1
  </select>
</mapper>