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

List<Menu> getOpMenusByRoleId(@Param("roleId") Integer roleId,@Param("clientId") String clientId); List<Menu> getOpMenusByRoleId(@Param("roleId") Integer roleId,@Param("clientId") String clientId);


List<Menu> getChildrenMenuByPid(@Param("parentId") Integer id,@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

package com.tuoheng.admin.service.third.oidc; package com.tuoheng.admin.service.third.oidc;


import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.tuoheng.admin.dto.RolePermissionDto;
import com.tuoheng.admin.entity.Tenant; import com.tuoheng.admin.entity.Tenant;
import com.tuoheng.admin.entity.User; import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.mapper.MenuMapper;
import com.tuoheng.admin.query.RoleClientQuery; import com.tuoheng.admin.query.RoleClientQuery;
import com.tuoheng.admin.request.third.oidc.CreateOidcTenantRequest; import com.tuoheng.admin.request.third.oidc.CreateOidcTenantRequest;
import com.tuoheng.admin.request.third.oidc.DeletedOidcTenantRequest; import com.tuoheng.admin.request.third.oidc.DeletedOidcTenantRequest;
@Autowired @Autowired
private IRoleService roleService; private IRoleService roleService;
@Autowired @Autowired
private OpPermissionsService opPermissionsService;
private MenuMapper menuMapper;




public JsonResult addUser(User user, String password, Tenant tenant) { public JsonResult addUser(User user, String password, Tenant tenant) {
} }


/** /**
* 获取角色对应的菜单
* 查询角色对应的菜单
* *
* @param roleId * @param roleId
* @return * @return
*/ */
@Override @Override
public JsonResult getMenuList(Integer roleId) { 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

where mark = 1 and status = 1 and parent_id = #{parentId} and client_id = #{clientId} where mark = 1 and status = 1 and parent_id = #{parentId} and client_id = #{clientId}
order by sort asc order by sort asc
</select> </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> </mapper>

Loading…
Cancel
Save