forked from github/dataease
Merge pull request #9674 from dataease/pr@dev-v2@sysvariable
Pr@dev v2@sysvariable
This commit is contained in:
commit
f75c90e9b3
@ -8,6 +8,8 @@ import io.dataease.api.permissions.dataset.api.ColumnPermissionsApi;
|
||||
import io.dataease.api.permissions.dataset.api.RowPermissionsApi;
|
||||
import io.dataease.api.permissions.dataset.dto.*;
|
||||
import io.dataease.api.permissions.user.vo.UserFormVO;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueDto;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueItem;
|
||||
import io.dataease.constant.ColumnPermissionConstants;
|
||||
import io.dataease.dto.dataset.DatasetTableFieldDTO;
|
||||
import io.dataease.utils.AuthUtils;
|
||||
@ -188,18 +190,27 @@ public class PermissionManage {
|
||||
}
|
||||
// 替换系统变量
|
||||
if (StringUtils.equalsIgnoreCase(record.getAuthTargetType(), "sysParams")) {
|
||||
String expressionTree = record.getExpressionTree();
|
||||
if (StringUtils.isNotEmpty(userEntity.getAccount())) {
|
||||
expressionTree = expressionTree.replaceAll("\\$\\{sysParams\\.userId}", userEntity.getAccount());
|
||||
DatasetRowPermissionsTreeObj tree = JsonUtil.parseObject(record.getExpressionTree(), DatasetRowPermissionsTreeObj.class);
|
||||
List<DatasetRowPermissionsTreeItem> items = new ArrayList<>();
|
||||
for (DatasetRowPermissionsTreeItem datasetRowPermissionsTreeItem : tree.getItems()) {
|
||||
if (StringUtils.isNotEmpty(userEntity.getAccount()) && datasetRowPermissionsTreeItem.getValue().equalsIgnoreCase("\\$\\{sysParams\\.userId}")) {
|
||||
datasetRowPermissionsTreeItem.setValue(userEntity.getAccount());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userEntity.getEmail()) && datasetRowPermissionsTreeItem.getValue().equalsIgnoreCase("\\$\\{sysParams\\.userEmail}")) {
|
||||
datasetRowPermissionsTreeItem.setValue(userEntity.getEmail());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userEntity.getName()) && datasetRowPermissionsTreeItem.getValue().equalsIgnoreCase("\\$\\{sysParams\\.userName}")) {
|
||||
datasetRowPermissionsTreeItem.setValue(userEntity.getName());
|
||||
}
|
||||
String value = handleSysVariable(userEntity, datasetRowPermissionsTreeItem.getValue());
|
||||
if (value == null) {
|
||||
continue;
|
||||
} else {
|
||||
datasetRowPermissionsTreeItem.setValue(value);
|
||||
}
|
||||
items.add(datasetRowPermissionsTreeItem);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userEntity.getEmail())) {
|
||||
expressionTree = expressionTree.replaceAll("\\$\\{sysParams\\.userEmail}", userEntity.getEmail());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(userEntity.getName())) {
|
||||
expressionTree = expressionTree.replaceAll("\\$\\{sysParams\\.userName}", userEntity.getName());
|
||||
}
|
||||
record.setExpressionTree(expressionTree);
|
||||
DatasetRowPermissionsTreeObj tree = JsonUtil.parseObject(expressionTree, DatasetRowPermissionsTreeObj.class);
|
||||
tree.setItems(items);
|
||||
record.setTree(tree);
|
||||
}
|
||||
result.add(record);
|
||||
@ -207,6 +218,28 @@ public class PermissionManage {
|
||||
return result;
|
||||
}
|
||||
|
||||
private String handleSysVariable(UserFormVO userEntity, String sysVariable) {
|
||||
String value = null;
|
||||
if (StringUtils.isNotBlank(sysVariable) && sysVariable.startsWith("${") && sysVariable.endsWith("}")) {
|
||||
String variableId = sysVariable.substring(2, sysVariable.length() - 1);
|
||||
for (SysVariableValueItem variable : userEntity.getVariables()) {
|
||||
if (variableId.equalsIgnoreCase(variable.getVariableId())) {
|
||||
if (variable.getSysVariableDto().getType().equalsIgnoreCase("text")) {
|
||||
for (SysVariableValueDto sysVariableValueDto : variable.getValueList()) {
|
||||
if (sysVariableValueDto.getId().toString().equals(variable.getVariableValueId())) {
|
||||
value = sysVariableValueDto.getValue();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
value = variable.getVariableValue();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private List<Long> intersectionForList(List<Long> list1, List<Long> list2) {
|
||||
List<Long> result = new ArrayList<>();
|
||||
for (Long id : list1) {
|
||||
|
@ -16,6 +16,7 @@ i18n_menu.datasource=datasource
|
||||
i18n_menu.user=User
|
||||
i18n_menu.org=Organization
|
||||
i18n_menu.auth=Authority
|
||||
i18n_menu.sysVariable=System Variables
|
||||
i18n_field_name_repeat=has duplicate field names:
|
||||
i18n_pid_not_eq_id=Target is error
|
||||
i18n_ds_name_exists=Name is exists
|
||||
|
@ -26,6 +26,7 @@ i18n_menu.task=\u4EFB\u52A1\u7BA1\u7406
|
||||
i18n_menu.embedded=\u5D4C\u5165\u5F0F\u7BA1\u7406
|
||||
i18n_menu.platform=\u5E73\u53F0\u5BF9\u63A5
|
||||
i18n_menu.appearance=\u5916\u89C2\u914D\u7F6E
|
||||
i18n_menu.sysVariable=\u7cfb\u7edf\u53d8\u91cf
|
||||
i18n_field_name_repeat=\u6709\u91CD\u590D\u5B57\u6BB5\u540D\uFF1A
|
||||
i18n_pid_not_eq_id=\u79FB\u52A8\u76EE\u6807\u4E0D\u80FD\u662F\u81EA\u5DF1\u6216\u5B50\u76EE\u5F55
|
||||
i18n_ds_name_exists=\u8BE5\u5206\u7EC4\u4E0B\u540D\u79F0\u91CD\u590D
|
||||
|
@ -17,6 +17,7 @@ i18n_menu.datasource=\u6578\u64DA\u6E90
|
||||
i18n_menu.user=\u7528\u6236\u7BA1\u7406
|
||||
i18n_menu.org=\u7D44\u7E54\u7BA1\u7406
|
||||
i18n_menu.auth=\u6B0A\u9650\u914D\u7F6E
|
||||
i18n_menu.sysVariable=\u7cfb\u7edf\u53d8\u91cf
|
||||
i18n_field_name_repeat=\u5177\u6709\u91CD\u8907\u7684\u6B04\u4F4D\u540D\u7A31\uFF1A
|
||||
i18n_pid_not_eq_id=\u79FB\u52D5\u76EE\u6A19\u4E0D\u80FD\u662F\u81EA\u5DF1\u6216\u5B50\u76EE\u9304
|
||||
i18n_ds_name_exists=\u8A72\u5206\u7D44\u4E0B\u540D\u7A31\u91CD\u5FA9
|
||||
|
25
core/core-frontend/src/api/variable.ts
Normal file
25
core/core-frontend/src/api/variable.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
export const variableCreateApi = data => request.post({ url: '/sysVariable/create', data })
|
||||
|
||||
export const variableEditApi = data => request.post({ url: '/sysVariable/edit', data })
|
||||
|
||||
export const variableDetailApi = id => request.get({ url: '/sysVariable/detail/' + id })
|
||||
|
||||
export const variableDeletelApi = id => request.get({ url: '/sysVariable/delete/' + id })
|
||||
|
||||
export const searchVariableApi = async data => request.post({ url: '/sysVariable/query', data })
|
||||
|
||||
export const valueSelectedForVariableApi = (page: number, limit: number, data) =>
|
||||
request.post({ url: `/sysVariable/value/selected/${page}/${limit}`, data })
|
||||
|
||||
export const valueForVariable = id => request.get({ url: '/sysVariable/value/selected/' + id })
|
||||
|
||||
export const variableValueCreateApi = data =>
|
||||
request.post({ url: '/sysVariable/value/create', data })
|
||||
|
||||
export const variableValueDeletelApi = id => request.get({ url: '/sysVariable/value/delete/' + id })
|
||||
|
||||
export const variableValueEditApi = data => request.post({ url: '/sysVariable/value/edit', data })
|
||||
|
||||
export const batchDelApi = data => request.post({ url: '/sysVariable/value/batchDel', data })
|
@ -2316,5 +2316,9 @@ export default {
|
||||
last_status_running: '运行中',
|
||||
last_status_fail: '失败',
|
||||
last_status_success: '成功'
|
||||
},
|
||||
variable: {
|
||||
give_up: 's',
|
||||
save_apply: '保存并应用'
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.api.permissions.user.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -31,4 +32,6 @@ public class UserCreator implements Serializable {
|
||||
@Schema(hidden = true)
|
||||
@JsonIgnore
|
||||
private Long uid;
|
||||
@Schema(description = "系统变量")
|
||||
private List<SysVariableValueItem> variables;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.api.permissions.user.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -42,4 +43,10 @@ public class UserFormVO implements Serializable {
|
||||
|
||||
@Schema(description = "模式")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "系统变量")
|
||||
private String sysVariable;
|
||||
|
||||
@Schema(description = "系统变量")
|
||||
private List<SysVariableValueItem> variables;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.api.permissions.user.vo;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueItem;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -26,4 +27,6 @@ public class UserGridVO {
|
||||
private Boolean enable;
|
||||
@Schema(description = "创建时间")
|
||||
private Long createTime;
|
||||
@Schema(description = "系统变量")
|
||||
private List<SysVariableValueItem> variables;
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package io.dataease.api.permissions.variable.api;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableDto;
|
||||
import io.dataease.api.permissions.variable.dto.SysVariableValueDto;
|
||||
import io.dataease.auth.DeApiPath;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static io.dataease.constant.AuthResourceEnum.SYSTEM;
|
||||
|
||||
@Tag(name = "系统变量")
|
||||
@ApiSupport(order = 881, author = "fit2cloud-someone")
|
||||
@DeApiPath(value = "/sysVariable", rt = SYSTEM)
|
||||
public interface SysVariablesApi {
|
||||
|
||||
@Operation(summary = "创建")
|
||||
@PostMapping("/create")
|
||||
SysVariableDto create(@RequestBody SysVariableDto sysVariableDto);
|
||||
|
||||
@Operation(summary = "编辑")
|
||||
@PostMapping("/edit")
|
||||
SysVariableDto edit(@RequestBody SysVariableDto sysVariableDto);
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/delete/{id}")
|
||||
void delete(@PathVariable String id);
|
||||
|
||||
@Operation(summary = "详细信息")
|
||||
@GetMapping("/detail/{id}")
|
||||
SysVariableDto detail(@PathVariable String id);
|
||||
|
||||
@Operation(summary = "查询")
|
||||
@PostMapping("/query")
|
||||
List<SysVariableDto> query(@RequestBody SysVariableDto sysVariableDto);
|
||||
|
||||
@Operation(summary = "创建")
|
||||
@PostMapping("/value/create")
|
||||
SysVariableValueDto createValue(@RequestBody SysVariableValueDto sysVariableDto);
|
||||
|
||||
@Operation(summary = "编辑")
|
||||
@PostMapping("/value/edit")
|
||||
SysVariableValueDto editValue(@RequestBody SysVariableValueDto sysVariableDto);
|
||||
|
||||
@Operation(summary = "删除")
|
||||
@GetMapping("/value/delete/{id}")
|
||||
void deleteValue(@PathVariable String id);
|
||||
|
||||
@GetMapping("/value/selected/{id}")
|
||||
List<SysVariableValueDto> selectVariableValue(@PathVariable("id") String id);
|
||||
|
||||
@PostMapping("/value/selected/{goPage}/{pageSize}")
|
||||
IPage<SysVariableValueDto> selectPage(@PathVariable("goPage") int goPage, @PathVariable("pageSize") int pageSize, @RequestBody SysVariableValueDto sysVariableValueDto);
|
||||
|
||||
@Operation(summary = "批量删除")
|
||||
@PostMapping("/value/batchDel")
|
||||
void batchDel(@RequestBody List<Long> ids);
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package io.dataease.api.permissions.variable.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysVariableDto {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
private String type;
|
||||
private String name;
|
||||
private Long min;
|
||||
private Long max;
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private boolean root = false;
|
||||
private boolean disabled = false;
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.dataease.api.permissions.variable.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SysVariableValueDto {
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sysVariableId;
|
||||
private String value;
|
||||
private String begin;
|
||||
private String end;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package io.dataease.api.permissions.variable.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysVariableValueItem {
|
||||
private SysVariableDto sysVariableDto;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String variableId;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String variableValueId;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private String variableValue;
|
||||
private List<SysVariableValueDto> valueList;
|
||||
}
|
Loading…
Reference in New Issue
Block a user