Merge remote-tracking branch 'base-version/main' into dev
This commit is contained in:
@@ -4,6 +4,7 @@ import com.zt.plat.framework.common.biz.system.permission.PermissionCommonApi;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.module.system.api.permission.dto.*;
|
||||
import com.zt.plat.module.system.enums.ApiConstants;
|
||||
import com.zt.plat.module.system.enums.permission.DataScopeEnum;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -50,4 +51,9 @@ public interface PermissionApi extends PermissionCommonApi {
|
||||
@Parameter(name = "userId", description = "用户编号", example = "1", required = true)
|
||||
CommonResult<Set<Long>> getUserRoleIdListByUserId(@RequestParam("userId") Long userId);
|
||||
|
||||
@GetMapping(PREFIX + "/user-data-permission-level")
|
||||
@Operation(summary = "获得用户的数据权限级别")
|
||||
@Parameter(name = "userId", description = "用户编号", example = "1", required = true)
|
||||
CommonResult<DataScopeEnum> getUserDataPermissionLevel(@RequestParam("userId") Long userId);
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.zt.plat.module.system.enums.permission;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import com.zt.plat.framework.common.core.ArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 数据范围枚举类
|
||||
@@ -33,6 +35,26 @@ public enum DataScopeEnum implements ArrayValuable<Integer> {
|
||||
|
||||
public static final Integer[] ARRAYS = Arrays.stream(values()).map(DataScopeEnum::getScope).toArray(Integer[]::new);
|
||||
|
||||
/**
|
||||
* Jackson 序列化时输出整数 code,兼容旧客户端
|
||||
*/
|
||||
@JsonValue
|
||||
public Integer getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static DataScopeEnum findByScope(Integer scope) {
|
||||
if (scope == null) {
|
||||
return null;
|
||||
}
|
||||
for (DataScopeEnum value : values()) {
|
||||
if (Objects.equals(value.scope, scope)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] array() {
|
||||
return ARRAYS;
|
||||
|
||||
Reference in New Issue
Block a user