feat: 字典配置前端代码.
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.orion.ops.module.infra.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.infra.define.operator.DictKeyOperatorType;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest;
|
||||
import com.orion.ops.module.infra.entity.vo.DictKeyVO;
|
||||
import com.orion.ops.module.infra.service.DictKeyService;
|
||||
@@ -62,6 +64,14 @@ public class DictKeyController {
|
||||
return dictKeyService.getDictKeyList();
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@PostMapping("/query")
|
||||
@Operation(summary = "分页查询全部字典配置项")
|
||||
@PreAuthorize("@ss.hasPermission('infra:dict-key:query')")
|
||||
public DataGrid<DictKeyVO> getDictKeyPage(@Validated @RequestBody DictKeyQueryRequest request) {
|
||||
return dictKeyService.getDictKeyPage(request);
|
||||
}
|
||||
|
||||
@OperatorLog(DictKeyOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除字典配置项")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.module.infra.entity.request.dict;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ValidConst;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -27,7 +28,7 @@ public class DictKeyCreateRequest implements Serializable {
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,32}$")
|
||||
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
|
||||
@Schema(description = "配置项")
|
||||
private String keyName;
|
||||
|
||||
@@ -36,11 +37,9 @@ public class DictKeyCreateRequest implements Serializable {
|
||||
@Schema(description = "配置值定义")
|
||||
private String valueType;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "额外配置定义")
|
||||
private String extraSchema;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 64)
|
||||
@Schema(description = "配置描述")
|
||||
private String description;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.orion.ops.module.infra.entity.request.dict;
|
||||
|
||||
import com.orion.ops.framework.common.entity.PageRequest;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* 字典配置项 查询请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-10-19 10:25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(name = "DictKeyQueryRequest", description = "字典配置项 查询请求对象")
|
||||
public class DictKeyQueryRequest extends PageRequest {
|
||||
|
||||
@Schema(description = "搜索")
|
||||
private String searchValue;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "配置项")
|
||||
private String keyName;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "配置描述")
|
||||
private String description;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.module.infra.entity.request.dict;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ValidConst;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -32,7 +33,7 @@ public class DictKeyUpdateRequest implements Serializable {
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,32}$")
|
||||
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
|
||||
@Schema(description = "配置项")
|
||||
private String keyName;
|
||||
|
||||
@@ -41,11 +42,9 @@ public class DictKeyUpdateRequest implements Serializable {
|
||||
@Schema(description = "配置值定义")
|
||||
private String valueType;
|
||||
|
||||
@NotBlank
|
||||
@Schema(description = "额外配置定义")
|
||||
private String extraSchema;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 64)
|
||||
@Schema(description = "配置描述")
|
||||
private String description;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.module.infra.entity.request.dict;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ValidConst;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -32,7 +33,7 @@ public class DictValueCreateRequest implements Serializable {
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,32}$")
|
||||
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
|
||||
@Schema(description = "配置名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.module.infra.entity.request.dict;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ValidConst;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -36,7 +37,7 @@ public class DictValueUpdateRequest implements Serializable {
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,32}$")
|
||||
@Pattern(regexp = ValidConst.CHAR_NUMBER_2_32_PATTERN, message = ValidConst.CHAR_NUMBER_2_32_MESSAGE)
|
||||
@Schema(description = "配置名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.module.infra.entity.request.user;
|
||||
|
||||
import com.orion.ops.framework.common.constant.ValidConst;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@@ -27,7 +28,7 @@ public class SystemUserCreateRequest implements Serializable {
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Pattern(regexp = "^[a-zA-Z0-9]{4,32}$")
|
||||
@Pattern(regexp = ValidConst.CHAR_NUMBER_4_32_PATTERN, message = ValidConst.CHAR_NUMBER_4_32_MESSAGE)
|
||||
@Schema(description = "用户名")
|
||||
private String username;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.orion.ops.module.infra.service;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest;
|
||||
import com.orion.ops.module.infra.entity.vo.DictKeyVO;
|
||||
|
||||
@@ -39,6 +41,14 @@ public interface DictKeyService {
|
||||
*/
|
||||
List<DictKeyVO> getDictKeyList();
|
||||
|
||||
/**
|
||||
* 分页 查询字典配置项
|
||||
*
|
||||
* @param request request
|
||||
* @return rows
|
||||
*/
|
||||
DataGrid<DictKeyVO> getDictKeyPage(DictKeyQueryRequest request);
|
||||
|
||||
/**
|
||||
* 查询字典配置项 schema
|
||||
*
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.orion.ops.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.Objects1;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
@@ -17,6 +19,7 @@ import com.orion.ops.module.infra.define.cache.DictCacheKeyDefine;
|
||||
import com.orion.ops.module.infra.entity.domain.DictKeyDO;
|
||||
import com.orion.ops.module.infra.entity.dto.DictKeyCacheDTO;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.dict.DictKeyUpdateRequest;
|
||||
import com.orion.ops.module.infra.entity.vo.DictKeyVO;
|
||||
import com.orion.ops.module.infra.enums.DictValueTypeEnum;
|
||||
@@ -118,6 +121,16 @@ public class DictKeyServiceImpl implements DictKeyService {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataGrid<DictKeyVO> getDictKeyPage(DictKeyQueryRequest request) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<DictKeyDO> wrapper = this.buildQueryWrapper(request);
|
||||
// 查询
|
||||
return dictKeyDAO.of(wrapper)
|
||||
.page(request)
|
||||
.dataGrid(DictKeyConvert.MAPPER::to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDictSchema(String key) {
|
||||
// 查询缓存
|
||||
@@ -210,4 +223,22 @@ public class DictKeyServiceImpl implements DictKeyService {
|
||||
Valid.isFalse(present, ErrorMessage.DATA_PRESENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询 wrapper
|
||||
*
|
||||
* @param request request
|
||||
* @return wrapper
|
||||
*/
|
||||
private LambdaQueryWrapper<DictKeyDO> buildQueryWrapper(DictKeyQueryRequest request) {
|
||||
String searchValue = request.getSearchValue();
|
||||
return dictKeyDAO.wrapper()
|
||||
.eq(DictKeyDO::getId, request.getId())
|
||||
.like(DictKeyDO::getKeyName, request.getKeyName())
|
||||
.like(DictKeyDO::getDescription, request.getDescription())
|
||||
.and(Strings.isNotEmpty(searchValue), c -> c
|
||||
.like(DictKeyDO::getKeyName, searchValue).or()
|
||||
.like(DictKeyDO::getDescription, searchValue)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -182,6 +182,7 @@ public class DictValueServiceImpl implements DictValueService {
|
||||
Map<String, Map<String, Object>> result = Maps.newLinkedMap();
|
||||
for (DictValueVO value : values) {
|
||||
Map<String, Object> item = Maps.newMap();
|
||||
item.put(Const.NAME, value.getName());
|
||||
item.put(Const.LABEL, value.getLabel());
|
||||
item.put(Const.VALUE, DictValueTypeEnum.of(schema.get(Const.VALUE)).parse(value.getValue()));
|
||||
// 额外值
|
||||
@@ -213,7 +214,7 @@ public class DictValueServiceImpl implements DictValueService {
|
||||
DictValueDO updateRecord = new DictValueDO();
|
||||
updateRecord.setKeyName(newKey);
|
||||
LambdaQueryWrapper<DictValueDO> wrapper = dictValueDAO.lambda()
|
||||
.eq(DictValueDO::getKeyId, beforeKey);
|
||||
.eq(DictValueDO::getKeyId, keyId);
|
||||
int effect = dictValueDAO.update(updateRecord, wrapper);
|
||||
// 删除缓存
|
||||
String beforeCacheKey = DictCacheKeyDefine.DICT_VALUE.format(beforeKey);
|
||||
|
||||
Reference in New Issue
Block a user