<?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.microservices.wiki.mapper.members.MembersMapper">
    <resultMap id="BaseResultMap" type="com.microservices.wiki.domain.members.Members">
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="project_id" property="projectId" jdbcType="INTEGER" />
    <result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
    <result column="mail_notification" property="mailNotification" jdbcType="BIT" />
    <result column="course_id" property="courseId" jdbcType="INTEGER" />
    <result column="course_group_id" property="courseGroupId" jdbcType="INTEGER" />
    <result column="is_collect" property="isCollect" jdbcType="INTEGER" />
    <result column="graduation_group_id" property="graduationGroupId" jdbcType="INTEGER" />
    <result column="is_apply_signature" property="isApplySignature" jdbcType="BIT" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, project_id, created_on, mail_notification, course_id, course_group_id, 
    is_collect, graduation_group_id, is_apply_signature
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from members
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from members
    where id = #{id,jdbcType=INTEGER}
  </delete>
    <insert id="insert" parameterType="com.microservices.wiki.domain.members.Members">
    insert into members (id, user_id, project_id, 
      created_on, mail_notification, course_id, 
      course_group_id, is_collect, graduation_group_id, 
      is_apply_signature)
    values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{projectId,jdbcType=INTEGER}, 
      #{createdOn,jdbcType=TIMESTAMP}, #{mailNotification,jdbcType=BIT}, #{courseId,jdbcType=INTEGER}, 
      #{courseGroupId,jdbcType=INTEGER}, #{isCollect,jdbcType=INTEGER}, #{graduationGroupId,jdbcType=INTEGER}, 
      #{isApplySignature,jdbcType=BIT})
  </insert>
    <insert id="insertSelective" parameterType="com.microservices.wiki.domain.members.Members">
    insert into members
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="projectId != null" >
        project_id,
      </if>
      <if test="createdOn != null" >
        created_on,
      </if>
      <if test="mailNotification != null" >
        mail_notification,
      </if>
      <if test="courseId != null" >
        course_id,
      </if>
      <if test="courseGroupId != null" >
        course_group_id,
      </if>
      <if test="isCollect != null" >
        is_collect,
      </if>
      <if test="graduationGroupId != null" >
        graduation_group_id,
      </if>
      <if test="isApplySignature != null" >
        is_apply_signature,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="userId != null" >
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="projectId != null" >
        #{projectId,jdbcType=INTEGER},
      </if>
      <if test="createdOn != null" >
        #{createdOn,jdbcType=TIMESTAMP},
      </if>
      <if test="mailNotification != null" >
        #{mailNotification,jdbcType=BIT},
      </if>
      <if test="courseId != null" >
        #{courseId,jdbcType=INTEGER},
      </if>
      <if test="courseGroupId != null" >
        #{courseGroupId,jdbcType=INTEGER},
      </if>
      <if test="isCollect != null" >
        #{isCollect,jdbcType=INTEGER},
      </if>
      <if test="graduationGroupId != null" >
        #{graduationGroupId,jdbcType=INTEGER},
      </if>
      <if test="isApplySignature != null" >
        #{isApplySignature,jdbcType=BIT},
      </if>
    </trim>
  </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.microservices.wiki.domain.members.Members">
    update members
    <set >
      <if test="userId != null" >
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="projectId != null" >
        project_id = #{projectId,jdbcType=INTEGER},
      </if>
      <if test="createdOn != null" >
        created_on = #{createdOn,jdbcType=TIMESTAMP},
      </if>
      <if test="mailNotification != null" >
        mail_notification = #{mailNotification,jdbcType=BIT},
      </if>
      <if test="courseId != null" >
        course_id = #{courseId,jdbcType=INTEGER},
      </if>
      <if test="courseGroupId != null" >
        course_group_id = #{courseGroupId,jdbcType=INTEGER},
      </if>
      <if test="isCollect != null" >
        is_collect = #{isCollect,jdbcType=INTEGER},
      </if>
      <if test="graduationGroupId != null" >
        graduation_group_id = #{graduationGroupId,jdbcType=INTEGER},
      </if>
      <if test="isApplySignature != null" >
        is_apply_signature = #{isApplySignature,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
    <update id="updateByPrimaryKey" parameterType="com.microservices.wiki.domain.members.Members">
    update members
    set user_id = #{userId,jdbcType=INTEGER},
      project_id = #{projectId,jdbcType=INTEGER},
      created_on = #{createdOn,jdbcType=TIMESTAMP},
      mail_notification = #{mailNotification,jdbcType=BIT},
      course_id = #{courseId,jdbcType=INTEGER},
      course_group_id = #{courseGroupId,jdbcType=INTEGER},
      is_collect = #{isCollect,jdbcType=INTEGER},
      graduation_group_id = #{graduationGroupId,jdbcType=INTEGER},
      is_apply_signature = #{isApplySignature,jdbcType=BIT}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="doesMemberExist" resultType="java.lang.Integer">
    select count(*)
    from members
    where user_id = #{userId} and project_id = #{projectId}
  </select>
</mapper>