<?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.community.huiju.dao.ToSysUserRoleMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.ToSysUserRole" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="role_id" property="roleId" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, role_id
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from to_sys_user_role
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from to_sys_user_role
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.ToSysUserRole" >
    insert into to_sys_user_role (id, user_id, role_id
      )
    values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.ToSysUserRole" >
    insert into to_sys_user_role
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="userId != null" >
        user_id,
      </if>
      <if test="roleId != null" >
        role_id,
      </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="roleId != null" >
        #{roleId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToSysUserRole" >
    update to_sys_user_role
    <set >
      <if test="userId != null" >
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="roleId != null" >
        role_id = #{roleId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>

  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.ToSysUserRole" >
    update to_sys_user_role
    set user_id = #{userId,jdbcType=INTEGER},
      role_id = #{roleId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <delete id="deleteRole" parameterType="java.lang.Integer" >
    delete from to_sys_user_role
    where user_id = #{userId,jdbcType=INTEGER}
  </delete>

  <select id="selelctByRoleId" parameterType="integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from to_sys_user_role
    where role_id = #{roleId,jdbcType=INTEGER}
  </select>

  <delete id="deleteByRoleId" parameterType="list" >
    delete from
    to_sys_user_role
    where role_id in (
      <foreach collection="list" item="item" separator=",">
        #{item}
      </foreach>
    )
  </delete>

</mapper>