feat: 数据别名.
This commit is contained in:
@@ -27,7 +27,7 @@ public class CodeGenerators {
|
||||
// 作者
|
||||
String author = Const.ORION_AUTHOR;
|
||||
// 模块
|
||||
String module = "asset";
|
||||
String module = "infra";
|
||||
// 生成的表
|
||||
Table[] tables = {
|
||||
// Template.create("dict_key", "字典配置项", "dict")
|
||||
@@ -45,17 +45,11 @@ public class CodeGenerators {
|
||||
// .color("blue", "gray", "red", "green", "white")
|
||||
// .valueUseFields()
|
||||
// .build(),
|
||||
Template.create("command_template", "命令模板", "command")
|
||||
Template.create("data_alias", "数据别名", "data")
|
||||
.disableUnitTest()
|
||||
.cache("command:template:list", "命令模板列表")
|
||||
.enableProviderApi()
|
||||
.cache("data:alias:{}:{}", "数据别名 ${userId} ${type}")
|
||||
.expire(1, TimeUnit.DAYS)
|
||||
.vue("asset", "snippet")
|
||||
.enableDrawerForm()
|
||||
.dict("commandTemplateRender", "prepare_render")
|
||||
.comment("是否使用脚本渲染")
|
||||
.fields("UNUSED", "USED")
|
||||
.labels("不使用", "使用")
|
||||
.values(0, 1)
|
||||
.build(),
|
||||
};
|
||||
// jdbc 配置 - 使用配置文件
|
||||
|
||||
@@ -9,7 +9,9 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.office.excel.writer.exporting.ExcelExport;
|
||||
#end
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
#if($meta.enableExport)
|
||||
import com.orion.ops.framework.common.utils.FileNames;
|
||||
#end
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
#if($meta.enableCache)
|
||||
import com.orion.ops.framework.redis.core.utils.RedisMaps;
|
||||
@@ -21,14 +23,18 @@ import ${pkg}.*;
|
||||
import ${package.Entity}.${entity};
|
||||
import ${package.Mapper}.${table.mapperName};
|
||||
import ${package.Service}.${table.serviceName};
|
||||
#if($meta.enableExport)
|
||||
import com.orion.web.servlet.web.Servlets;
|
||||
#end
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
#if($meta.enableExport)
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
#end
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.orion.ops.framework.redis.core.utils.barrier;
|
||||
|
||||
import com.orion.lang.define.barrier.GenericsAnonymousCollectionBarrier;
|
||||
import com.orion.lang.define.barrier.GenericsAnonymousMapBarrier;
|
||||
import com.orion.lang.define.barrier.GenericsBarrier;
|
||||
import com.orion.lang.define.cache.key.model.LongCacheIdModel;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@@ -19,7 +23,9 @@ public class CacheBarriers {
|
||||
private CacheBarriers() {
|
||||
}
|
||||
|
||||
public static final GenericsListBarrier<Long> LONG = GenericsListBarrier.create(Const.NONE_ID);
|
||||
public static final GenericsBarrier<Collection<?>> LIST = GenericsAnonymousCollectionBarrier.create(Const.NONE_ID);
|
||||
|
||||
public static final GenericsBarrier<Map<?, ?>> MAP = GenericsAnonymousMapBarrier.create(Const.NONE_ID, Const.NONE_ID);
|
||||
|
||||
/**
|
||||
* 创建屏障对象 防止穿透
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.orion.ops.framework.redis.core.utils.barrier;
|
||||
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 标准集合屏障
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/11/21 11:46
|
||||
*/
|
||||
public class GenericsListBarrier<T> {
|
||||
|
||||
private final T barrierValue;
|
||||
|
||||
public GenericsListBarrier(T barrierValue) {
|
||||
this.barrierValue = barrierValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建屏障
|
||||
*
|
||||
* @param barrierValue barrierValue
|
||||
* @param <T> T
|
||||
* @return barrier
|
||||
*/
|
||||
public static <T> GenericsListBarrier<T> create(T barrierValue) {
|
||||
return new GenericsListBarrier<>(barrierValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检测是否需要添加屏障对象 防止穿透
|
||||
*
|
||||
* @param list list
|
||||
*/
|
||||
public void check(Collection<T> list) {
|
||||
if (list != null && list.isEmpty()) {
|
||||
// 添加屏障对象
|
||||
list.add(barrierValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除屏障对象
|
||||
*
|
||||
* @param list list
|
||||
*/
|
||||
public void remove(Collection<T> list) {
|
||||
if (!Lists.isEmpty(list)) {
|
||||
list.removeIf(s -> s.equals(barrierValue));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,10 +36,13 @@ public class HostSshConfigStrategy implements HostConfigStrategy<HostSshConfigMo
|
||||
|
||||
private static final int SSH_PORT = 22;
|
||||
|
||||
private static final String USERNAME = "root";
|
||||
|
||||
@Override
|
||||
public HostSshConfigModel getDefault() {
|
||||
return HostSshConfigModel.builder()
|
||||
.port(SSH_PORT)
|
||||
.username(USERNAME)
|
||||
.charset(Const.UTF_8)
|
||||
.connectTimeout(Const.MS_S_10)
|
||||
.fileNameCharset(Const.UTF_8)
|
||||
|
||||
@@ -48,7 +48,7 @@ public class TerminalThemeFetcher {
|
||||
.limit(200)
|
||||
.map(f -> {
|
||||
JSONObject schema = JSONObject.parseObject(new String(FileReaders.readAllBytes(f)));
|
||||
schema.put("dark", isDarkColor(schema.getString("background")));
|
||||
schema.put("dark", Colors.isDarkColor(schema.getString("background")));
|
||||
schema.put("selectionBackground", schema.getString("selection"));
|
||||
// 转为对象
|
||||
return JSON.parseObject(JSON.toJSONString(schema, colorFilter), TerminalTheme.class);
|
||||
@@ -69,19 +69,6 @@ public class TerminalThemeFetcher {
|
||||
System.out.println("\n\njsCode 已复制到剪切板");
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO kit
|
||||
* 是否为深色
|
||||
* 亮度值 < 128 ? 深色 : 128
|
||||
*
|
||||
* @param hex hex
|
||||
* @return 是否为深色
|
||||
*/
|
||||
public static boolean isDarkColor(String hex) {
|
||||
int[] rgb = Colors.toRgbColor(hex);
|
||||
return (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 < 128;
|
||||
}
|
||||
|
||||
//
|
||||
/*
|
||||
var term = new Terminal();
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// package com.orion.ops.module.infra.api;
|
||||
//
|
||||
// import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
//
|
||||
// import java.util.List;
|
||||
//
|
||||
// /**
|
||||
// * 数据别名 对外服务类
|
||||
// *
|
||||
// * @author Jiahang Li
|
||||
// * @version 1.0.0
|
||||
// * @since 2023-12-18 17:37
|
||||
// */
|
||||
// public interface DataAliasApi {
|
||||
//
|
||||
// /**
|
||||
// * 创建数据别名
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return id
|
||||
// */
|
||||
// Long createDataAlias(DataAliasCreateDTO dto);
|
||||
//
|
||||
// /**
|
||||
// * 更新数据别名
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return effect
|
||||
// */
|
||||
// Integer updateDataAliasById(DataAliasUpdateDTO dto);
|
||||
//
|
||||
// /**
|
||||
// * 查询数据别名
|
||||
// *
|
||||
// * @param id id
|
||||
// * @return row
|
||||
// */
|
||||
// DataAliasDTO getDataAliasById(Long id);
|
||||
//
|
||||
// /**
|
||||
// * 批量查询数据别名
|
||||
// *
|
||||
// * @param idList idList
|
||||
// * @return rows
|
||||
// */
|
||||
// List<DataAliasDTO> getDataAliasByIdList(List<Long> idList);
|
||||
//
|
||||
// /**
|
||||
// * 查询全部数据别名
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return rows
|
||||
// */
|
||||
// List<DataAliasDTO> getDataAliasList(DataAliasQueryDTO dto);
|
||||
//
|
||||
// /**
|
||||
// * 通过缓存查询数据别名
|
||||
// *
|
||||
// * @return rows
|
||||
// */
|
||||
// List<DataAliasDTO> getDataAliasListByCache();
|
||||
//
|
||||
// /**
|
||||
// * 查询数据别名数量
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return count
|
||||
// */
|
||||
// Long getDataAliasCount(DataAliasQueryDTO dto);
|
||||
//
|
||||
// /**
|
||||
// * 删除数据别名
|
||||
// *
|
||||
// * @param id id
|
||||
// * @return effect
|
||||
// */
|
||||
// Integer deleteDataAliasById(Long id);
|
||||
//
|
||||
// /**
|
||||
// * 批量删除数据别名
|
||||
// *
|
||||
// * @param idList idList
|
||||
// * @return effect
|
||||
// */
|
||||
// Integer deleteDataAliasByIdList(List<Long> idList);
|
||||
//
|
||||
// /**
|
||||
// * 根据条件删除数据别名
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return effect
|
||||
// */
|
||||
// Integer deleteDataAlias(DataAliasQueryDTO dto);
|
||||
//
|
||||
// }
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据别名 创建请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataAliasCreateDTO", description = "数据别名 创建请求业务对象")
|
||||
public class DataAliasCreateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "数据id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "数据类型")
|
||||
private String type;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据别名 业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataAliasDTO", description = "数据别名 业务对象")
|
||||
public class DataAliasDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "数据id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "数据类型")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据别名 查询请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataAliasQueryDTO", description = "数据别名 查询请求业务对象")
|
||||
public class DataAliasQueryDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "数据id")
|
||||
private Long relId;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "数据类型")
|
||||
private String type;
|
||||
|
||||
@Size(max = 32)
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.orion.ops.module.infra.entity.dto.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据别名 更新请求业务对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataAliasUpdateDTO", description = "数据别名 更新请求业务对象")
|
||||
public class DataAliasUpdateDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "数据id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "数据类型")
|
||||
private String type;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
// package com.orion.ops.module.infra.api.impl;
|
||||
//
|
||||
// import com.alibaba.fastjson.JSON;
|
||||
// import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
// import com.orion.lang.utils.collect.Lists;
|
||||
// import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
// import com.orion.ops.framework.common.utils.Valid;
|
||||
// import com.orion.ops.module.infra.entity.vo.*;
|
||||
// import com.orion.ops.module.infra.entity.request.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.*;
|
||||
// import com.orion.ops.module.infra.define.cache.*;
|
||||
// import com.orion.ops.module.infra.define.operator.*;
|
||||
// import com.orion.ops.module.infra.api.*;
|
||||
// import com.orion.ops.module.infra.api.impl.*;
|
||||
// import com.orion.ops.module.infra.entity.dto.data.*;
|
||||
// import com.orion.ops.module.infra.convert.*;
|
||||
// import com.orion.ops.module.infra.entity.domain.DataAliasDO;
|
||||
// import com.orion.ops.module.infra.dao.DataAliasDAO;
|
||||
// import com.orion.ops.module.infra.service.DataAliasService;
|
||||
// import lombok.extern.slf4j.Slf4j;
|
||||
// import org.springframework.stereotype.Service;
|
||||
//
|
||||
// import javax.annotation.Resource;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.List;
|
||||
// import java.util.stream.Collectors;
|
||||
//
|
||||
// /**
|
||||
// * 数据别名 对外服务实现类
|
||||
// *
|
||||
// * @author Jiahang Li
|
||||
// * @version 1.0.0
|
||||
// * @since 2023-12-18 17:37
|
||||
// */
|
||||
// @Slf4j
|
||||
// @Service
|
||||
// public class DataAliasApiImpl implements DataAliasApi {
|
||||
//
|
||||
// @Resource
|
||||
// private DataAliasService dataAliasService;
|
||||
//
|
||||
// @Resource
|
||||
// private DataAliasDAO dataAliasDAO;
|
||||
//
|
||||
// @Override
|
||||
// public Long createDataAlias(DataAliasCreateDTO dto) {
|
||||
// log.info("DataAliasApi.createDataAlias dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataAliasCreateRequest request = DataAliasProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 创建
|
||||
// return dataAliasService.createDataAlias(request);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer updateDataAliasById(DataAliasUpdateDTO dto) {
|
||||
// log.info("DataAliasApi.updateDataAliasById dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 转换
|
||||
// DataAliasUpdateRequest request = DataAliasProviderConvert.MAPPER.toRequest(dto);
|
||||
// // 修改
|
||||
// return dataAliasService.updateDataAliasById(request);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public DataAliasDTO getDataAliasById(Long id) {
|
||||
// log.info("DataAliasApi.getDataAliasById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 修改
|
||||
// DataAliasDO record = dataAliasDAO.selectById(id);
|
||||
// if (record == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // 转换
|
||||
// return DataAliasProviderConvert.MAPPER.to(record);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataAliasDTO> getDataAliasByIdList(List<Long> idList) {
|
||||
// log.info("DataAliasApi.getDataAliasByIdList idList: {}", idList);
|
||||
// if (Lists.isEmpty(idList)) {
|
||||
// return new ArrayList<>();
|
||||
// }
|
||||
// // 查询
|
||||
// List<DataAliasDO> rows = dataAliasDAO.selectBatchIds(idList);
|
||||
// // 转换
|
||||
// return DataAliasProviderConvert.MAPPER.toList(rows);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataAliasDTO> getDataAliasList(DataAliasQueryDTO dto) {
|
||||
// log.info("DataAliasApi.getDataAliasList dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataAliasDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataAliasDAO.of(wrapper).list(DataAliasProviderConvert.MAPPER::to);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<DataAliasDTO> getDataAliasListByCache() {
|
||||
// return dataAliasService.getDataAliasListByCache()
|
||||
// .stream()
|
||||
// .map(DataAliasProviderConvert.MAPPER::to)
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Long getDataAliasCount(DataAliasQueryDTO dto) {
|
||||
// log.info("DataAliasApi.getDataAliasCount dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataAliasDO> wrapper = this.buildQueryWrapper(dto);
|
||||
// // 查询
|
||||
// return dataAliasDAO.selectCount(wrapper);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataAliasById(Long id) {
|
||||
// log.info("DataAliasApi.deleteDataAliasById id: {}", id);
|
||||
// Valid.notNull(id, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataAliasService.deleteDataAliasById(id);
|
||||
// log.info("DataAliasApi.deleteDataAliasById id: {}, effect: {}", id, effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataAliasByIdList(List<Long> idList) {
|
||||
// log.info("DataAliasApi.deleteDataAliasByIdList idList: {}", idList);
|
||||
// Valid.notEmpty(idList, ErrorMessage.ID_MISSING);
|
||||
// // 删除
|
||||
// Integer effect = dataAliasService.deleteDataAliasByIdList(idList);
|
||||
// log.info("DataAliasApi.deleteDataAliasByIdList effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Integer deleteDataAlias(DataAliasQueryDTO dto) {
|
||||
// log.info("DataAliasApi.deleteDataAlias dto: {}", JSON.toJSONString(dto));
|
||||
// Valid.valid(dto);
|
||||
// // 删除
|
||||
// Integer effect = dataAliasService.deleteDataAlias(DataAliasProviderConvert.MAPPER.toRequest(dto));
|
||||
// log.info("DataAliasApi.deleteDataAlias effect: {}", effect);
|
||||
// return effect;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 构建查询 wrapper
|
||||
// *
|
||||
// * @param dto dto
|
||||
// * @return wrapper
|
||||
// */
|
||||
// private LambdaQueryWrapper<DataAliasDO> buildQueryWrapper(DataAliasQueryDTO dto) {
|
||||
// return dataAliasDAO.wrapper()
|
||||
// .eq(DataAliasDO::getId, dto.getId())
|
||||
// .eq(DataAliasDO::getUserId, dto.getUserId())
|
||||
// .eq(DataAliasDO::getRelId, dto.getRelId())
|
||||
// .eq(DataAliasDO::getType, dto.getType())
|
||||
// .eq(DataAliasDO::getAlias, dto.getAlias());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.orion.ops.module.infra.convert;
|
||||
|
||||
import com.orion.ops.module.infra.entity.domain.DataAliasDO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataAliasUpdateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 数据别名 内部对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataAliasConvert {
|
||||
|
||||
DataAliasConvert MAPPER = Mappers.getMapper(DataAliasConvert.class);
|
||||
|
||||
DataAliasDO to(DataAliasUpdateRequest request);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.orion.ops.module.infra.convert;
|
||||
|
||||
import com.orion.ops.module.infra.entity.domain.DataAliasDO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataAliasDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataAliasQueryDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataAliasUpdateDTO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataAliasUpdateRequest;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据别名 对外服务对象转换器
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataAliasProviderConvert {
|
||||
|
||||
DataAliasProviderConvert MAPPER = Mappers.getMapper(DataAliasProviderConvert.class);
|
||||
|
||||
DataAliasDO to(DataAliasDTO dto);
|
||||
|
||||
DataAliasDTO to(DataAliasDO domain);
|
||||
|
||||
DataAliasDO to(DataAliasQueryDTO domain);
|
||||
|
||||
DataAliasDO to(DataAliasUpdateDTO update);
|
||||
|
||||
DataAliasUpdateRequest toRequest(DataAliasUpdateDTO request);
|
||||
|
||||
List<DataAliasDTO> toList(List<DataAliasDO> list);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.orion.ops.module.infra.dao;
|
||||
|
||||
import com.orion.ops.framework.mybatis.core.mapper.IMapper;
|
||||
import com.orion.ops.module.infra.entity.domain.DataAliasDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 数据别名 Mapper 接口
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Mapper
|
||||
public interface DataAliasDAO extends IMapper<DataAliasDO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.orion.ops.module.infra.define.cache;
|
||||
|
||||
import com.orion.lang.define.cache.key.CacheKeyBuilder;
|
||||
import com.orion.lang.define.cache.key.CacheKeyDefine;
|
||||
import com.orion.lang.define.cache.key.struct.RedisCacheStruct;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 数据别名缓存 key
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
public interface DataAliasCacheKeyDefine {
|
||||
|
||||
CacheKeyDefine DATA_ALIAS = new CacheKeyBuilder()
|
||||
.key("data:alias:{}:{}")
|
||||
.desc("数据别名 ${userId} ${type}")
|
||||
.type(String.class)
|
||||
.struct(RedisCacheStruct.HASH)
|
||||
.timeout(1, TimeUnit.DAYS)
|
||||
.build();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.Module;
|
||||
import com.orion.ops.framework.biz.operator.log.core.factory.InitializingOperatorTypes;
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
|
||||
/**
|
||||
* 数据别名 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Module("infra:data-alias")
|
||||
public class DataAliasOperatorType extends InitializingOperatorTypes {
|
||||
|
||||
public static final String CREATE = "data-alias:create";
|
||||
|
||||
public static final String UPDATE = "data-alias:update";
|
||||
|
||||
public static final String DELETE = "data-alias:delete";
|
||||
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建数据别名"),
|
||||
new OperatorType(M, UPDATE, "更新数据别名"),
|
||||
new OperatorType(H, DELETE, "删除数据别名"),
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.orion.ops.module.infra.entity.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.orion.ops.framework.mybatis.core.domain.BaseDO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
/**
|
||||
* 数据别名 实体对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName(value = "data_alias", autoResultMap = true)
|
||||
@Schema(name = "DataAliasDO", description = "数据别名 实体对象")
|
||||
public class DataAliasDO extends BaseDO {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "id")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户id")
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "数据id")
|
||||
@TableField("rel_id")
|
||||
private Long relId;
|
||||
|
||||
@Schema(description = "数据类型")
|
||||
@TableField("type")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "别名")
|
||||
@TableField("alias")
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.orion.ops.module.infra.entity.request.data;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 数据别名 更新请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "DataAliasUpdateRequest", description = "数据别名 更新请求对象")
|
||||
public class DataAliasUpdateRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "用户id")
|
||||
private Long userId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "数据id")
|
||||
private Long relId;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "数据类型")
|
||||
private String type;
|
||||
|
||||
@NotBlank
|
||||
@Size(max = 32)
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.orion.ops.module.infra.service;
|
||||
|
||||
import com.orion.ops.module.infra.entity.request.data.DataAliasUpdateRequest;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据别名 服务类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
public interface DataAliasService {
|
||||
|
||||
/**
|
||||
* 更新数据别名
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateDataAlias(DataAliasUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 查询数据别名
|
||||
*
|
||||
* @param userId userId
|
||||
* @param type type
|
||||
* @param relId relId
|
||||
* @return aliasName
|
||||
*/
|
||||
String getDataAlias(Long userId, String type, Long relId);
|
||||
|
||||
/**
|
||||
* 查询数据别名
|
||||
*
|
||||
* @param userId userId
|
||||
* @param type type
|
||||
* @return relId:aliasName
|
||||
*/
|
||||
Map<Long, String> getDataAlias(Long userId, String type);
|
||||
|
||||
/**
|
||||
* 删除数据别名
|
||||
*
|
||||
* @param userId userId
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataAliasByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 删除数据别名
|
||||
*
|
||||
* @param type type
|
||||
* @param relId relId
|
||||
* @return effect
|
||||
*/
|
||||
Integer deleteDataAliasByRelId(String type, Long relId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisMaps;
|
||||
import com.orion.ops.framework.redis.core.utils.barrier.CacheBarriers;
|
||||
import com.orion.ops.module.infra.convert.DataAliasConvert;
|
||||
import com.orion.ops.module.infra.dao.DataAliasDAO;
|
||||
import com.orion.ops.module.infra.define.cache.DataAliasCacheKeyDefine;
|
||||
import com.orion.ops.module.infra.entity.domain.DataAliasDO;
|
||||
import com.orion.ops.module.infra.entity.request.data.DataAliasUpdateRequest;
|
||||
import com.orion.ops.module.infra.service.DataAliasService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 数据别名 服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-18 17:37
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DataAliasServiceImpl implements DataAliasService {
|
||||
|
||||
@Resource
|
||||
private DataAliasDAO dataAliasDAO;
|
||||
// @Override
|
||||
// public Integer deleteDataAlias(DataAliasQueryRequest request) {
|
||||
// log.info("DataAliasService.deleteDataAlias request: {}", JSON.toJSONString(request));
|
||||
// // 条件
|
||||
// LambdaQueryWrapper<DataAliasDO> wrapper = this.buildQueryWrapper(request);
|
||||
// // 删除
|
||||
// int effect = dataAliasDAO.delete(wrapper);
|
||||
// log.info("DataAliasService.deleteDataAlias effect: {}", effect);
|
||||
// // 删除缓存
|
||||
// RedisMaps.delete(DataAliasCacheKeyDefine.DATA_ALIAS);
|
||||
// return effect;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Integer updateDataAlias(DataAliasUpdateRequest request) {
|
||||
// 检查是否存在
|
||||
Long userId = request.getUserId();
|
||||
String type = request.getType();
|
||||
DataAliasDO alias = dataAliasDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataAliasDO::getUserId, userId)
|
||||
.eq(DataAliasDO::getType, type)
|
||||
.eq(DataAliasDO::getRelId, request.getRelId())
|
||||
.then()
|
||||
.only()
|
||||
.get();
|
||||
int effect;
|
||||
if (alias == null) {
|
||||
// 插入
|
||||
DataAliasDO record = DataAliasConvert.MAPPER.to(request);
|
||||
effect = dataAliasDAO.insert(record);
|
||||
} else {
|
||||
// 更新
|
||||
DataAliasDO update = DataAliasDO.builder()
|
||||
.id(alias.getId())
|
||||
.alias(request.getAlias())
|
||||
.build();
|
||||
effect = dataAliasDAO.updateById(update);
|
||||
}
|
||||
// 删除缓存
|
||||
RedisMaps.delete(DataAliasCacheKeyDefine.DATA_ALIAS.format(userId, type));
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataAlias(Long userId, String type, Long relId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getDataAlias(Long userId, String type) {
|
||||
// 查询缓存
|
||||
String key = DataAliasCacheKeyDefine.DATA_ALIAS.format(userId, type);
|
||||
Map<String, String> entities = RedisMaps.entities(key);
|
||||
if (Maps.isEmpty(entities)) {
|
||||
// 查询数据库
|
||||
entities = dataAliasDAO.of()
|
||||
.createWrapper()
|
||||
.eq(DataAliasDO::getUserId, userId)
|
||||
.eq(DataAliasDO::getType, type)
|
||||
.then()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
s -> String.valueOf(s.getRelId()),
|
||||
DataAliasDO::getAlias,
|
||||
Functions.right())
|
||||
);
|
||||
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.MAP.check(entities);
|
||||
// 设置缓存
|
||||
RedisMaps.putAll(key, DataAliasCacheKeyDefine.DATA_ALIAS, entities);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.MAP.remove(entities);
|
||||
// 转换
|
||||
return Maps.map(entities, Long::valueOf, Function.identity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataAliasByUserId(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteDataAliasByRelId(String type, Long relId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -214,12 +214,12 @@ public class DataGroupRelServiceImpl implements DataGroupRelService {
|
||||
.map(DataGroupRelDO::getRelId)
|
||||
.collect(Collectors.toList());
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.LONG.check(list);
|
||||
CacheBarriers.LIST.check(list);
|
||||
// 设置缓存
|
||||
RedisLists.pushAll(key, DataGroupCacheKeyDefine.DATA_GROUP_REL_GROUP, list, Object::toString);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.LONG.remove(list);
|
||||
CacheBarriers.LIST.remove(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,12 +156,12 @@ public class DataPermissionServiceImpl implements DataPermissionService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.LONG.check(list);
|
||||
CacheBarriers.LIST.check(list);
|
||||
// 设置缓存
|
||||
RedisLists.pushAll(cacheKey, DataPermissionCacheKeyDefine.DATA_PERMISSION_USER, list, String::valueOf);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.LONG.remove(list);
|
||||
CacheBarriers.LIST.remove(list);
|
||||
return list.stream()
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -104,12 +104,12 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
// 设置屏障 防止穿透
|
||||
CacheBarriers.LONG.check(list);
|
||||
CacheBarriers.LIST.check(list);
|
||||
// 设置缓存
|
||||
RedisLists.pushAll(cacheKey, FavoriteCacheKeyDefine.FAVORITE, list, String::valueOf);
|
||||
}
|
||||
// 删除屏障
|
||||
CacheBarriers.LONG.remove(list);
|
||||
CacheBarriers.LIST.remove(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.orion.ops.module.infra.dao.DataAliasDAO">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.orion.ops.module.infra.entity.domain.DataAliasDO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="rel_id" property="relId"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="alias" property="alias"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="updater" property="updater"/>
|
||||
<result column="deleted" property="deleted"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, rel_id, type, alias, create_time, update_time, creator, updater, deleted
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user