Browse Source

租户创建相关查询角色及菜单列表

tags/v1.2.0^2
xiaoying 1 year ago
parent
commit
d85e71bed9
5 changed files with 68 additions and 4 deletions
  1. +21
    -4
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/callback/OidcCallbackController.java
  2. +2
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java
  3. +8
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java
  4. +4
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcService.java
  5. +33
    -0
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcServiceImpl.java

+ 21
- 4
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/controller/callback/OidcCallbackController.java View File

import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;


/** /**
* oidc平台回调前端控制器 * oidc平台回调前端控制器
log.info("被oidc调用,删除租户:{}", JSONObject.toJSONString(request)); log.info("被oidc调用,删除租户:{}", JSONObject.toJSONString(request));
return oidcService.deletedTenant(request); return oidcService.deletedTenant(request);
} }
/**
* 查询所有可用的角色
*
* @return
*/
@GetMapping("/getRoleList")
public JsonResult getRoleList() {
return oidcService.getRoleList();
}

/**
* 查询角色对应的菜单
*
* @return
*/
@GetMapping("/getMenuList/{roleId}")
public JsonResult getMenuList(@PathVariable("roleId") Integer roleId) {
return oidcService.getMenuList(roleId);
}

} }

+ 2
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/IRoleService.java View File

JsonResult savePermission(RoleMenuDto roleMenuDto); JsonResult savePermission(RoleMenuDto roleMenuDto);


JsonResult roleToTenant(Integer[] ids); JsonResult roleToTenant(Integer[] ids);

JsonResult getRoles();
} }

+ 8
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/role/RoleServiceImpl.java View File

} }
return JsonResult.success(); return JsonResult.success();
} }
@Override
public JsonResult getRoles() {

List<Role> roles = roleMapper.selectList(Wrappers.<Role>lambdaQuery()
.eq(Role::getMark, MarkEnum.VALID.getCode()).eq(Role::getStatus, 1));

return JsonResult.success(roles);
}




} }

+ 4
- 0
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/third/oidc/OidcService.java View File

JsonResult editTenant(EditOidcTenantRequest request); JsonResult editTenant(EditOidcTenantRequest request);


JsonResult deletedTenant(DeletedOidcTenantRequest request); JsonResult deletedTenant(DeletedOidcTenantRequest request);

JsonResult getRoleList();

JsonResult getMenuList(Integer roleId);
} }

+ 33
- 0
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.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.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;
import com.tuoheng.admin.request.third.oidc.EditOidcTenantRequest; import com.tuoheng.admin.request.third.oidc.EditOidcTenantRequest;
import com.tuoheng.admin.service.role.IRoleService;
import com.tuoheng.common.core.utils.JsonResult; import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@Autowired @Autowired
private DeletedOidcTenantService deletedOidcTenantService; private DeletedOidcTenantService deletedOidcTenantService;


@Autowired
private IRoleService roleService;


public JsonResult addUser(User user, String password, Tenant tenant) { public JsonResult addUser(User user, String password, Tenant tenant) {
return addOidcUserService.add(user, password, tenant); return addOidcUserService.add(user, password, tenant);
} }
public JsonResult deletedTenant(DeletedOidcTenantRequest request) { public JsonResult deletedTenant(DeletedOidcTenantRequest request) {
return deletedOidcTenantService.deletedTenant(request); return deletedOidcTenantService.deletedTenant(request);
} }

/**
* 租户获取可用的角色
*
* @return
*/
@Override
public JsonResult getRoleList() {

JsonResult jsonResult = roleService.getRoles();
return jsonResult;
}

/**
* 获取角色对应的菜单
*
* @param roleId
* @return
*/
@Override
public JsonResult getMenuList(Integer roleId) {

RoleClientQuery query = new RoleClientQuery();
query.setRoleId(roleId);
return roleService.getMenuList(query);
}
} }

Loading…
Cancel
Save