<?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.community.huiju.dao.TpBillMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpBill" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="bill_name" property="billName" jdbcType="VARCHAR" />
    <result column="bill_explain" property="billExplain" jdbcType="VARCHAR" />
    <result column="pay_price" property="payPrice" jdbcType="CHAR" />
    <result column="pay_total_num" property="payTotalNum" jdbcType="INTEGER" />
    <result column="payed_num" property="payedNum" jdbcType="INTEGER" />
    <result column="unpayed_num" property="unpayedNum" jdbcType="INTEGER" />
    <result column="bill_status" property="billStatus" jdbcType="CHAR" />
    <result column="end_date" property="endDate" jdbcType="TIMESTAMP" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, bill_name, bill_explain, pay_price, pay_total_num, payed_num, unpayed_num, 
    bill_status, end_date, create_user, create_date, update_user, update_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_bill
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectById" resultType="com.community.huiju.model.TpBill">
    SELECT
        t.id,
        t.community_id,
        t.bill_name,
        t.bill_explain,
        t.pay_price,
        t.pay_total_num,
        t.payed_num,
        t.unpayed_num,
        t.bill_status,
        t.end_date,
        t.create_user,
        t.create_date,
        t.update_user,
        t.update_date
    FROM
        tp_bill t
    LEFT JOIN tp_bill_invoice i ON t.id = i.bill_id
    WHERE i.id = #{id,jdbcType=INTEGER}
  </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_bill
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpBill" >
    insert into tp_bill (id, community_id, bill_name, 
      bill_explain, pay_price, pay_total_num, 
      payed_num, unpayed_num, bill_status, 
      end_date, create_user, create_date, 
      update_user, update_date)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{billName,jdbcType=VARCHAR}, 
      #{billExplain,jdbcType=VARCHAR}, #{payPrice,jdbcType=CHAR}, #{payTotalNum,jdbcType=INTEGER}, 
      #{payedNum,jdbcType=INTEGER}, #{unpayedNum,jdbcType=INTEGER}, #{billStatus,jdbcType=CHAR}, 
      #{endDate,jdbcType=TIMESTAMP}, #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpBill" >
    insert into tp_bill
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="billName != null" >
        bill_name,
      </if>
      <if test="billExplain != null" >
        bill_explain,
      </if>
      <if test="payPrice != null" >
        pay_price,
      </if>
      <if test="payTotalNum != null" >
        pay_total_num,
      </if>
      <if test="payedNum != null" >
        payed_num,
      </if>
      <if test="unpayedNum != null" >
        unpayed_num,
      </if>
      <if test="billStatus != null" >
        bill_status,
      </if>
      <if test="endDate != null" >
        end_date,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
      <if test="updateDate != null" >
        update_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="billName != null" >
        #{billName,jdbcType=VARCHAR},
      </if>
      <if test="billExplain != null" >
        #{billExplain,jdbcType=VARCHAR},
      </if>
      <if test="payPrice != null" >
        #{payPrice,jdbcType=CHAR},
      </if>
      <if test="payTotalNum != null" >
        #{payTotalNum,jdbcType=INTEGER},
      </if>
      <if test="payedNum != null" >
        #{payedNum,jdbcType=INTEGER},
      </if>
      <if test="unpayedNum != null" >
        #{unpayedNum,jdbcType=INTEGER},
      </if>
      <if test="billStatus != null" >
        #{billStatus,jdbcType=CHAR},
      </if>
      <if test="endDate != null" >
        #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpBill" >
    update tp_bill
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="billName != null" >
        bill_name = #{billName,jdbcType=VARCHAR},
      </if>
      <if test="billExplain != null" >
        bill_explain = #{billExplain,jdbcType=VARCHAR},
      </if>
      <if test="payPrice != null" >
        pay_price = #{payPrice,jdbcType=CHAR},
      </if>
      <if test="payTotalNum != null" >
        pay_total_num = #{payTotalNum,jdbcType=INTEGER},
      </if>
      <if test="payedNum != null" >
        payed_num = #{payedNum,jdbcType=INTEGER},
      </if>
      <if test="unpayedNum != null" >
        unpayed_num = #{unpayedNum,jdbcType=INTEGER},
      </if>
      <if test="billStatus != null" >
        bill_status = #{billStatus,jdbcType=CHAR},
      </if>
      <if test="endDate != null" >
        end_date = #{endDate,jdbcType=TIMESTAMP},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpBill" >
    update tp_bill
    set community_id = #{communityId,jdbcType=INTEGER},
      bill_name = #{billName,jdbcType=VARCHAR},
      bill_explain = #{billExplain,jdbcType=VARCHAR},
      pay_price = #{payPrice,jdbcType=CHAR},
      pay_total_num = #{payTotalNum,jdbcType=INTEGER},
      payed_num = #{payedNum,jdbcType=INTEGER},
      unpayed_num = #{unpayedNum,jdbcType=INTEGER},
      bill_status = #{billStatus,jdbcType=CHAR},
      end_date = #{endDate,jdbcType=TIMESTAMP},
      create_user = #{createUser,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>