zhubaomin
2025-04-07 ecef3df4890be54c1da2a8a4fc1c8c1f50f1c263
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserRoleMapper.xml
New file
@@ -0,0 +1,76 @@
<?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.dy.pipIrrGlobal.daoBa.BaUserRoleMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaUserRole">
    <!--@mbg.generated-->
    <!--@Table ba_user_role-->
    <id column="userId" jdbcType="BIGINT" property="userId" />
    <id column="roleId" jdbcType="BIGINT" property="roleId" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    userId, roleId
  </sql>
  <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUserRole">
    <!--@mbg.generated-->
    insert into ba_user_role (userId, roleId)
    values (#{userId,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUserRole">
    <!--@mbg.generated-->
    insert into ba_user_role
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        userId,
      </if>
      <if test="roleId != null">
        roleId,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="roleId != null">
        #{roleId,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <delete id="deleteByPrimaryKey" parameterType="map">
    <!--@mbg.generated-->
    delete from ba_user_role
    where userId = #{userId,jdbcType=BIGINT}
    and roleId = #{roleId,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByUserId" parameterType="long">
    <!--@mbg.generated-->
    delete from ba_user_role
    where userId = #{userId,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByRoleId" parameterType="long">
    <!--@mbg.generated-->
    delete from ba_user_role
    where userId = #{roleId,jdbcType=BIGINT}
  </delete>
  <!--根据用户编号获取权限列表-->
  <select id="getPermissionsByUserId" resultType="java.util.Map">
    SELECT
      rol.id AS roleId,
      rol.`name` AS roleName,
      per.id AS perId
    FROM ba_user_role use_rol
           INNER JOIN ba_role rol ON rol.id = use_rol.roleId
           INNER JOIN ba_role_permissions per ON per.roleId = rol.id
    WHERE use_rol.userId = ${userId}
  </select>
</mapper>