<?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.JpushEasemobAccountMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.JpushEasemobAccount">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="uuid" jdbcType="VARCHAR" property="uuid" />
    <result column="registration_id" jdbcType="VARCHAR" property="registrationId" />
    <result column="uid" jdbcType="VARCHAR" property="uid" />
    <result column="tag" jdbcType="VARCHAR" property="tag" />
    <result column="group_id" jdbcType="VARCHAR" property="groupId" />
    <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime" />
    <result column="easemob_name" jdbcType="VARCHAR" property="easemobName" />
    <result column="easemob_pass" jdbcType="VARCHAR" property="easemobPass" />
  </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 Mon Dec 25 14:46:37 CST 2017.
    -->
    <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 Mon Dec 25 14:46:37 CST 2017.
    -->
    <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 Mon Dec 25 14:46:37 CST 2017.
    -->
    id, uuid, registration_id, uid, tag, group_id, last_login_time, easemob_name, easemob_pass
  </sql>
  <select id="selectByExample" parameterType="com.goafanti.common.model.JpushEasemobAccountExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from jpush_easemob_account
    <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.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    select 
    <include refid="Base_Column_List" />
    from jpush_easemob_account
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    delete from jpush_easemob_account
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.goafanti.common.model.JpushEasemobAccountExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    delete from jpush_easemob_account
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.JpushEasemobAccount">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    insert into jpush_easemob_account (id, uuid, registration_id, 
      uid, tag, group_id, 
      last_login_time, easemob_name, easemob_pass
      )
    values (#{id,jdbcType=INTEGER}, #{uuid,jdbcType=VARCHAR}, #{registrationId,jdbcType=VARCHAR}, 
      #{uid,jdbcType=VARCHAR}, #{tag,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR}, 
      #{lastLoginTime,jdbcType=TIMESTAMP}, #{easemobName,jdbcType=VARCHAR}, #{easemobPass,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.JpushEasemobAccount">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    insert into jpush_easemob_account
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="uuid != null">
        uuid,
      </if>
      <if test="registrationId != null">
        registration_id,
      </if>
      <if test="uid != null">
        uid,
      </if>
      <if test="tag != null">
        tag,
      </if>
      <if test="groupId != null">
        group_id,
      </if>
      <if test="lastLoginTime != null">
        last_login_time,
      </if>
      <if test="easemobName != null">
        easemob_name,
      </if>
      <if test="easemobPass != null">
        easemob_pass,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="uuid != null">
        #{uuid,jdbcType=VARCHAR},
      </if>
      <if test="registrationId != null">
        #{registrationId,jdbcType=VARCHAR},
      </if>
      <if test="uid != null">
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="tag != null">
        #{tag,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null">
        #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="lastLoginTime != null">
        #{lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="easemobName != null">
        #{easemobName,jdbcType=VARCHAR},
      </if>
      <if test="easemobPass != null">
        #{easemobPass,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.goafanti.common.model.JpushEasemobAccountExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    select count(*) from jpush_easemob_account
    <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 Mon Dec 25 14:46:37 CST 2017.
    -->
    update jpush_easemob_account
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.uuid != null">
        uuid = #{record.uuid,jdbcType=VARCHAR},
      </if>
      <if test="record.registrationId != null">
        registration_id = #{record.registrationId,jdbcType=VARCHAR},
      </if>
      <if test="record.uid != null">
        uid = #{record.uid,jdbcType=VARCHAR},
      </if>
      <if test="record.tag != null">
        tag = #{record.tag,jdbcType=VARCHAR},
      </if>
      <if test="record.groupId != null">
        group_id = #{record.groupId,jdbcType=VARCHAR},
      </if>
      <if test="record.lastLoginTime != null">
        last_login_time = #{record.lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.easemobName != null">
        easemob_name = #{record.easemobName,jdbcType=VARCHAR},
      </if>
      <if test="record.easemobPass != null">
        easemob_pass = #{record.easemobPass,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 Mon Dec 25 14:46:37 CST 2017.
    -->
    update jpush_easemob_account
    set id = #{record.id,jdbcType=INTEGER},
      uuid = #{record.uuid,jdbcType=VARCHAR},
      registration_id = #{record.registrationId,jdbcType=VARCHAR},
      uid = #{record.uid,jdbcType=VARCHAR},
      tag = #{record.tag,jdbcType=VARCHAR},
      group_id = #{record.groupId,jdbcType=VARCHAR},
      last_login_time = #{record.lastLoginTime,jdbcType=TIMESTAMP},
      easemob_name = #{record.easemobName,jdbcType=VARCHAR},
      easemob_pass = #{record.easemobPass,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.JpushEasemobAccount">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    update jpush_easemob_account
    <set>
      <if test="uuid != null">
        uuid = #{uuid,jdbcType=VARCHAR},
      </if>
      <if test="registrationId != null">
        registration_id = #{registrationId,jdbcType=VARCHAR},
      </if>
      <if test="uid != null">
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="tag != null">
        tag = #{tag,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null">
        group_id = #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="lastLoginTime != null">
        last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
      </if>
      <if test="easemobName != null">
        easemob_name = #{easemobName,jdbcType=VARCHAR},
      </if>
      <if test="easemobPass != null">
        easemob_pass = #{easemobPass,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.JpushEasemobAccount">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon Dec 25 14:46:37 CST 2017.
    -->
    update jpush_easemob_account
    set uuid = #{uuid,jdbcType=VARCHAR},
      registration_id = #{registrationId,jdbcType=VARCHAR},
      uid = #{uid,jdbcType=VARCHAR},
      tag = #{tag,jdbcType=VARCHAR},
      group_id = #{groupId,jdbcType=VARCHAR},
      last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
      easemob_name = #{easemobName,jdbcType=VARCHAR},
      easemob_pass = #{easemobPass,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectSynAccByUid" parameterType="java.lang.String" resultMap="BaseResultMap">
  	select 
    <include refid="Base_Column_List" />
    from jpush_easemob_account
    where uid = #{uid,jdbcType=VARCHAR}
  </select>
  
  
  <select id="findJpushClientsByType" resultType="com.goafanti.user.bo.ClientListBo">
  select jea.uid,
  u.identify_name as name,u.society_tag as societyTag,u.create_time as createTime,c.contacts,c.contact_mobile as contactMobile,dg.name as provinceS,fg.name as industryS,
  <if test="clientType!=null and clientType==0">
  i.province as province,
  </if>
    <if test="clientType!=null and clientType==1">
  i.licence_province as province,
  </if>
   <if test="clientType!=null and clientType==0">
  i.industry as industry
  </if>
   <if test="clientType!=null and clientType==1">
  i.field as field
  </if>
   from jpush_easemob_account jea
   left join user u on u.id=jea.uid
   <if test="clientType!=null and clientType==0">
   left join user_identity i on i.uid =jea.uid
   </if>
   <if test="clientType!=null and clientType==1">
   left join organization_identity i on i.uid =jea.uid
   </if>
   left join contract c on c.uid=u.id
   <if test="clientType!=null and clientType==0">
      left join district_glossory dg on dg.id=i.province
   </if>
    <if test="clientType!=null and clientType==1">
      left join district_glossory dg on dg.id=i.licence_province
   </if>
    <if test="clientType!=null and clientType==0">
      left join field_glossory fg on fg.id=i.industry
   </if>
    <if test="clientType!=null and clientType==1">
      left join field_glossory fg on fg.id=i.field
   </if>
   where i.uid=jea.uid
 	<if test="page_sql!=null">
		${page_sql}
	</if>
  </select>
    <select id="findJpushClientsCountByType" resultType="java.lang.Integer">
   select count(0)
   from jpush_easemob_account jea
   left join user u on u.id=jea.uid
   <if test="clientType!=null and clientType==0">
   left join user_identity i on i.uid =jea.uid
   </if>
   <if test="clientType!=null and clientType==1">
   left join organization_identity i on i.uid =jea.uid
   </if>
   left join contract c on c.uid=u.id
   where i.uid=jea.uid
  </select>
  
</mapper>