<?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.sooka.mybatis.mapper.TSysUserRoleMapper">
  <resultMap id="BaseResultMap" type="com.sooka.mybatis.model.TSysUserRole">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="user_id" jdbcType="INTEGER" property="userId" />
    <result column="role_id" jdbcType="INTEGER" property="roleId" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_sys_user_role
    where id = #{id,jdbcType=INTEGER}
  </delete>

  <delete id="deleteByUserId">
    delete from t_sys_user_role
    where user_id = #{userId}
  </delete>

  <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.sooka.mybatis.model.TSysUserRole">
    insert into t_sys_user_role ( user_id, role_id
      )
    values (#{userId,jdbcType=INTEGER}, #{roleId,jdbcType=INTEGER}
      )
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.sooka.mybatis.model.TSysUserRole">
    update t_sys_user_role
    set user_id = #{userId,jdbcType=INTEGER},
      role_id = #{roleId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select id, user_id, role_id
    from t_sys_user_role
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select id, user_id, role_id
    from t_sys_user_role
  </select>
</mapper>