fix javadoc warning
This commit is contained in:
@@ -9,11 +9,19 @@ import java.lang.annotation.Annotation;
|
||||
/**
|
||||
* 数据验证动态消息返回抽象类
|
||||
*
|
||||
* @param <A> 注解类型
|
||||
* @param <T> 校验数据类型
|
||||
* @author 夜雨
|
||||
* @version 2023-05-07 00:08
|
||||
*/
|
||||
public abstract class AbstractValidator<A extends Annotation, T> implements ConstraintValidator<A, T> {
|
||||
|
||||
/**
|
||||
* 创建校验器
|
||||
*/
|
||||
protected AbstractValidator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证处理器,入参验证数据,返回错误消息语言映射,返回 null 时表示通过验证
|
||||
*
|
||||
@@ -32,4 +40,4 @@ public abstract class AbstractValidator<A extends Annotation, T> implements Cons
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,20 @@ public class GlobalExceptionHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
private static final String DEV_LANG_CONFIG = "dev.lang";
|
||||
|
||||
/**
|
||||
* 创建全局异常处理器
|
||||
*/
|
||||
public GlobalExceptionHandler() {
|
||||
}
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String env;
|
||||
|
||||
/**
|
||||
* @param e
|
||||
* @return
|
||||
* 消息转换异常
|
||||
*
|
||||
* @param e 异常
|
||||
* @return 异常返回
|
||||
*/
|
||||
@ExceptionHandler(HttpMessageConversionException.class)
|
||||
public TimiResponse<?> conversionException(HttpMessageConversionException e) {
|
||||
|
||||
@@ -32,8 +32,15 @@ public class GlobalReturnHandler implements ResponseBodyAdvice<Object> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalReturnHandler.class);
|
||||
|
||||
/** 多语言头处理回调 */
|
||||
private CallbackArgReturn<LanguageMsgMapping<?>, String> multilingualHeader;
|
||||
|
||||
/**
|
||||
* 创建全局返回处理器
|
||||
*/
|
||||
public GlobalReturnHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(@NonNull MethodParameter returnType, @NonNull Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return Objects.requireNonNull(returnType.getMethod()).getAnnotation(IgnoreGlobalReturn.class) == null;
|
||||
@@ -71,10 +78,20 @@ public class GlobalReturnHandler implements ResponseBodyAdvice<Object> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多语言头处理回调
|
||||
*
|
||||
* @return 处理回调
|
||||
*/
|
||||
public CallbackArgReturn<LanguageMsgMapping<?>, String> getMultilingualHeader() {
|
||||
return multilingualHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置多语言头处理回调
|
||||
*
|
||||
* @param multilingualHeader 处理回调
|
||||
*/
|
||||
public void setMultilingualHeader(CallbackArgReturn<LanguageMsgMapping<?>, String> multilingualHeader) {
|
||||
this.multilingualHeader = multilingualHeader;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.function.Consumer;
|
||||
* RedisTemplate 功能封装,简化 Redis 操作
|
||||
* <p>serializer 为该 RedisTemplate 的键的序列化操作,序列化解析器由 {@link AbstractRedisConfig} 提供
|
||||
*
|
||||
* @param <K> 键类型
|
||||
* @param <V> 值类型
|
||||
* @author 夜雨
|
||||
* @version 2021-11-21 09:58
|
||||
*/
|
||||
@@ -30,6 +32,12 @@ public class Redis<K, V> {
|
||||
private final RedisSerializer<K> serializer;
|
||||
private final RedisTemplate<K, V> redis;
|
||||
|
||||
/**
|
||||
* 创建 Redis 操作封装
|
||||
*
|
||||
* @param redis RedisTemplate 实例
|
||||
* @param serializer 键序列化器
|
||||
*/
|
||||
public Redis(RedisTemplate<K, V> redis, RedisSerializer<K> serializer) {
|
||||
this.redis = redis;
|
||||
this.serializer = serializer;
|
||||
@@ -47,9 +55,9 @@ public class Redis<K, V> {
|
||||
/**
|
||||
* 加锁
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @param timeoutMS
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
* @param timeoutMS 超时时间毫秒
|
||||
* @return true 为加锁成功
|
||||
*/
|
||||
public boolean lock(K key, V value, long timeoutMS) {
|
||||
@@ -57,6 +65,11 @@ public class Redis<K, V> {
|
||||
return lock != null && lock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放锁
|
||||
*
|
||||
* @param key 键
|
||||
*/
|
||||
public void releaseLock(K key) {
|
||||
destroy(key);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,17 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* Redis 序列化工具
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2023-07-17 16:20
|
||||
*/
|
||||
public class RedisSerializers {
|
||||
|
||||
/** 工具类禁止实例化 */
|
||||
private RedisSerializers() {
|
||||
}
|
||||
|
||||
/** 字符串序列化 */
|
||||
public static final StringRedisSerializer STRING = new StringRedisSerializer();
|
||||
|
||||
@@ -76,7 +82,13 @@ public class RedisSerializers {
|
||||
}
|
||||
};
|
||||
|
||||
/** Gson 序列化 */
|
||||
/**
|
||||
* Gson 序列化
|
||||
*
|
||||
* @param <T> 数据类型
|
||||
* @param clazz 数据类型
|
||||
* @return Redis 序列化器
|
||||
*/
|
||||
public static <T> RedisSerializer<T> gsonSerializer(Class<T> clazz) {
|
||||
return new RedisSerializer<>() {
|
||||
|
||||
|
||||
@@ -45,6 +45,12 @@ public class SQLProvider {
|
||||
/** 反射缓存 */
|
||||
private static final Map<Class<?>, EntityMeta> ENTITY_META_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* 创建 SQL 提供器
|
||||
*/
|
||||
public SQLProvider() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 Page 对象查询数据列表
|
||||
*
|
||||
@@ -148,6 +154,12 @@ public class SQLProvider {
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
*
|
||||
* @param context 代理器上下文
|
||||
* @return SQL
|
||||
*/
|
||||
public String selectAll(ProviderContext context) {
|
||||
EntityMeta meta = getEntityMeta(context);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
@@ -162,6 +174,7 @@ public class SQLProvider {
|
||||
* 插入
|
||||
* <p><i>不实现 {@link Creatable} 也允许调用是合理的,某些数据属于关联数据,不参与主创建过程</i></p>
|
||||
*
|
||||
* @param context 代理器上下文
|
||||
* @param entity 实体
|
||||
* @return SQL
|
||||
*/
|
||||
@@ -299,6 +312,12 @@ public class SQLProvider {
|
||||
return "UPDATE `%s` SET `deleted_at` = %s WHERE `%s` = #{id}".formatted(meta.table, Time.now(), meta.idFieldColumn.columnName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据示例批量逻辑删除
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return SQL
|
||||
*/
|
||||
public String deleteAllByExample(Object entity) {
|
||||
EntityMeta meta = getEntityMeta(entity.getClass());
|
||||
TimiException.required(meta.canDelete, "not allow delete for %s".formatted(meta.entityClass));
|
||||
@@ -398,6 +417,11 @@ public class SQLProvider {
|
||||
/** true 为可销毁(硬删除) */
|
||||
final boolean canDestroy;
|
||||
|
||||
/**
|
||||
* 创建实体元数据
|
||||
*
|
||||
* @param entityClass 实体类型
|
||||
*/
|
||||
public EntityMeta(Class<?> entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
|
||||
@@ -459,38 +483,83 @@ public class SQLProvider {
|
||||
return sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实体类型
|
||||
*
|
||||
* @return 实体类型
|
||||
*/
|
||||
public Class<?> getEntityClass() {
|
||||
return entityClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表名
|
||||
*
|
||||
* @return 表名
|
||||
*/
|
||||
public String getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询字段映射
|
||||
*
|
||||
* @return 查询字段映射
|
||||
*/
|
||||
public String getSelectAllClause() {
|
||||
return selectAllClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 ID 字段映射
|
||||
*
|
||||
* @return ID 字段映射
|
||||
*/
|
||||
public FieldColumn getIdFieldColumn() {
|
||||
return idFieldColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段映射列表
|
||||
*
|
||||
* @return 字段映射列表
|
||||
*/
|
||||
public List<FieldColumn> getFieldColumnList() {
|
||||
return fieldColumnList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可创建
|
||||
*
|
||||
* @return true 为可创建
|
||||
*/
|
||||
public boolean canCreate() {
|
||||
return canCreate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可更新
|
||||
*
|
||||
* @return true 为可更新
|
||||
*/
|
||||
public boolean canUpdate() {
|
||||
return canUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可删除
|
||||
*
|
||||
* @return true 为可删除
|
||||
*/
|
||||
public boolean canDelete() {
|
||||
return canDelete;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可销毁
|
||||
*
|
||||
* @return true 为可销毁
|
||||
*/
|
||||
public boolean canDestroy() {
|
||||
return canDestroy;
|
||||
}
|
||||
@@ -525,6 +594,11 @@ public class SQLProvider {
|
||||
|
||||
final DeleteColumn.Type deleteColumnType;
|
||||
|
||||
/**
|
||||
* 创建字段映射
|
||||
*
|
||||
* @param field 字段
|
||||
*/
|
||||
public FieldColumn(Field field) {
|
||||
this.field = field;
|
||||
|
||||
@@ -551,6 +625,12 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否为空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为 null
|
||||
*/
|
||||
public boolean isNull(Object entity) {
|
||||
try {
|
||||
return Ref.getFieldValue(entity, field, Object.class) == null;
|
||||
@@ -559,10 +639,22 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否非空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为非 null
|
||||
*/
|
||||
public boolean isNotNull(Object entity) {
|
||||
return !isNull(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否为空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为空
|
||||
*/
|
||||
public boolean isEmpty(Object entity) {
|
||||
try {
|
||||
return TimiJava.isEmpty(Ref.getFieldValue(entity, field, Object.class));
|
||||
@@ -571,10 +663,22 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字段值是否非空
|
||||
*
|
||||
* @param entity 实体
|
||||
* @return true 为非空
|
||||
*/
|
||||
public boolean isNotEmpty(Object entity) {
|
||||
return !isEmpty(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段字符串值
|
||||
*
|
||||
* @param obj 实体
|
||||
* @return 字符串值
|
||||
*/
|
||||
public String getAsString(Object obj) {
|
||||
try {
|
||||
return field.get(obj).toString();
|
||||
@@ -583,30 +687,65 @@ public class SQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段
|
||||
*
|
||||
* @return 字段
|
||||
*/
|
||||
public Field getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段名
|
||||
*
|
||||
* @return 字段名
|
||||
*/
|
||||
public String getFieldName() {
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列名
|
||||
*
|
||||
* @return 列名
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 ID 字段
|
||||
*
|
||||
* @return true 为 ID 字段
|
||||
*/
|
||||
public boolean isId() {
|
||||
return isId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否非 ID 字段
|
||||
*
|
||||
* @return true 为非 ID 字段
|
||||
*/
|
||||
public boolean isNotId() {
|
||||
return !isId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动 UUID
|
||||
*
|
||||
* @return true 为自动 UUID
|
||||
*/
|
||||
public boolean isAutoUUID() {
|
||||
return isAutoUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动大写 UUID
|
||||
*
|
||||
* @return true 为自动大写 UUID
|
||||
*/
|
||||
public boolean isAutoUpperUUID() {
|
||||
return isAutoUpperUUID;
|
||||
}
|
||||
|
||||
@@ -9,13 +9,19 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* Yaml 属性源加载工厂
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-10-13 16:29
|
||||
*/
|
||||
public class YamlPropertySourceFactory implements PropertySourceFactory {
|
||||
|
||||
/**
|
||||
* 创建 Yaml 属性源工厂
|
||||
*/
|
||||
public YamlPropertySourceFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @org.springframework.lang.NonNull PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
|
||||
List<PropertySource<?>> sources = new YamlPropertySourceLoader().load(resource.getResource().getFilename(), resource.getResource());
|
||||
|
||||
Reference in New Issue
Block a user