feat: 权限作用域(Scopes)结构化枚举类与字典接口
This commit is contained in:
@@ -9,6 +9,7 @@ import com.iot.gateway.mapper.OpenClientMapper;
|
|||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -35,6 +36,12 @@ public class OpenClientAdminController {
|
|||||||
|
|
||||||
private static final SecureRandom RANDOM = new SecureRandom();
|
private static final SecureRandom RANDOM = new SecureRandom();
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有可授权的作用域 (Scopes) 枚举字典列表")
|
||||||
|
@GetMapping("/scopes")
|
||||||
|
public Result<List<Map<String, Object>>> listScopes() {
|
||||||
|
return Result.success(com.iot.gateway.oauth.OpenScopeEnum.toList());
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "三方应用凭据分页列表")
|
@Operation(summary = "三方应用凭据分页列表")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public Result<Page<OpenClient>> page(
|
public Result<Page<OpenClient>> page(
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.iot.gateway.oauth;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开放平台接口授权作用域 (OAuth 2.0 Scopes) 枚举
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum OpenScopeEnum {
|
||||||
|
|
||||||
|
DEVICE_READ("device.read", "设备台账读取", "允许拉取租户名下设备台账、在线状态与点位元数据", "设备资产", "LOW"),
|
||||||
|
TELEMETRY_READ("telemetry.read", "实时遥测召测", "允许实时读取料筒温度、射胶压力、螺杆转速及能耗电流等实时点位", "工况监控", "LOW"),
|
||||||
|
ALARM_READ("alarm.read", "故障告警检索", "允许检索产线设备的未确认告警、严重级别及历史故障原因", "异常告警", "LOW"),
|
||||||
|
DEVICE_CONTROL("device.control", "设备反向控制", "高危权限!允许向边缘设备下发启停控制与工艺参数反写指令", "反向控制", "HIGH");
|
||||||
|
|
||||||
|
private final String code;
|
||||||
|
private final String name;
|
||||||
|
private final String description;
|
||||||
|
private final String category;
|
||||||
|
private final String riskLevel;
|
||||||
|
|
||||||
|
OpenScopeEnum(String code, String name, String description, String category, String riskLevel) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.category = category;
|
||||||
|
this.riskLevel = riskLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取全部枚举的结构化字典列表(供前端下拉/多选使用)
|
||||||
|
*/
|
||||||
|
public static List<Map<String, Object>> toList() {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (OpenScopeEnum item : values()) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("code", item.getCode());
|
||||||
|
map.put("name", item.getName());
|
||||||
|
map.put("description", item.getDescription());
|
||||||
|
map.put("category", item.getCategory());
|
||||||
|
map.put("riskLevel", item.getRiskLevel());
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user