<?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.neusoft.smart.pos.member.persistent.mapper.MemberMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.member.persistent.domain.Member">
    <id column="member_id" jdbcType="INTEGER" property="memberId" />
    <result column="member_store_id" jdbcType="INTEGER" property="memberStoreId" />
    <result column="member_name" jdbcType="VARCHAR" property="memberName" />
    <result column="member_mobile" jdbcType="VARCHAR" property="memberMobile" />
    <result column="member_birthday" jdbcType="DATE" property="memberBirthday" />
    <result column="member_email" jdbcType="VARCHAR" property="memberEmail" />
    <result column="member_code" jdbcType="VARCHAR" property="memberCode" />
    <result column="member_type" jdbcType="INTEGER" property="memberType" />
    <result column="gender" jdbcType="INTEGER" property="gender" />
    <result column="address" jdbcType="VARCHAR" property="address" />
    <result column="avatar" jdbcType="VARCHAR" property="avatar" />
    <result column="is_active" jdbcType="INTEGER" property="isActive" />
    <result column="content" jdbcType="VARCHAR" property="content" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
    <result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
    <result column="member_org_id" jdbcType="INTEGER" property="memberOrgId" />
    <result column="openid" jdbcType="VARCHAR" property="openid" />
    <result column="member_level_id" jdbcType="INTEGER" property="memberLevelId" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
  </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">
    member_id, member_store_id, member_name, member_mobile, member_birthday, member_email, 
    member_code, member_type, gender, address, avatar, is_active, content, version, created_time, 
    created_by, updated_time, updated_by, member_org_id, openid, member_level_id, user_id
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from member
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from member
    where member_id = #{memberId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from member
    where member_id = #{memberId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberExample">
    delete from member
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="member_id" keyProperty="memberId" parameterType="com.neusoft.smart.pos.member.persistent.domain.Member" useGeneratedKeys="true">
    insert into member (member_store_id, member_name, member_mobile, 
      member_birthday, member_email, member_code, 
      member_type, gender, address, 
      avatar, is_active, content, 
      version, created_time, created_by, 
      updated_time, updated_by, member_org_id, 
      openid, member_level_id)
    values (#{memberStoreId,jdbcType=INTEGER}, #{memberName,jdbcType=VARCHAR}, #{memberMobile,jdbcType=VARCHAR}, 
      #{memberBirthday,jdbcType=DATE}, #{memberEmail,jdbcType=VARCHAR}, #{memberCode,jdbcType=VARCHAR}, 
      #{memberType,jdbcType=INTEGER}, #{gender,jdbcType=INTEGER}, #{address,jdbcType=VARCHAR}, 
      #{avatar,jdbcType=VARCHAR}, #{isActive,jdbcType=INTEGER}, #{content,jdbcType=VARCHAR}, 
      #{version,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, 
      #{updatedTime,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, #{memberOrgId,jdbcType=INTEGER}, 
      #{openid,jdbcType=VARCHAR}, #{memberLevelId,jdbcType=INTEGER},
      #{userId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" keyColumn="member_id" keyProperty="memberId" parameterType="com.neusoft.smart.pos.member.persistent.domain.Member" useGeneratedKeys="true">
    insert into member
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="memberStoreId != null">
        member_store_id,
      </if>
      <if test="memberName != null">
        member_name,
      </if>
      <if test="memberMobile != null">
        member_mobile,
      </if>
      <if test="memberBirthday != null">
        member_birthday,
      </if>
      <if test="memberEmail != null">
        member_email,
      </if>
      <if test="memberCode != null">
        member_code,
      </if>
      <if test="memberType != null">
        member_type,
      </if>
      <if test="gender != null">
        gender,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="avatar != null">
        avatar,
      </if>
      <if test="isActive != null">
        is_active,
      </if>
      <if test="content != null">
        content,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
      <if test="memberOrgId != null">
        member_org_id,
      </if>
      <if test="openid != null">
        openid,
      </if>
      <if test="memberLevelId != null">
        member_level_id,
      </if>
      <if test="userId != null">
        user_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="memberStoreId != null">
        #{memberStoreId,jdbcType=INTEGER},
      </if>
      <if test="memberName != null">
        #{memberName,jdbcType=VARCHAR},
      </if>
      <if test="memberMobile != null">
        #{memberMobile,jdbcType=VARCHAR},
      </if>
      <if test="memberBirthday != null">
        #{memberBirthday,jdbcType=DATE},
      </if>
      <if test="memberEmail != null">
        #{memberEmail,jdbcType=VARCHAR},
      </if>
      <if test="memberCode != null">
        #{memberCode,jdbcType=VARCHAR},
      </if>
      <if test="memberType != null">
        #{memberType,jdbcType=INTEGER},
      </if>
      <if test="gender != null">
        #{gender,jdbcType=INTEGER},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="avatar != null">
        #{avatar,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        #{isActive,jdbcType=INTEGER},
      </if>
      <if test="content != null">
        #{content,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="memberOrgId != null">
        #{memberOrgId,jdbcType=INTEGER},
      </if>
      <if test="openid != null">
        #{openid,jdbcType=VARCHAR},
      </if>
      <if test="memberLevelId != null">
        #{memberLevelId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        #{userId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.member.persistent.domain.MemberExample" resultType="java.lang.Integer">
    select count(*) from member
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update member
    <set>
      <if test="record.memberId != null">
        member_id = #{record.memberId,jdbcType=INTEGER},
      </if>
      <if test="record.memberStoreId != null">
        member_store_id = #{record.memberStoreId,jdbcType=INTEGER},
      </if>
      <if test="record.memberName != null">
        member_name = #{record.memberName,jdbcType=VARCHAR},
      </if>
      <if test="record.memberMobile != null">
        member_mobile = #{record.memberMobile,jdbcType=VARCHAR},
      </if>
      <if test="record.memberBirthday != null">
        member_birthday = #{record.memberBirthday,jdbcType=DATE},
      </if>
      <if test="record.memberEmail != null">
        member_email = #{record.memberEmail,jdbcType=VARCHAR},
      </if>
      <if test="record.memberCode != null">
        member_code = #{record.memberCode,jdbcType=VARCHAR},
      </if>
      <if test="record.memberType != null">
        member_type = #{record.memberType,jdbcType=INTEGER},
      </if>
      <if test="record.gender != null">
        gender = #{record.gender,jdbcType=INTEGER},
      </if>
      <if test="record.address != null">
        address = #{record.address,jdbcType=VARCHAR},
      </if>
      <if test="record.avatar != null">
        avatar = #{record.avatar,jdbcType=VARCHAR},
      </if>
      <if test="record.isActive != null">
        is_active = #{record.isActive,jdbcType=INTEGER},
      </if>
      <if test="record.content != null">
        content = #{record.content,jdbcType=VARCHAR},
      </if>
      <if test="record.version != null">
        version = #{record.version,jdbcType=INTEGER},
      </if>
      <if test="record.createdTime != null">
        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
      <if test="record.updatedTime != null">
        updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updatedBy != null">
        updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="record.memberOrgId != null">
        member_org_id = #{record.memberOrgId,jdbcType=INTEGER},
      </if>
      <if test="record.openid != null">
        openid = #{record.openid,jdbcType=VARCHAR},
      </if>
      <if test="record.memberLevelId != null">
        member_level_id = #{record.memberLevelId,jdbcType=INTEGER},
      </if>
      <if test="record.userId != null">
        user_id = #{record.userId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update member
    set member_id = #{record.memberId,jdbcType=INTEGER},
      member_store_id = #{record.memberStoreId,jdbcType=INTEGER},
      member_name = #{record.memberName,jdbcType=VARCHAR},
      member_mobile = #{record.memberMobile,jdbcType=VARCHAR},
      member_birthday = #{record.memberBirthday,jdbcType=DATE},
      member_email = #{record.memberEmail,jdbcType=VARCHAR},
      member_code = #{record.memberCode,jdbcType=VARCHAR},
      member_type = #{record.memberType,jdbcType=INTEGER},
      gender = #{record.gender,jdbcType=INTEGER},
      address = #{record.address,jdbcType=VARCHAR},
      avatar = #{record.avatar,jdbcType=VARCHAR},
      is_active = #{record.isActive,jdbcType=INTEGER},
      content = #{record.content,jdbcType=VARCHAR},
      version = #{record.version,jdbcType=INTEGER},
      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR},
      updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{record.updatedBy,jdbcType=VARCHAR},
      member_org_id = #{record.memberOrgId,jdbcType=INTEGER},
      openid = #{record.openid,jdbcType=VARCHAR},
      member_level_id = #{record.memberLevelId,jdbcType=INTEGER},
      user_id = #{record.userId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.member.persistent.domain.Member">
    update member
    <set>
      <if test="memberStoreId != null">
        member_store_id = #{memberStoreId,jdbcType=INTEGER},
      </if>
      <if test="memberName != null">
        member_name = #{memberName,jdbcType=VARCHAR},
      </if>
      <if test="memberMobile != null">
        member_mobile = #{memberMobile,jdbcType=VARCHAR},
      </if>
      <if test="memberBirthday != null">
        member_birthday = #{memberBirthday,jdbcType=DATE},
      </if>
      <if test="memberEmail != null">
        member_email = #{memberEmail,jdbcType=VARCHAR},
      </if>
      <if test="memberCode != null">
        member_code = #{memberCode,jdbcType=VARCHAR},
      </if>
      <if test="memberType != null">
        member_type = #{memberType,jdbcType=INTEGER},
      </if>
      <if test="gender != null">
        gender = #{gender,jdbcType=INTEGER},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="avatar != null">
        avatar = #{avatar,jdbcType=VARCHAR},
      </if>
      <if test="isActive != null">
        is_active = #{isActive,jdbcType=INTEGER},
      </if>
      <if test="content != null">
        content = #{content,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=VARCHAR},
      </if>
      <if test="memberOrgId != null">
        member_org_id = #{memberOrgId,jdbcType=INTEGER},
      </if>
      <if test="openid != null">
        openid = #{openid,jdbcType=VARCHAR},
      </if>
      <if test="memberLevelId != null">
        member_level_id = #{memberLevelId,jdbcType=INTEGER},
      </if>
      <if test="userId != null">
        user_id = #{userId,jdbcType=INTEGER},
      </if>
    </set>
    where member_id = #{memberId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.member.persistent.domain.Member">
    update member
    set member_store_id = #{memberStoreId,jdbcType=INTEGER},
      member_name = #{memberName,jdbcType=VARCHAR},
      member_mobile = #{memberMobile,jdbcType=VARCHAR},
      member_birthday = #{memberBirthday,jdbcType=DATE},
      member_email = #{memberEmail,jdbcType=VARCHAR},
      member_code = #{memberCode,jdbcType=VARCHAR},
      member_type = #{memberType,jdbcType=INTEGER},
      gender = #{gender,jdbcType=INTEGER},
      address = #{address,jdbcType=VARCHAR},
      avatar = #{avatar,jdbcType=VARCHAR},
      is_active = #{isActive,jdbcType=INTEGER},
      content = #{content,jdbcType=VARCHAR},
      version = #{version,jdbcType=INTEGER},
      created_time = #{createdTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR},
      updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=VARCHAR},
      member_org_id = #{memberOrgId,jdbcType=INTEGER},
      openid = #{openid,jdbcType=VARCHAR},
      member_level_id = #{memberLevelId,jdbcType=INTEGER},
      user_id = #{userId,jdbcType=INTEGER}
    where member_id = #{memberId,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into member  (member_store_id, member_name, member_mobile, 
        member_birthday, member_email, member_code, 
        member_type, gender, address, 
        avatar, is_active, content, 
        version, created_time, created_by, 
        updated_time, updated_by, member_org_id, 
        openid, member_level_id, user_id)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.memberStoreId,jdbcType=INTEGER}, #{item.memberName,jdbcType=VARCHAR}, #{item.memberMobile,jdbcType=VARCHAR}, 
        #{item.memberBirthday,jdbcType=DATE}, #{item.memberEmail,jdbcType=VARCHAR}, #{item.memberCode,jdbcType=VARCHAR}, 
        #{item.memberType,jdbcType=INTEGER}, #{item.gender,jdbcType=INTEGER}, #{item.address,jdbcType=VARCHAR}, 
        #{item.avatar,jdbcType=VARCHAR}, #{item.isActive,jdbcType=INTEGER}, #{item.content,jdbcType=VARCHAR}, 
        #{item.version,jdbcType=INTEGER}, #{item.createdTime,jdbcType=TIMESTAMP}, #{item.createdBy,jdbcType=VARCHAR}, 
        #{item.updatedTime,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=VARCHAR}, #{item.memberOrgId,jdbcType=INTEGER}, 
        #{item.openid,jdbcType=VARCHAR}, #{item.memberLevelId,jdbcType=INTEGER}, #{item.userId,jdbcType=INTEGER})
      </foreach>
    </if>
  </insert>
</mapper>