<?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.saye.hospitalgd.mapper.system.UserRoleMapper">

    <resultMap id="BaseResultMap" type="com.saye.hospitalgd.model.UserRole">
        <id column="user_role_id" property="userRoleId" jdbcType="VARCHAR"/>
        <result column="user_id" property="userId" jdbcType="VARCHAR"/>
        <result column="role_id" property="roleId" jdbcType="VARCHAR"/>
    </resultMap>

    <insert id="insertUserRole">
        insert into USER_ROLE(USER_ID, ROLE_ID)
        values (#{userId}, #{roleId})
    </insert>
    <insert id="insertNewUserRole">
        insert into USER_ROLE(USER_ID, ROLE_ID, USER_ROLE_ID)
        values (#{userId}, #{roleId}, #{userRoleId})
    </insert>
    <delete id="deleteUserRole">
        DELETE
        FROM user_role
        WHERE USER_ID = #{userId}
    </delete>

    <select id="selectUserRoleByUserId" resultMap="BaseResultMap">
        select user_role_id, user_id, role_id
        from user_role
        where user_id = #{userId}
    </select>
    <select id="selectUserRoleByRoleId" resultMap="BaseResultMap">
        select user_role_id, user_id, role_id
        from user_role
        where role_id = #{roleId}
    </select>


</mapper>