feat: 权限作用域(Scopes)结构化枚举类与字典接口
This commit is contained in:
@@ -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