初始化项目

This commit is contained in:
2026-04-21 16:12:04 +08:00
parent 4541af2c63
commit f9d96473da
443 changed files with 36365 additions and 19 deletions

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xujun</groupId>
<artifactId>xtools-app-sys</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>xtools-app-sys-param</artifactId>
<!-- 依赖 -->
<dependencies>
<!-- xtools begin -->
<!-- xtools-boot-base -->
<dependency>
<groupId>org.xujun</groupId>
<artifactId>xtools-boot-api</artifactId>
</dependency>
<!-- xtools-boot-cache-redis -->
<dependency>
<groupId>org.xujun</groupId>
<artifactId>xtools-boot-cache-redis</artifactId>
</dependency>
<!-- xtools end -->
<!-- 项目模块 begin -->
<dependency>
<groupId>org.xujun</groupId>
<artifactId>xtools-app-common-cache</artifactId>
</dependency>
<!-- 项目模块 end -->
<!-- fastjson2 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,32 @@
package xtools.app.sys.param.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* <p>Title : SysBlacklistDto</p>
* <p>Description : SysBlacklistDto</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/3/18 16:03
*/
@Data
public class SysBlacklistDto implements Serializable {
/**
* ip
*/
private List<String> ipList;
/**
* uri
*/
private List<String> uriList;
}

View File

@@ -0,0 +1,40 @@
package xtools.app.sys.param.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* <p>Title : UpdateHistoryDto</p>
* <p>Description : UpdateHistoryDto</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/4/3 09:39
*/
@Data
public class UpdateHistoryDto implements Serializable {
/**
* 信息
*/
@Schema(description = "信息")
private String info;
/**
* 显示时间
*/
@Schema(description = "显示时间")
private String showTime;
/**
* 所属版本
*/
@Schema(description = "所属版本")
private String version;
}

View File

@@ -0,0 +1,25 @@
package xtools.app.sys.param.enums;
import xtools.boot.api.enums.BaseEnum;
/**
* <p>Title : SysParamBaseEnum</p>
* <p>Description : SysParamBaseEnum</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/3/26 10:29
*/
public interface SysParamBaseEnum extends BaseEnum {
/**
* 获取数据类型
*
* @return 数据类型
*/
SysParamDataType type();
}

View File

@@ -0,0 +1,75 @@
package xtools.app.sys.param.enums;
import xtools.boot.api.enums.BaseEnum;
/**
* <p>Title : SysParamDataType</p>
* <p>Description : SysParamDataType</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/2/4 16:27
*/
public enum SysParamDataType implements BaseEnum {
// json
JSON(1, "json"),
// array
ARRAY(2, "array"),
;
/**
* 编码
*/
private final int code;
/**
* 说明
*/
private final String desc;
/**
* 构造函数
*
* @param code 编码
* @param desc 说明
*/
SysParamDataType(int code, String desc) {
this.code = code;
this.desc = desc;
}
/**
* 获取所有枚举
*
* @return 所有枚举
*/
@Override
public BaseEnum[] all() {
return values();
}
/**
* 获取枚举编码
*
* @return 枚举编码
*/
@Override
public int code() {
return code;
}
/**
* 获取枚举说明
*
* @return 枚举说明
*/
@Override
public String desc() {
return desc;
}
}

View File

@@ -0,0 +1,89 @@
package xtools.app.sys.param.enums;
import xtools.boot.api.enums.BaseEnum;
/**
* <p>Title : SysParamEnum</p>
* <p>Description : SysParamEnum</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/2/4 16:27
*/
public enum SysParamEnum implements SysParamBaseEnum {
// 系统更新历史
UPDATE_HISTORY(2, "sys-update-history", SysParamDataType.ARRAY);
/**
* 编码
*/
private final int code;
/**
* 说明
*/
private final String desc;
/**
* 数据类型
*/
private final SysParamDataType type;
/**
* 构造函数
*
* @param code 编码
* @param desc 说明
* @param type 数据类型
*/
SysParamEnum(int code, String desc, SysParamDataType type) {
this.code = code;
this.desc = desc;
this.type = type;
}
/**
* 获取所有枚举
*
* @return 所有枚举
*/
@Override
public BaseEnum[] all() {
return values();
}
/**
* 获取枚举编码
*
* @return 枚举编码
*/
@Override
public int code() {
return code;
}
/**
* 获取枚举说明
*
* @return 枚举说明
*/
@Override
public String desc() {
return desc;
}
/**
* 获取数据类型
*
* @return 数据类型
*/
@Override
public SysParamDataType type() {
return type;
}
}

View File

@@ -0,0 +1,244 @@
package xtools.app.sys.param.utils;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import xtools.app.common.cache.enums.AppCache;
import xtools.app.sys.param.enums.SysParamBaseEnum;
import xtools.app.sys.param.enums.SysParamDataType;
import xtools.base.config.BaseParams;
import xtools.boot.api.exection.BizError;
import xtools.boot.cache.redis.base.RedisService;
import xtools.boot.cache.redis.utils.RedisUtils;
import xtools.core.CollectionUtils;
import java.util.List;
import java.util.Objects;
/**
* <p>Title : SysParamUtils</p>
* <p>Description : SysParamUtils</p>
* <p>DevelopTools : Idea_x64_v2026.1</p>
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
* <p>Company : org.xujun</p>
*
* @author : XuJun
* @version : 1.0.0
* @date : 2026/3/18 15:50
*/
@Slf4j
public class SysParamUtils implements BaseParams {
/**
* 系统参数缓存
*/
private static final AppCache CACHE_PARAM = AppCache.SYS_CACHE_PARAM;
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param bizType 业务类型
* @param clazz 数据类型
* @param <T> 数据类型
* @return 数据
*/
public static <T> T get(SysParamBaseEnum sysParamEnum, Object bizType, Class<T> clazz) {
RedisService redisService = RedisUtils.get();
try {
return redisService.get(getCacheKey(sysParamEnum.type(), sysParamEnum.desc(), bizType), clazz);
} catch (Exception e) {
log.error("获取缓存异常,dataType:{},dataKey:{}", sysParamEnum.type(), sysParamEnum.desc(), e);
throw new BizError("获取缓存异常");
}
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param clazz 数据类型
* @param defaultValue 默认值
* @param <T> 数据类型
* @return 数据
*/
public static <T> T getOrDefault(SysParamBaseEnum sysParamEnum, Class<T> clazz, T defaultValue) {
T data = get(sysParamEnum, clazz);
if (Objects.nonNull(data)) {
return data;
}
return defaultValue;
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param clazz 数据类型
* @param <T> 数据类型
* @return 数据
*/
public static <T> T get(SysParamBaseEnum sysParamEnum, Class<T> clazz) {
RedisService redisService = RedisUtils.get();
try {
return redisService.get(getCacheKey(sysParamEnum.type(), sysParamEnum.desc()), clazz);
} catch (Exception e) {
log.error("获取缓存异常,dataType:{},dataKey:{}", sysParamEnum.type(), sysParamEnum.desc(), e);
throw new BizError("获取缓存异常");
}
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param defaultValue 默认值
* @return 数据
*/
public static JSONObject getJsonOrDefault(SysParamBaseEnum sysParamEnum, JSONObject defaultValue) {
JSONObject data = getJson(sysParamEnum);
if (CollectionUtils.isNotEmpty(data)) {
return data;
}
return defaultValue;
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @return 数据
*/
public static JSONObject getJson(SysParamBaseEnum sysParamEnum) {
RedisService redisService = RedisUtils.get();
try {
return redisService.get(getCacheKey(sysParamEnum.type(), sysParamEnum.desc()), JSONObject.class);
} catch (Exception e) {
log.error("获取缓存异常,dataType:{},dataKey:{}", sysParamEnum.type(), sysParamEnum.desc(), e);
throw new BizError("获取缓存异常");
}
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param bizType 业务类型
* @param clazz 数据类型
* @param <T> 数据类型
* @return 数据
*/
public static <T> List<T> getArray(SysParamBaseEnum sysParamEnum, Object bizType, Class<T> clazz) {
RedisService redisService = RedisUtils.get();
try {
JSONArray array = redisService.get(getCacheKey(sysParamEnum.type(), sysParamEnum.desc(), bizType), JSONArray.class);
if (Objects.nonNull(array)) {
return array.toJavaList(clazz);
}
return null;
} catch (Exception e) {
log.error("获取缓存异常,dataType:{},dataKey:{}", sysParamEnum.type(), sysParamEnum.desc(), e);
throw new BizError("获取缓存异常");
}
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param clazz 数据类型
* @param defaultValue 默认值
* @param <T> 数据类型
* @return 数据
*/
public static <T> List<T> getArrayOrDefault(SysParamBaseEnum sysParamEnum, Class<T> clazz, List<T> defaultValue) {
List<T> array = getArray(sysParamEnum, clazz);
if (Objects.nonNull(array)) {
return array;
}
return defaultValue;
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param clazz 数据类型
* @param <T> 数据类型
* @return 数据
*/
public static <T> List<T> getArray(SysParamBaseEnum sysParamEnum, Class<T> clazz) {
JSONArray array = getArray(sysParamEnum);
if (Objects.nonNull(array)) {
return array.toJavaList(clazz);
}
return null;
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @param defaultValue 默认值
* @return 数据
*/
public static JSONArray getArrayOrDefault(SysParamBaseEnum sysParamEnum, JSONArray defaultValue) {
JSONArray data = getArray(sysParamEnum);
if (Objects.nonNull(data)) {
return data;
}
return defaultValue;
}
/**
* 获取系统缓存数据
*
* @param sysParamEnum 系统参数枚举
* @return 数据
*/
public static JSONArray getArray(SysParamBaseEnum sysParamEnum) {
RedisService redisService = RedisUtils.get();
try {
return redisService.get(getCacheKey(sysParamEnum.type(), sysParamEnum.desc()), JSONArray.class);
} catch (Exception e) {
log.error("获取缓存异常,dataType:{},dataKey:{}", sysParamEnum.type(), sysParamEnum.desc(), e);
throw new BizError("获取缓存异常");
}
}
/**
* 获取缓存的 key
*
* @param dataType 数据类型
* @param dataKey 数据 key
* @param bizType 业务类型
* @return 缓存的 key
*/
public static String getCacheKey(SysParamDataType dataType, String dataKey, Object bizType) {
return CACHE_PARAM.key() + dataType.desc() + CP_COLON + dataKey + bizType;
}
/**
* 获取缓存的 key
*
* @param dataType 数据类型
* @param dataKey 数据 key
* @return 缓存的 key
*/
public static String getCacheKey(SysParamDataType dataType, String dataKey) {
return CACHE_PARAM.key() + dataType.desc() + CP_COLON + dataKey;
}
/**
* 获取缓存的 key
*
* @param dataType 数据类型
* @param dataKey 数据 key
* @return 缓存的 key
*/
public static String getCacheKey(Integer dataType, String dataKey) {
String type = Objects.equals(dataType, CP_NUM1) ? "json" : "array";
return CACHE_PARAM.key() + type + CP_COLON + dataKey;
}
}