<?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.buy507.mall.mapper.DmsTeamMemberNumberMapper">
  <resultMap id="BaseResultMap" type="com.buy507.mall.model.DmsTeamMemberNumber">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="member_id" jdbcType="BIGINT" property="memberId" />
    <result column="total" jdbcType="INTEGER" property="total" />
    <result column="consumer" jdbcType="INTEGER" property="consumer" />
    <result column="partner" jdbcType="INTEGER" property="partner" />
    <result column="one_diamond" jdbcType="INTEGER" property="oneDiamond" />
    <result column="two_diamond" jdbcType="INTEGER" property="twoDiamond" />
    <result column="three_diamond" jdbcType="INTEGER" property="threeDiamond" />
    <result column="four_diamond" jdbcType="INTEGER" property="fourDiamond" />
  </resultMap>
  
  <select id="selectOneByMemberId" parameterType="java.lang.Long" resultMap="BaseResultMap">
    SELECT *
      FROM dms_team_member_number
     WHERE member_id = #{memberId}
  </select>
  
  <insert id="insert" parameterType="com.buy507.mall.model.DmsTeamMemberNumber">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into dms_team_member_number (member_id, total, consumer, partner, one_diamond, two_diamond, three_diamond, four_diamond)
    values (#{memberId,jdbcType=BIGINT}, #{total,jdbcType=INTEGER}, #{consumer,jdbcType=INTEGER}, #{partner,jdbcType=INTEGER}
    			, #{oneDiamond,jdbcType=INTEGER}, #{twoDiamond,jdbcType=INTEGER}, #{threeDiamond,jdbcType=INTEGER}, #{fourDiamond,jdbcType=INTEGER})
  </insert>
  
  <update id="updateById" parameterType="com.buy507.mall.model.DmsTeamMemberNumber">
    update dms_team_member_number
       set total = #{total,jdbcType=INTEGER},
       	   consumer = #{consumer,jdbcType=INTEGER},
       	   one_diamond = #{oneDiamond,jdbcType=INTEGER},
       	   two_diamond = #{twoDiamond,jdbcType=INTEGER},
       	   three_diamond = #{threeDiamond,jdbcType=INTEGER},
	       four_diamond = #{fourDiamond,jdbcType=INTEGER}
     where id = #{id,jdbcType=BIGINT}
  </update>
  
</mapper>