parent
66cf868588
commit
51bcfa9cc7
11 changed files with 57 additions and 130 deletions
@ -1,38 +0,0 @@ |
||||
package com.teaching.backend.mapper.umsAdmin; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.umsAdmin.UmsAdminRoleRelation; |
||||
import com.teaching.backend.model.entity.umsAdmin.UmsResource; |
||||
import com.teaching.backend.model.entity.umsAdmin.UmsRole; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 后台用户与角色关系管理自定义Dao |
||||
* Created by macro on 2018/10/8. |
||||
*/ |
||||
@Mapper |
||||
public interface UmsAdminRoleRelationMapper extends BaseMapper<UmsAdminRoleRelation> { |
||||
/** |
||||
* 插入用户角色关系 |
||||
*/ |
||||
boolean insert(@Param("adminId") Long adminId, @Param("roleId") Long roleId); |
||||
|
||||
/** |
||||
* 获取用于所有角色 |
||||
*/ |
||||
List<UmsRole> getRoleList(@Param("adminId") Long adminId); |
||||
|
||||
/** |
||||
* 获取用户所有可访问资源 |
||||
*/ |
||||
List<UmsResource> getResourceList(@Param("adminId") Long adminId); |
||||
|
||||
|
||||
// /**
|
||||
// * 获取资源相关用户ID列表
|
||||
// */
|
||||
// List<Long> getAdminIdList(@Param("resourceId") Long resourceId);
|
||||
} |
@ -0,0 +1,22 @@ |
||||
package com.teaching.backend.mapper.umsAdmin; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.teaching.backend.model.entity.umsAdmin.UmsPermission; |
||||
import com.teaching.backend.model.entity.umsAdmin.UmsResource; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 后台角色管理自定义Dao |
||||
* Created by macro on 2020/2/2. |
||||
*/ |
||||
@Mapper |
||||
public interface UmsRoleResourceMapper extends BaseMapper<UmsResource> { |
||||
/** |
||||
* 获取用户所有可访问资源 |
||||
*/ |
||||
List<UmsResource> getResourceList(@Param("roleId") Long roleId); |
||||
} |
@ -1,18 +0,0 @@ |
||||
package com.teaching.backend.model.entity.umsAdmin; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
|
||||
@Data |
||||
@TableName("ums_admin_role_relation") |
||||
public class UmsAdminRoleRelation implements Serializable { |
||||
private Long id; |
||||
|
||||
private Long adminId; |
||||
|
||||
private Long roleId; |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
} |
@ -1,40 +0,0 @@ |
||||
<?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.teaching.backend.mapper.umsAdmin.UmsAdminRoleRelationMapper"> |
||||
<insert id="insert"> |
||||
INSERT INTO ums_admin_role_relation (admin_id, role_id) VALUES (#{adminId,jdbcType=BIGINT}, |
||||
#{roleId,jdbcType=BIGINT}) |
||||
</insert> |
||||
<select id="getRoleList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsRole"> |
||||
select r.* |
||||
from ums_admin_role_relation ar left join ums_role r on ar.role_id = r.id |
||||
where ar.admin_id = #{adminId} |
||||
</select> |
||||
<select id="getResourceList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsResource"> |
||||
SELECT |
||||
ur.id id, |
||||
ur.create_time createTime, |
||||
ur.`name` `name`, |
||||
ur.url url, |
||||
ur.description description, |
||||
ur.category_id categoryId |
||||
FROM |
||||
ums_admin_role_relation ar |
||||
LEFT JOIN ums_role r ON ar.role_id = r.id |
||||
LEFT JOIN ums_role_resource_relation rrr ON r.id = rrr.role_id |
||||
LEFT JOIN ums_resource ur ON ur.id = rrr.resource_id |
||||
WHERE |
||||
ar.admin_id = #{adminId} |
||||
AND ur.id IS NOT NULL |
||||
GROUP BY |
||||
ur.id |
||||
</select> |
||||
<!-- <select id="getAdminIdList" resultType="java.lang.Long">--> |
||||
<!-- SELECT--> |
||||
<!-- DISTINCT ar.admin_id--> |
||||
<!-- FROM--> |
||||
<!-- ums_role_resource_relation rr--> |
||||
<!-- LEFT JOIN ums_admin_role_relation ar ON rr.role_id = ar.role_id--> |
||||
<!-- WHERE rr.resource_id=#{resourceId}--> |
||||
<!-- </select>--> |
||||
</mapper> |
@ -0,0 +1,5 @@ |
||||
<?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.teaching.backend.mapper.umsAdmin.UmsPermissionMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,22 @@ |
||||
<?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.teaching.backend.mapper.umsAdmin.UmsRoleResourceMapper"> |
||||
<select id="getResourceList" resultType="com.teaching.backend.model.entity.umsAdmin.UmsResource"> |
||||
SELECT |
||||
ur.id id, |
||||
ur.create_time createTime, |
||||
ur.`name` `name`, |
||||
ur.url url, |
||||
ur.description description, |
||||
ur.category_id categoryId |
||||
FROM |
||||
ums_role_resource_relation rrr |
||||
LEFT JOIN ums_resource ur ON ur.id = rrr.resource_id |
||||
WHERE |
||||
rrr.role_id = #{roleId} |
||||
AND ur.id IS NOT NULL |
||||
GROUP BY |
||||
ur.id |
||||
</select> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue