<?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.JtBusinessProjectMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.JtBusinessProject">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="category_id" jdbcType="VARCHAR" property="categoryId" />
    <result column="number" jdbcType="VARCHAR" property="number" />
    <result column="price" jdbcType="DECIMAL" property="price" />
    <result column="activity_price" jdbcType="DECIMAL" property="activityPrice" />
    <result column="member_price" jdbcType="DECIMAL" property="memberPrice" />
    <result column="offset" jdbcType="REAL" property="offset" />
    <result column="activity_flag" jdbcType="INTEGER" property="activityFlag" />
    <result column="introduce" jdbcType="VARCHAR" property="introduce" />
    <result column="province" jdbcType="INTEGER" property="province" />
    <result column="city" jdbcType="INTEGER" property="city" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="min_img_url" jdbcType="VARCHAR" property="minImgUrl" />
    <result column="max_img_url" jdbcType="VARCHAR" property="maxImgUrl" />
    <result column="value" jdbcType="VARCHAR" property="value" />
    <result column="apply_conditions" jdbcType="VARCHAR" property="applyConditions" />
  </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 Jun 20 11:08:54 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 Jun 20 11:08:54 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 Jun 20 11:08:54 CST 2018.
    -->
    id, name, category_id as categoryId, number, price, activity_price as activityPrice, member_price as memberPrice, offset, activity_flag as activityFlag, 
    introduce, province, city, create_time as createTime, min_img_url as minImgUrl, max_img_url as maxImgUrl, value, apply_conditions as applyConditions,owner_id as ownerId
  </sql>
  
    <sql id="My_Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    jtbp.id,  jtbp.name, jtbp.category_id as categoryId,  jtbp.number,  jtbp.price,  jtbp.activity_price as activityPrice,  jtbp.member_price as memberPrice,  jtbp.offset, 
     jtbp.activity_flag as activityFlag, 
     jtbp.introduce, 
      jtbp.province, 
       jtbp.city,  jtbp.create_time as createTime,
         jtbp.min_img_url as minImgUrl,
           jtbp.max_img_url as maxImgUrl, 
            jtbp.value,  jtbp.apply_conditions as applyConditions
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.JtBusinessProjectExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from jt_business_project
    <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.String" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    select 
    <include refid="Base_Column_List" />
    from jt_business_project
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    delete from jt_business_project
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.JtBusinessProjectExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    delete from jt_business_project
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.JtBusinessProject">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    insert into jt_business_project (id, name, category_id, 
      number, price, activity_price, 
      member_price, offset, activity_flag, 
      introduce, province, city, 
      create_time, min_img_url, max_img_url, 
      value, apply_conditions)
    values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR}, 
      #{number,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{activityPrice,jdbcType=DECIMAL}, 
      #{memberPrice,jdbcType=DECIMAL}, #{offset,jdbcType=REAL}, #{activityFlag,jdbcType=INTEGER}, 
      #{introduce,jdbcType=VARCHAR}, #{province,jdbcType=INTEGER}, #{city,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP}, #{minImgUrl,jdbcType=VARCHAR}, #{maxImgUrl,jdbcType=VARCHAR}, 
      #{value,jdbcType=VARCHAR}, #{applyConditions,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.JtBusinessProject">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    insert into jt_business_project
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="categoryId != null">
        category_id,
      </if>
      <if test="number != null">
        number,
      </if>
      <if test="price != null">
        price,
      </if>
      <if test="activityPrice != null">
        activity_price,
      </if>
      <if test="memberPrice != null">
        member_price,
      </if>
      <if test="offset != null">
        offset,
      </if>
      <if test="activityFlag != null">
        activity_flag,
      </if>
      <if test="introduce != null">
        introduce,
      </if>
      <if test="province != null">
        province,
      </if>
      <if test="city != null">
        city,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="minImgUrl != null">
        min_img_url,
      </if>
      <if test="maxImgUrl != null">
        max_img_url,
      </if>
      <if test="value != null">
        value,
      </if>
      <if test="applyConditions != null">
        apply_conditions,
      </if>
      <if test="ownerId!=null">
      owner_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="categoryId != null">
        #{categoryId,jdbcType=VARCHAR},
      </if>
      <if test="number != null">
        #{number,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="activityPrice != null">
        #{activityPrice,jdbcType=DECIMAL},
      </if>
      <if test="memberPrice != null">
        #{memberPrice,jdbcType=DECIMAL},
      </if>
      <if test="offset != null">
        #{offset,jdbcType=REAL},
      </if>
      <if test="activityFlag != null">
        #{activityFlag,jdbcType=INTEGER},
      </if>
      <if test="introduce != null">
        #{introduce,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        #{province,jdbcType=INTEGER},
      </if>
      <if test="city != null">
        #{city,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="minImgUrl != null">
        #{minImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="maxImgUrl != null">
        #{maxImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        #{value,jdbcType=VARCHAR},
      </if>
      <if test="applyConditions != null">
        #{applyConditions,jdbcType=VARCHAR},
      </if>
      <if test="ownerId!=null">
      #{ownerId,jdbcType=VARCHAR}
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.JtBusinessProjectExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    select count(*) from jt_business_project
    <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 Jun 20 11:08:54 CST 2018.
    -->
    update jt_business_project
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.categoryId != null">
        category_id = #{record.categoryId,jdbcType=VARCHAR},
      </if>
      <if test="record.number != null">
        number = #{record.number,jdbcType=VARCHAR},
      </if>
      <if test="record.price != null">
        price = #{record.price,jdbcType=DECIMAL},
      </if>
      <if test="record.activityPrice != null">
        activity_price = #{record.activityPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.memberPrice != null">
        member_price = #{record.memberPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.offset != null">
        offset = #{record.offset,jdbcType=REAL},
      </if>
      <if test="record.activityFlag != null">
        activity_flag = #{record.activityFlag,jdbcType=INTEGER},
      </if>
      <if test="record.introduce != null">
        introduce = #{record.introduce,jdbcType=VARCHAR},
      </if>
      <if test="record.province != null">
        province = #{record.province,jdbcType=INTEGER},
      </if>
      <if test="record.city != null">
        city = #{record.city,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.minImgUrl != null">
        min_img_url = #{record.minImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.maxImgUrl != null">
        max_img_url = #{record.maxImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="record.value != null">
        value = #{record.value,jdbcType=VARCHAR},
      </if>
      <if test="record.applyConditions != null">
        apply_conditions = #{record.applyConditions,jdbcType=VARCHAR},
      </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 Jun 20 11:08:54 CST 2018.
    -->
    update jt_business_project
    set id = #{record.id,jdbcType=VARCHAR},
      name = #{record.name,jdbcType=VARCHAR},
      category_id = #{record.categoryId,jdbcType=VARCHAR},
      number = #{record.number,jdbcType=VARCHAR},
      price = #{record.price,jdbcType=DECIMAL},
      activity_price = #{record.activityPrice,jdbcType=DECIMAL},
      member_price = #{record.memberPrice,jdbcType=DECIMAL},
      offset = #{record.offset,jdbcType=REAL},
      activity_flag = #{record.activityFlag,jdbcType=INTEGER},
      introduce = #{record.introduce,jdbcType=VARCHAR},
      province = #{record.province,jdbcType=INTEGER},
      city = #{record.city,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      min_img_url = #{record.minImgUrl,jdbcType=VARCHAR},
      max_img_url = #{record.maxImgUrl,jdbcType=VARCHAR},
      value = #{record.value,jdbcType=VARCHAR},
      apply_conditions = #{record.applyConditions,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.JtBusinessProject">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    update jt_business_project
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="categoryId != null">
        category_id = #{categoryId,jdbcType=VARCHAR},
      </if>
      <if test="number != null">
        number = #{number,jdbcType=VARCHAR},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="activityPrice != null">
        activity_price = #{activityPrice,jdbcType=DECIMAL},
      </if>
      <if test="memberPrice != null">
        member_price = #{memberPrice,jdbcType=DECIMAL},
      </if>
      <if test="offset != null">
        offset = #{offset,jdbcType=REAL},
      </if>
      <if test="activityFlag != null">
        activity_flag = #{activityFlag,jdbcType=INTEGER},
      </if>
      <if test="introduce != null">
        introduce = #{introduce,jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        province = #{province,jdbcType=INTEGER},
      </if>
      <if test="city != null">
        city = #{city,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="minImgUrl != null">
        min_img_url = #{minImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="maxImgUrl != null">
        max_img_url = #{maxImgUrl,jdbcType=VARCHAR},
      </if>
      <if test="value != null">
        value = #{value,jdbcType=VARCHAR},
      </if>
      <if test="applyConditions != null">
        apply_conditions = #{applyConditions,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.JtBusinessProject">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Wed Jun 20 11:08:54 CST 2018.
    -->
    update jt_business_project
    set name = #{name,jdbcType=VARCHAR},
      category_id = #{categoryId,jdbcType=VARCHAR},
      number = #{number,jdbcType=VARCHAR},
      price = #{price,jdbcType=DECIMAL},
      activity_price = #{activityPrice,jdbcType=DECIMAL},
      member_price = #{memberPrice,jdbcType=DECIMAL},
      offset = #{offset,jdbcType=REAL},
      activity_flag = #{activityFlag,jdbcType=INTEGER},
      introduce = #{introduce,jdbcType=VARCHAR},
      province = #{province,jdbcType=INTEGER},
      city = #{city,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      min_img_url = #{minImgUrl,jdbcType=VARCHAR},
      max_img_url = #{maxImgUrl,jdbcType=VARCHAR},
      value = #{value,jdbcType=VARCHAR},
      apply_conditions = #{applyConditions,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
   <select id="getBusinessProjectByCategoryId" resultType="com.goafanti.common.model.JtBusinessProject">
  select 
  	id,
  	name,
  	introduce
  	from 
  	jt_business_project
  	where 
  	category_id=#{0}
  	 order by create_time
  	limit #{1}
  </select>
  
  <select id="findJtBusinessProjectByPage" resultType="com.goafanti.common.model.JtBusinessProject">
  select 
  <include refid="My_Base_Column_List" />
  from jt_business_project jtbp
  <if test="topId!=null">
  left join jt_business_category jtbc on jtbc.super_id =#{topId,jdbcType=VARCHAR}
  </if>
  where 1=1
  <if test="secondId!=null">
  and jtbp.category_id=#{secondId,jdbcType=VARCHAR}
  </if>
  <if test="name!=null">
  and jtbp.name like concat("%",#{name,jdbcType=VARCHAR},"%")
  </if>
  <if test="topId!=null">
 and jtbc.id=jtbp.category_id
  </if>
  <if test="ownerId!=null">
  and jtbp.owner_id=#{ownerId,jdbcType=VARCHAR}
  </if>
  	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
    <select id="findJtBusinessCountByPage" resultType="java.lang.Integer">
  select 
 count(0)
 from jt_business_project jtbp
  <if test="topId!=null">
  left join jt_business_category jtbc on jtbc.super_id =#{topId,jdbcType=VARCHAR}
  </if>
  where 1=1
  <if test="secondId!=null">
  and jtbp.category_id=#{secondId,jdbcType=VARCHAR}
  </if>
  <if test="name!=null">
  and jtbp.name like concat("%",#{name,jdbcType=VARCHAR},"%")
  </if>
  <if test="topId!=null">
 and jtbc.id=jtbp.category_id
  </if>
    <if test="ownerId!=null">
  and jtbp.owner_id=#{ownerId,jdbcType=VARCHAR}
  </if>
  </select>
  
  <select id="findProjectOrderByNumber" resultType="com.goafanti.common.model.JtBusinessProject">
  select
 <include refid="Base_Column_List" />
  from jt_business_project order by create_time desc
  </select>
</mapper>