add lombok
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package com.imyeyu.spring.util;
|
||||
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import jakarta.validation.ConstraintValidator;
|
||||
import jakarta.validation.ConstraintValidatorContext;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
@@ -16,12 +16,6 @@ import java.lang.annotation.Annotation;
|
||||
*/
|
||||
public abstract class AbstractValidator<A extends Annotation, T> implements ConstraintValidator<A, T> {
|
||||
|
||||
/**
|
||||
* 创建校验器
|
||||
*/
|
||||
protected AbstractValidator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证处理器,入参验证数据,返回错误消息语言映射,返回 null 时表示通过验证
|
||||
*
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.imyeyu.spring.entity.Updatable;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.utils.Text;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.Getter;
|
||||
import org.apache.ibatis.builder.annotation.ProviderContext;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -443,6 +444,7 @@ public abstract class BaseSQLProvider {
|
||||
* @author 夜雨
|
||||
* @since 2025-02-05 23:47
|
||||
*/
|
||||
@Getter
|
||||
protected static class EntityMeta {
|
||||
|
||||
/** 实体类 */
|
||||
@@ -541,51 +543,6 @@ public abstract class BaseSQLProvider {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可创建
|
||||
*
|
||||
@@ -629,6 +586,7 @@ public abstract class BaseSQLProvider {
|
||||
* @author 夜雨
|
||||
* @since 2025-02-07 09:54
|
||||
*/
|
||||
@Getter
|
||||
protected static class FieldColumn {
|
||||
|
||||
/** 字段 */
|
||||
@@ -745,42 +703,6 @@ public abstract class BaseSQLProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段
|
||||
*
|
||||
* @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 字段
|
||||
*
|
||||
@@ -789,23 +711,5 @@ public abstract class BaseSQLProvider {
|
||||
public boolean isNotId() {
|
||||
return !isId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动 UUID
|
||||
*
|
||||
* @return true 为自动 UUID
|
||||
*/
|
||||
public boolean isAutoUUID() {
|
||||
return isAutoUUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动大写 UUID
|
||||
*
|
||||
* @return true 为自动大写 UUID
|
||||
*/
|
||||
public boolean isAutoUpperUUID() {
|
||||
return isAutoUpperUUID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
|
||||
private static final String DEV_LANG_CONFIG = "dev.lang";
|
||||
|
||||
/**
|
||||
* 创建全局异常处理器
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.imyeyu.java.bean.timi.TimiResponse;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLogInterceptor;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -27,6 +28,7 @@ import java.util.Objects;
|
||||
* @author 夜雨
|
||||
* @version 2023-04-30 00:59
|
||||
*/
|
||||
@Data
|
||||
@RestControllerAdvice
|
||||
public class GlobalReturnHandler implements ResponseBodyAdvice<Object> {
|
||||
|
||||
@@ -77,22 +79,4 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.imyeyu.spring.util;
|
||||
|
||||
import com.imyeyu.spring.config.AbstractRedisConfig;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.config.AbstractRedisConfig;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
@@ -27,30 +27,7 @@ import java.util.function.Consumer;
|
||||
* @author 夜雨
|
||||
* @version 2021-11-21 09:58
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Redis 模板对象
|
||||
*
|
||||
* @return Redis 模板对象
|
||||
*/
|
||||
public RedisTemplate<?, ?> getRedis() {
|
||||
return redis;
|
||||
}
|
||||
public record Redis<K, V>(RedisTemplate<K, V> redis, RedisSerializer<K> serializer) {
|
||||
|
||||
/**
|
||||
* 加锁
|
||||
@@ -101,8 +78,8 @@ public class Redis<K, V> {
|
||||
* @param value 值
|
||||
*/
|
||||
public void setAndKeepTTL(K key, V value) {
|
||||
Long expire = redis.getExpire(key, TimeUnit.MILLISECONDS);
|
||||
if (expire == null || expire <= 0) {
|
||||
long expire = redis.getExpire(key, TimeUnit.MILLISECONDS);
|
||||
if (expire <= 0) {
|
||||
// 判死
|
||||
destroy(key);
|
||||
} else {
|
||||
@@ -210,8 +187,8 @@ public class Redis<K, V> {
|
||||
public Map<K, List<V>> getAllList() {
|
||||
Map<K, List<V>> r = new HashMap<>();
|
||||
List<K> ks = keys("*");
|
||||
for (int i = 0; i < ks.size(); i++) {
|
||||
r.put(ks.get(i), getList(ks.get(i)));
|
||||
for (K k : ks) {
|
||||
r.put(k, getList(k));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -235,9 +212,9 @@ public class Redis<K, V> {
|
||||
*/
|
||||
public List<V> values() {
|
||||
List<V> r = new ArrayList<>();
|
||||
List<K> keys = keys("*");
|
||||
for (K key : keys) {
|
||||
r.add(get(key));
|
||||
List<K> ks = keys("*");
|
||||
for (K k : ks) {
|
||||
r.add(get(k));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -250,8 +227,8 @@ public class Redis<K, V> {
|
||||
public Map<K, V> map() {
|
||||
Map<K, V> r = new HashMap<>();
|
||||
List<K> ks = keys("*");
|
||||
for (int i = 0; i < ks.size(); i++) {
|
||||
r.put(ks.get(i), get(ks.get(i)));
|
||||
for (K k : ks) {
|
||||
r.put(k, get(k));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -280,8 +257,7 @@ public class Redis<K, V> {
|
||||
*/
|
||||
public boolean destroy(K key) {
|
||||
if (TimiJava.isNotEmpty(key) && has(key)) {
|
||||
Boolean isSucceed = redis.delete(key);
|
||||
return isSucceed != null && isSucceed;
|
||||
return redis.delete(key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,6 @@ public class YamlPropertySourceFactory implements PropertySourceFactory {
|
||||
@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());
|
||||
return sources.get(0);
|
||||
return sources.getFirst();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user