<?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="im.zhaojun.system.mapper.UserAuthsMapper">
  <resultMap id="BaseResultMap" type="im.zhaojun.system.model.UserAuths">
    <!--@mbg.generated-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="identity_type" jdbcType="VARCHAR" property="identityType" />
    <result column="identifier" jdbcType="VARCHAR" property="identifier" />
    <result column="credential" jdbcType="VARCHAR" property="credential" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, user_id, identity_type, identifier, credential
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from user_auths
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--@mbg.generated-->
    delete from user_auths
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="im.zhaojun.system.model.UserAuths">
    <!--@mbg.generated-->
    insert into user_auths (user_id, identity_type, identifier, 
      credential)
    values (#{userId,jdbcType=INTEGER}, #{identityType,jdbcType=VARCHAR}, #{identifier,jdbcType=VARCHAR}, 
      #{credential,jdbcType=VARCHAR})
  </insert>
  <update id="updateByPrimaryKey" parameterType="im.zhaojun.system.model.UserAuths">
    <!--@mbg.generated-->
    update user_auths
    set user_id = #{userId,jdbcType=INTEGER},
      identity_type = #{identityType,jdbcType=VARCHAR},
      identifier = #{identifier,jdbcType=VARCHAR},
      credential = #{credential,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="selectOneByIdentityTypeAndUserId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from user_auths
    where identity_type=#{identityType,jdbcType=VARCHAR} and user_id=#{userId,jdbcType=INTEGER}
  </select>

  <select id="selectOneByIdentityTypeAndIdentifier" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from user_auths
    where identity_type=#{identityType,jdbcType=VARCHAR} and identifier=#{identifier,jdbcType=VARCHAR}
  </select>


  <select id="selectOneByIdentifier" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from user_auths
    where identifier=#{identifier,jdbcType=VARCHAR} limit 1
  </select>

  <delete id="deleteByUserId">
        delete
        from user_auths
        where user_id = #{userId,jdbcType=INTEGER}
  </delete>

</mapper>