Browse Source

更新oidc查询相关菜单

tags/v1.2.0^2
xiaoying 1 year ago
parent
commit
37f7bf98d2
3 changed files with 21 additions and 6 deletions
  1. +3
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/MenuMapper.java
  2. +8
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcServiceImpl.java
  3. +10
    -0
      tuoheng-service/tuoheng-admin/src/main/resources/mapper/MenuMapper.xml

+ 3
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/mapper/MenuMapper.java View File

@@ -15,4 +15,7 @@ public interface MenuMapper extends BaseMapper<Menu> {
List<Menu> getOpMenusByRoleId(@Param("roleId") Integer roleId,@Param("clientId") String clientId);

List<Menu> getChildrenMenuByPid(@Param("parentId") Integer id,@Param("clientId") String clientId);

List<Menu> getMenuListByRoleId(@Param("roleId") Integer roleId);

}

+ 8
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcServiceImpl.java View File

@@ -1,8 +1,10 @@
package com.tuoheng.admin.service.third.oidc;

import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.admin.dto.RolePermissionDto;
import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.mapper.MenuMapper;
import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.admin.request.third.oidc.CreateOidcTenantRequest;
import com.tuoheng.admin.request.third.oidc.DeletedOidcTenantRequest;
@@ -40,7 +42,7 @@ public class OidcServiceImpl implements OidcService {
@Autowired
private IRoleService roleService;
@Autowired
private OpPermissionsService opPermissionsService;
private MenuMapper menuMapper;


public JsonResult addUser(User user, String password, Tenant tenant) {
@@ -83,16 +85,16 @@ public class OidcServiceImpl implements OidcService {
}

/**
* 获取角色对应的菜单
* 查询角色对应的菜单
*
* @param roleId
* @return
*/
@Override
public JsonResult getMenuList(Integer roleId) {
RoleClientQuery query = new RoleClientQuery();
query.setRoleId(roleId);
return opPermissionsService.getRolePermissionByRoleId(query);
RolePermissionDto rolePermissionDto = new RolePermissionDto();
rolePermissionDto.setOpMenusList(menuMapper.getMenuListByRoleId(roleId));
rolePermissionDto.setRoleId(roleId);
return JsonResult.success(rolePermissionDto);
}
}

+ 10
- 0
tuoheng-service/tuoheng-admin/src/main/resources/mapper/MenuMapper.xml View File

@@ -48,6 +48,16 @@
where mark = 1 and status = 1 and parent_id = #{parentId} and client_id = #{clientId}
order by sort asc
</select>
<!-- 根据roleId 查询出所有的菜单-->
<select id="getMenuListByRoleId" resultType="com.tuoheng.admin.entity.Menu">
select
<include refid="Base_Column_List"/>
from op_menus
where mark = 1
and status = 1
and id in (select menu_id from op_role_menu where role_id = #{roleId} and mark = 1)
order by sort asc
</select>


</mapper>

Loading…
Cancel
Save