mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-06 18:53:45 +08:00
v3.15.0【新增】升级SaToken到最新版本;【新增】重磅优化 数据字典;【新增】升级wangEditor-next;【新增】优化缓存实现redis与caffeine
This commit is contained in:
@@ -3,6 +3,7 @@ package net.lab1024.sa.base.common.controller;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
|
||||
/**
|
||||
* 支撑类业务路由基类
|
||||
*
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
package net.lab1024.sa.base.common.json.deserializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.ObjectCodec;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典反序列化
|
||||
@@ -21,13 +18,13 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022-08-12 22:17:53
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
||||
public class DictDataDeserializer extends JsonDeserializer<String> {
|
||||
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
List<String> list = new ArrayList<>();
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
||||
@@ -11,6 +11,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static cn.hutool.core.util.CharsetUtil.UTF_8;
|
||||
|
||||
/**
|
||||
* 返回工具栏
|
||||
@@ -27,8 +30,8 @@ public class SmartResponseUtil {
|
||||
|
||||
public static void write(HttpServletResponse response, ResponseDTO<?> responseDTO) {
|
||||
// 重置response
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
|
||||
response.setCharacterEncoding(UTF_8);
|
||||
|
||||
try {
|
||||
response.getWriter().write(JSON.toJSONString(responseDTO));
|
||||
@@ -44,20 +47,20 @@ public class SmartResponseUtil {
|
||||
}
|
||||
|
||||
public static void setDownloadFileHeader(HttpServletResponse response, String fileName, Long fileSize) {
|
||||
response.setCharacterEncoding("utf-8");
|
||||
try {
|
||||
if (fileSize != null) {
|
||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
|
||||
}
|
||||
response.setCharacterEncoding(UTF_8);
|
||||
if (fileSize != null) {
|
||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(fileSize));
|
||||
}
|
||||
|
||||
if (SmartStringUtil.isNotEmpty(fileName)) {
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaTypeFactory.getMediaType(fileName).orElse(MediaType.APPLICATION_OCTET_STREAM) + ";charset=utf-8");
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20"));
|
||||
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION);
|
||||
if (SmartStringUtil.isNotEmpty(fileName)) {
|
||||
response.setHeader(HttpHeaders.CONTENT_TYPE, MediaTypeFactory.getMediaType(fileName).orElse(MediaType.APPLICATION_OCTET_STREAM) + ";charset=utf-8");
|
||||
try {
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode(fileName, UTF_8).replaceAll("\\+", "%20"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException(e);
|
||||
response.setHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, HttpHeaders.CONTENT_DISPOSITION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.lab1024.sa.base.config;
|
||||
|
||||
import net.lab1024.sa.base.module.support.cache.CacheService;
|
||||
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
|
||||
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 缓存配置
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2025/03/28
|
||||
*/
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
|
||||
private static final String REDIS_CACHE = "redis";
|
||||
private static final String CAFFEINE_CACHE = "caffeine";
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
||||
public CacheService redisCacheService() {
|
||||
return new RedisCacheServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = CAFFEINE_CACHE)
|
||||
public CacheService caffeineCacheService() {
|
||||
return new CaffeineCacheServiceImpl();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class DataSourceConfig {
|
||||
if (dataScopePlugin != null) {
|
||||
pluginsList.add(dataScopePlugin);
|
||||
}
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[pluginsList.size()]));
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[0]));
|
||||
// 添加字段自动填充处理
|
||||
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @Date 2019-09-02 23:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@@ -68,7 +68,7 @@ public class FileConfig implements WebMvcConfigurer {
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = "cloud")
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
|
||||
public AmazonS3 initAmazonS3() {
|
||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
||||
clientConfig.setProtocol(Protocol.HTTPS);
|
||||
|
||||
@@ -4,8 +4,12 @@ import net.lab1024.sa.base.common.constant.StringConst;
|
||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.RepeatSubmitAspect;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitCaffeineTicket;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitRedisTicket;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 重复提交配置
|
||||
@@ -14,14 +18,17 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @Date 2021/10/9 18:47
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
public class RepeatSubmitConfig {
|
||||
|
||||
@Resource
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
|
||||
@Bean
|
||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||
RepeatSubmitCaffeineTicket caffeineTicket = new RepeatSubmitCaffeineTicket(this::ticket);
|
||||
RepeatSubmitRedisTicket caffeineTicket = new RepeatSubmitRedisTicket(valueOperations, this::ticket);
|
||||
return new RepeatSubmitAspect(caffeineTicket);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,14 @@ package net.lab1024.sa.base.constant;
|
||||
* @Date 2022-05-30 21:22:12
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CacheKeyConst {
|
||||
|
||||
public static class Dict {
|
||||
|
||||
public static final String DICT_DATA = "dict_data_cache";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiDecrypt;
|
||||
@@ -25,7 +25,7 @@ import java.lang.reflect.Type;
|
||||
* @Date 2023/10/21 11:41:46
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@@ -37,16 +37,19 @@ public class DecryptRequestAdvice extends RequestBodyAdviceAdapter {
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return methodParameter.hasMethodAnnotation(ApiDecrypt.class) || methodParameter.hasParameterAnnotation(ApiDecrypt.class) || methodParameter.getContainingClass().isAnnotationPresent(ApiDecrypt.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
try {
|
||||
String bodyStr = IOUtils.toString(inputMessage.getBody(), ENCODING);
|
||||
ApiEncryptForm apiEncryptForm = JSONObject.parseObject(bodyStr, ApiEncryptForm.class);
|
||||
ApiEncryptForm apiEncryptForm = objectMapper.readValue(bodyStr, ApiEncryptForm.class);
|
||||
if (SmartStringUtil.isEmpty(apiEncryptForm.getEncryptData())) {
|
||||
return inputMessage;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,13 +24,13 @@ import javax.annotation.Resource;
|
||||
* @Date 2023/10/24 09:52:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO<Object>> {
|
||||
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
@@ -45,19 +44,18 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseDTO beforeBodyWrite(ResponseDTO body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body.getData() == null) {
|
||||
public ResponseDTO<Object> beforeBodyWrite(ResponseDTO<Object> body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body == null || body.getData() == null) {
|
||||
return body;
|
||||
}
|
||||
|
||||
String encrypt = null;
|
||||
try {
|
||||
encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
String encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,34 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.sa.base.constant.ReloadConst;
|
||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.cache.caffeine.CaffeineCache;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 缓存操作
|
||||
* 缓存服务
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
public interface CacheService {
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*
|
||||
*/
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
List<String> cacheNames();
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有key
|
||||
*
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
List<String> cacheKey(String cacheName);
|
||||
|
||||
/**
|
||||
* 移除某个key
|
||||
*
|
||||
* 移除某个 key
|
||||
*/
|
||||
void removeCache(String cacheName);
|
||||
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.sa.base.constant.ReloadConst;
|
||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.cache.caffeine.CaffeineCache;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* caffeine 缓存实现
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaffeineCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.lab1024.sa.base.constant.ReloadConst;
|
||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* redis 缓存实现
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2025/3/28
|
||||
*/
|
||||
public class RedisCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private RedisCacheManager redisCacheManager;
|
||||
|
||||
@Resource
|
||||
private RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(redisCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
// 获取 Redis 连接
|
||||
RedisConnection connection = redisConnectionFactory.getConnection();
|
||||
// 根据指定的 key 模式获取所有匹配的键
|
||||
Set<byte[]> keys = connection.keyCommands().keys((cacheName + ":*").getBytes());
|
||||
|
||||
if (keys != null) {
|
||||
return keys.stream().map(key -> {
|
||||
String redisKey = StrUtil.str(key, "utf-8");
|
||||
// 从 Redis 键中提取出最后一个冒号后面的字符串作为真正的键
|
||||
return redisKey.substring(redisKey.lastIndexOf(":") + 1);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
connection.close();
|
||||
return Lists.newArrayList(cacheName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = redisCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface CodeGeneratorConfigDao extends BaseMapper<CodeGeneratorConfigEntity> {
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface CodeGeneratorDao {
|
||||
|
||||
/**
|
||||
|
||||
@@ -84,14 +84,6 @@ public class VOVariableService extends CodeGenerateBaseVariableService {
|
||||
packageList.add("import io.swagger.v3.oas.annotations.media.Schema;");
|
||||
}
|
||||
|
||||
|
||||
//字典
|
||||
if (isDict(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("dict", "\n @JsonSerialize(using = DictValueVoSerializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonSerialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.serializer.DictValueVoSerializer;");
|
||||
}
|
||||
|
||||
//文件上传
|
||||
if (isFile(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("file", "\n @JsonSerialize(using = FileKeyVoSerializer.class)");
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import java.lang.annotation.Target;
|
||||
* @Date 2022-07-23 19:38:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface DataTracerFieldDict {
|
||||
|
||||
String keyCode() default "";
|
||||
String dictCode();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DataTracerDao extends BaseMapper<DataTracerEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,8 @@ import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.datatracer.annoation.*;
|
||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerConst;
|
||||
import net.lab1024.sa.base.module.support.datatracer.domain.bo.DataTracerContentBO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -39,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2022-07-23 19:38:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -48,7 +49,7 @@ public class DataTracerChangeContentService {
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
private DictService dictService;
|
||||
/**
|
||||
* 字段描述缓存
|
||||
*/
|
||||
@@ -64,7 +65,7 @@ public class DataTracerChangeContentService {
|
||||
*
|
||||
* @param oldObjectList 原始对象列表
|
||||
* @param newObjectList 新的对象列表
|
||||
* @param <T> Class类型
|
||||
* @param <T> Class类型
|
||||
* @return 变更内容
|
||||
*/
|
||||
public <T> String getChangeContent(List<T> oldObjectList, List<T> newObjectList) {
|
||||
@@ -143,7 +144,7 @@ public class DataTracerChangeContentService {
|
||||
/**
|
||||
* 单个对象变动内容
|
||||
*
|
||||
* @param oldObjectList 旧的对象列表
|
||||
* @param oldObjectList 旧的对象列表
|
||||
* @param newObjectList 新的对象列表
|
||||
* @return 拼接后的内容
|
||||
*/
|
||||
@@ -163,7 +164,7 @@ public class DataTracerChangeContentService {
|
||||
* 获取一个对象的内容信息
|
||||
*
|
||||
* @param objectList 对象列表
|
||||
* @param <T> 类型
|
||||
* @param <T> 类型
|
||||
* @return 内容
|
||||
*/
|
||||
private <T> String getObjectListContent(List<T> objectList) {
|
||||
@@ -275,7 +276,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取字段值
|
||||
*
|
||||
*/
|
||||
private DataTracerContentBO getFieldValue(Field field, Object object) {
|
||||
Object fieldValue = "";
|
||||
@@ -303,7 +303,8 @@ public class DataTracerChangeContentService {
|
||||
fieldContent = SmartEnumUtil.getEnumDescByValue(fieldValue, dataTracerFieldEnum.enumClass());
|
||||
}
|
||||
} else if (dataTracerFieldDict != null) {
|
||||
fieldContent = dictCacheService.selectValueNameByValueCodeSplit(dataTracerFieldDict.keyCode(), fieldValue.toString());
|
||||
DictDataVO dictData = dictService.getDictData(dataTracerFieldDict.dictCode(), fieldValue.toString());
|
||||
fieldContent = dictData == null ? fieldValue.toString() : dictData.getDataLabel();
|
||||
} else if (dataTracerFieldSql != null) {
|
||||
fieldContent = this.getRelateDisplayValue(fieldValue, dataTracerFieldSql);
|
||||
} else if (fieldValue instanceof Date) {
|
||||
@@ -330,7 +331,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取关联字段的显示值
|
||||
*
|
||||
*/
|
||||
private String getRelateDisplayValue(Object fieldValue, DataTracerFieldSql dataTracerFieldSql) {
|
||||
Class<? extends BaseMapper> relateMapper = dataTracerFieldSql.relateMapper();
|
||||
@@ -351,7 +351,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取字段描述信息 优先 OperateField 没得话swagger判断
|
||||
*
|
||||
*/
|
||||
private String getFieldDesc(Field field) {
|
||||
// 根据字段名称 从缓存中查询
|
||||
@@ -370,7 +369,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取操作类型
|
||||
*
|
||||
*/
|
||||
private String getOperateType(Object oldObject, Object newObject) {
|
||||
if (oldObject == null && newObject != null) {
|
||||
@@ -384,7 +382,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 校验是否进行比对
|
||||
*
|
||||
*/
|
||||
private boolean valid(Object oldObject, Object newObject) {
|
||||
if (oldObject == null && newObject == null) {
|
||||
@@ -404,7 +401,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 校验
|
||||
*
|
||||
*/
|
||||
private <T> boolean valid(List<T> oldObjectList, List<T> newObjectList) {
|
||||
if (CollectionUtils.isEmpty(oldObjectList) && CollectionUtils.isEmpty(newObjectList)) {
|
||||
@@ -429,7 +425,6 @@ public class DataTracerChangeContentService {
|
||||
/**
|
||||
* 查询 包含 file key 注解的字段
|
||||
* 使用缓存
|
||||
*
|
||||
*/
|
||||
private List<Field> getField(Object obj) {
|
||||
// 从缓存中查询
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictValueQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Tag(name = SwaggerTagConst.Support.DICT)
|
||||
@RestController
|
||||
public class DictController extends SupportBaseController {
|
||||
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
|
||||
|
||||
@Operation(summary = "查询全部字典key - @author 卓大")
|
||||
@GetMapping("/dict/key/queryAll")
|
||||
public ResponseDTO<List<DictKeyVO>> queryAll() {
|
||||
return ResponseDTO.ok(dictService.queryAllKey());
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询数据字典value - @author 罗伊")
|
||||
@PostMapping("/dict/value/query")
|
||||
public ResponseDTO<PageResult<DictValueVO>> valueQuery(@Valid @RequestBody DictValueQueryForm queryForm) {
|
||||
return dictService.valueQuery(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典-值列表- @author 罗伊")
|
||||
@GetMapping("/dict/value/list/{keyCode}")
|
||||
public ResponseDTO<List<DictValueVO>> valueList(@PathVariable String keyCode) {
|
||||
List<DictValueVO> dictValueVOList = dictCacheService.selectByKeyCode(keyCode);
|
||||
return ResponseDTO.ok(dictValueVOList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 数据字典 Dao
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictDao extends BaseMapper<DictEntity> {
|
||||
|
||||
/**
|
||||
* 分页 查询
|
||||
*/
|
||||
List<DictVO> queryPage(Page page, @Param("queryForm") DictQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 根据 dictCode 去查询
|
||||
*/
|
||||
DictEntity selectByCode(@Param("code") String code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据表 Dao
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictDataDao extends BaseMapper<DictDataEntity> {
|
||||
|
||||
List<DictDataVO> queryByDictId(@Param("dictId") Long dictId);
|
||||
|
||||
List<DictDataVO> selectByDictDataIds(@Param("dictDataIdList") Collection<Long> dictDataIds);
|
||||
|
||||
DictDataEntity selectByDictIdAndValue(@Param("dictId") Long dictId, @Param("dataValue") String dataValue);
|
||||
|
||||
List<DictDataVO> getAll();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictKeyQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictKeyDao extends BaseMapper<DictKeyEntity> {
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*/
|
||||
List<DictKeyEntity> selectByDeletedFlag(@Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
*/
|
||||
void updateDeletedFlagByIdList(@Param("dictKeyIdList") List<Long> dictKeyIdList, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
*/
|
||||
List<DictKeyVO> query(Page page, @Param("query") DictKeyQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 跟进code查询
|
||||
*/
|
||||
DictKeyEntity selectByCode(@Param("keyCode")String keyCode, @Param("deletedFlag") Boolean deletedFlag);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictValueQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictValueDao extends BaseMapper<DictValueEntity> {
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*
|
||||
*/
|
||||
List<DictValueEntity> selectByDeletedFlag(@Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*
|
||||
*/
|
||||
List<DictValueEntity> selectByDeletedFlagAndKeyId(@Param("dictKeyId") Long dictKeyId, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
*/
|
||||
void updateDeletedFlagByIdList(@Param("dictValueIdList") List<Long> dictValueIdList, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
*/
|
||||
List<DictValueVO> query(Page page, @Param("query") DictValueQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 跟进code查询
|
||||
*
|
||||
*/
|
||||
DictValueEntity selectByCode(@Param("dictKeyId") Long dictKeyId,@Param("valueCode") String valueCode, @Param("deletedFlag") Boolean deletedFlag);
|
||||
}
|
||||
@@ -8,43 +8,52 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* 字典数据表 实体类
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("t_dict_value")
|
||||
public class DictValueEntity {
|
||||
@TableName("t_dict_data")
|
||||
public class DictDataEntity {
|
||||
|
||||
/**
|
||||
* 字典数据id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long dictValueId;
|
||||
private Long dictDataId;
|
||||
|
||||
private Long dictKeyId;
|
||||
/**
|
||||
* 编码
|
||||
* 字典id
|
||||
*/
|
||||
private String valueCode;
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
* 字典项值
|
||||
*/
|
||||
private String valueName;
|
||||
private String dataValue;
|
||||
|
||||
/**
|
||||
* 字典项显示名称
|
||||
*/
|
||||
private String dataLabel;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
* 排序(越大越靠前)
|
||||
*/
|
||||
private Integer sort;
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
* 禁用状态
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
private Boolean disabledFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
@@ -55,4 +64,5 @@ public class DictValueEntity {
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,39 +8,42 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* 数据字典 实体类
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("t_dict_key")
|
||||
public class DictKeyEntity {
|
||||
@TableName("t_dict")
|
||||
public class DictEntity {
|
||||
|
||||
/**
|
||||
* 字典id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long dictKeyId;
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
* 字典名字
|
||||
*/
|
||||
private String keyCode;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String keyName;
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* 字典编码
|
||||
*/
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
* 禁用状态
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
private Boolean disabledFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
@@ -51,4 +54,5 @@ public class DictKeyEntity {
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 新建表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictAddForm {
|
||||
|
||||
@Schema(description = "字典名字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典名字 不能为空")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典数据表 新建表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataAddForm {
|
||||
|
||||
@Schema(description = "字典id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典id 不能为空")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典项值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典项值 不能为空")
|
||||
private String dataValue;
|
||||
|
||||
@Schema(description = "字典项显示名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典项显示名称 不能为空")
|
||||
private String dataLabel;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序(越大越靠前)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序(越大越靠前) 不能为空")
|
||||
private Integer sortOrder;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典数据表 更新表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataUpdateForm extends DictDataAddForm {
|
||||
|
||||
@Schema(description = "字典数据id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典数据id 不能为空")
|
||||
private Long dictDataId;
|
||||
|
||||
@Schema(description = "字典数据编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典数据编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyAddForm {
|
||||
|
||||
@Schema(description = "编码")
|
||||
@NotBlank(message = "编码不能为空")
|
||||
@Length(max = 50,message = "编码太长了,不能超过50字符")
|
||||
private String keyCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Length(max = 50,message = "名称太长了,不能超过50字符")
|
||||
private String keyName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 500,message = "备注太长了")
|
||||
private String remark;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "搜索词")
|
||||
private String searchWord;
|
||||
|
||||
@Schema(description = "删除标识",hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyUpdateForm extends DictKeyAddForm {
|
||||
|
||||
@Schema(description = "keyId")
|
||||
@NotNull(message = "keyId不能为空")
|
||||
private Long dictKeyId;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 数据字典 分页查询表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DictQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "关键字")
|
||||
private String keywords;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 更新表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictUpdateForm {
|
||||
|
||||
@Schema(description = "字典id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典id 不能为空")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典名字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典名字 不能为空")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueAddForm {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
@NotNull(message = "dictKeyId不能为空")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
@NotBlank(message = "编码不能为空")
|
||||
@Length(max = 50,message = "编码太长了,不能超过50字符")
|
||||
private String valueCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Length(max = 50,message = "名称太长了,不能超过50字符")
|
||||
private String valueName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 500,message = "备注太长了")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
@NotNull(message = "dictKeyId不能为空")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "搜索词")
|
||||
private String searchWord;
|
||||
|
||||
@Schema(description = "删除标识",hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueUpdateForm extends DictValueAddForm {
|
||||
|
||||
@Schema(description = "valueId")
|
||||
@NotNull(message = "valueId不能为空")
|
||||
private Long dictValueId;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典数据表 列表VO
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataVO {
|
||||
|
||||
@Schema(description = "字典数据id")
|
||||
private Long dictDataId;
|
||||
|
||||
@Schema(description = "字典id")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典项值")
|
||||
private String dataValue;
|
||||
|
||||
@Schema(description = "字典项显示名称")
|
||||
private String dataLabel;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序(越大越靠前)")
|
||||
private Integer sortOrder;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyVO {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String keyCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String keyName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 列表VO
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictVO {
|
||||
|
||||
@Schema(description = "字典id")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典名字")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Integer disabledFlag;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueVO {
|
||||
|
||||
@Schema(description = "valueId")
|
||||
private Long dictValueId;
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String valueCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String valueName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.lab1024.sa.base.module.support.dict.manager;
|
||||
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.constant.CacheKeyConst;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDataDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 数据字典 缓存
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class DictManager {
|
||||
|
||||
@Resource
|
||||
private DictDao dictDao;
|
||||
|
||||
@Resource
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
@Cacheable(value = CacheKeyConst.Dict.DICT_DATA, key = "#dictCode + '_' + #dataValue")
|
||||
public DictDataVO getDictData(String dictCode, String dataValue) {
|
||||
DictEntity dictEntity = dictDao.selectByCode(dictCode);
|
||||
if (dictEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = dictDataDao.selectByDictIdAndValue(dictEntity.getDictId(), dataValue);
|
||||
return SmartBeanUtil.copy(dictDataEntity, DictDataVO.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictKeyDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictValueDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典缓存 服务
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DictCacheService {
|
||||
|
||||
@Resource
|
||||
private DictKeyDao dictKeyDao;
|
||||
@Resource
|
||||
private DictValueDao dictValueDao;
|
||||
|
||||
private ConcurrentHashMap<String, List<DictValueVO>> DICT_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void dictCache() {
|
||||
this.cacheInit();
|
||||
}
|
||||
|
||||
public void cacheInit() {
|
||||
List<DictKeyEntity> dictKeyEntityList = dictKeyDao.selectByDeletedFlag(false);
|
||||
if (CollectionUtils.isEmpty(dictKeyEntityList)) {
|
||||
return;
|
||||
}
|
||||
List<DictValueEntity> dictKeyValueList = dictValueDao.selectByDeletedFlag(false);
|
||||
List<DictValueVO> dictValueVOList = SmartBeanUtil.copyList(dictKeyValueList, DictValueVO.class);
|
||||
Map<Long, List<DictValueVO>> valueListMap = dictValueVOList.stream().collect(Collectors.groupingBy(DictValueVO::getDictKeyId));
|
||||
//字典键值对缓存
|
||||
for (DictKeyEntity dictKeyEntity : dictKeyEntityList) {
|
||||
String keyCode = dictKeyEntity.getKeyCode();
|
||||
Long dictKeyId = dictKeyEntity.getDictKeyId();
|
||||
DICT_CACHE.put(keyCode, valueListMap.getOrDefault(dictKeyId, Lists.newArrayList()));
|
||||
}
|
||||
log.info("################# 数据字典缓存初始化完毕 ###################");
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缓存
|
||||
*/
|
||||
public ResponseDTO<String> cacheRefresh() {
|
||||
DICT_CACHE.clear();
|
||||
this.cacheInit();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个key对应的字典值列表
|
||||
*
|
||||
* @param keyCode
|
||||
* @return
|
||||
*/
|
||||
public List<DictValueVO> selectByKeyCode(String keyCode) {
|
||||
return DICT_CACHE.getOrDefault(keyCode, Lists.newArrayList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询值code名称
|
||||
* @param keyCode
|
||||
* @param valueCode
|
||||
* @return
|
||||
*/
|
||||
public String selectValueNameByValueCode(String keyCode, String valueCode) {
|
||||
DictValueVO dictValueVO = this.selectValueByValueCode(keyCode, valueCode);
|
||||
if (dictValueVO == null){
|
||||
return "";
|
||||
}
|
||||
return dictValueVO.getValueName()
|
||||
;
|
||||
}
|
||||
|
||||
public DictValueVO selectValueByValueCode(String keyCode, String valueCode) {
|
||||
if (StrUtil.isEmpty(valueCode)) {
|
||||
return null;
|
||||
}
|
||||
if (StrUtil.isEmpty(keyCode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DictValueVO> dictValueVOList = DICT_CACHE.get(valueCode);
|
||||
if (CollectionUtils.isEmpty(dictValueVOList)) {
|
||||
return null;
|
||||
}
|
||||
Optional<DictValueVO> option = dictValueVOList.stream().filter(e->e.getValueCode().equals(valueCode)).findFirst();
|
||||
if(option.isPresent()){
|
||||
return option.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String selectValueNameByValueCodeSplit(String keyCode, String valueCodes) {
|
||||
if (StrUtil.isEmpty(valueCodes)) {
|
||||
return "";
|
||||
}
|
||||
List<String> valueNameList = Lists.newArrayList();
|
||||
String[] valueCodeArray = valueCodes.split(",");
|
||||
for (String valueCode : valueCodeArray) {
|
||||
DictValueVO dictValueVO = this.selectValueByValueCode(keyCode, valueCode);
|
||||
if (dictValueVO != null) {
|
||||
valueNameList.add(dictValueVO.getValueName());
|
||||
}
|
||||
}
|
||||
return StringUtils.join(valueNameList, ",");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,197 +1,275 @@
|
||||
package net.lab1024.sa.base.module.support.dict.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Interner;
|
||||
import com.google.common.collect.Interners;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictKeyDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictValueDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.constant.CacheKeyConst;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDataDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.*;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import net.lab1024.sa.base.module.support.dict.manager.DictManager;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典 服务
|
||||
* 数据字典 Service
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class DictService {
|
||||
|
||||
@Resource
|
||||
private DictKeyDao dictKeyDao;
|
||||
private DictDao dictDao;
|
||||
|
||||
@Resource
|
||||
private DictValueDao dictValueDao;
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
/**
|
||||
* CODE锁
|
||||
*/
|
||||
private static final Interner<String> CODE_POOL = Interners.newWeakInterner();
|
||||
private CacheManager cacheManager;
|
||||
|
||||
@Resource
|
||||
private DictManager dictManager;
|
||||
|
||||
/**
|
||||
* key添加
|
||||
*
|
||||
* @param keyAddForm
|
||||
* @return
|
||||
* 获取全部数据
|
||||
*/
|
||||
public ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
||||
synchronized (CODE_POOL.intern(keyAddForm.getKeyCode())) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
||||
if (dictKeyEntity != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
}
|
||||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
||||
dictKeyDao.insert(dictKeyEntity);
|
||||
public List<DictDataVO> getAll() {
|
||||
return dictDataDao.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有字典
|
||||
*/
|
||||
public List<DictVO> getAllDict() {
|
||||
List<DictEntity> dictEntityList = dictDao.selectList(null).stream().filter(e -> !e.getDisabledFlag()).collect(Collectors.toList());
|
||||
return SmartBeanUtil.copyList(dictEntityList, DictVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageResult<DictVO> queryPage(DictQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictVO> list = dictDao.queryPage(page, queryForm);
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public synchronized ResponseDTO<String> add(DictAddForm addForm) {
|
||||
DictEntity existDictCode = dictDao.selectByCode(addForm.getDictCode());
|
||||
if (null != existDictCode) {
|
||||
return ResponseDTO.userErrorParam("数据字典编码已经存在!");
|
||||
}
|
||||
|
||||
DictEntity dictEntity = SmartBeanUtil.copy(addForm, DictEntity.class);
|
||||
dictDao.insert(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值添加
|
||||
*
|
||||
* @param valueAddForm
|
||||
* @return
|
||||
* 禁用 启用
|
||||
*/
|
||||
public ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
||||
|
||||
synchronized (CODE_POOL.intern(valueAddForm.getValueCode())) {
|
||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getDictKeyId(),valueAddForm.getValueCode(), false);
|
||||
if (dictValueEntity != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
}
|
||||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
||||
dictValueDao.insert(dictValueEntity);
|
||||
public ResponseDTO<String> updateDisabled(Long dictId) {
|
||||
DictEntity dictEntity = dictDao.selectById(dictId);
|
||||
if (dictEntity == null) {
|
||||
return ResponseDTO.userErrorParam("数据不存在");
|
||||
}
|
||||
|
||||
dictEntity.setDisabledFlag(!dictEntity.getDisabledFlag());
|
||||
dictDao.updateById(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* key 编辑
|
||||
*
|
||||
* @param keyUpdateForm
|
||||
* @return
|
||||
* 更新
|
||||
*/
|
||||
public ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
||||
synchronized (CODE_POOL.intern(keyUpdateForm.getKeyCode())) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
||||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
}
|
||||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
||||
dictKeyDao.updateById(dictKeyUpdateEntity);
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> update(DictUpdateForm updateForm) {
|
||||
DictEntity existDictCode = dictDao.selectByCode(updateForm.getDictCode());
|
||||
if (null != existDictCode && !existDictCode.getDictId().equals(updateForm.getDictId())) {
|
||||
return ResponseDTO.userErrorParam("数据字典编码已经存在!");
|
||||
}
|
||||
|
||||
DictEntity dictEntity = SmartBeanUtil.copy(updateForm, DictEntity.class);
|
||||
dictDao.updateById(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值编辑
|
||||
*
|
||||
* @param valueUpdateForm
|
||||
* @return
|
||||
* 批量删除
|
||||
*/
|
||||
public ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
||||
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
||||
return ResponseDTO.userErrorParam("key不能存在");
|
||||
}
|
||||
synchronized (CODE_POOL.intern(valueUpdateForm.getValueCode())) {
|
||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getDictKeyId() ,valueUpdateForm.getValueCode(), false);
|
||||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
}
|
||||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
||||
dictValueDao.updateById(dictValueUpdateEntity);
|
||||
}
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* key删除
|
||||
*
|
||||
* @param keyIdList
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||
if (CollectionUtils.isEmpty(keyIdList)) {
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
||||
|
||||
dictDao.deleteBatchIds(idList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值删除
|
||||
*
|
||||
* @param valueIdList
|
||||
* @return
|
||||
* 单个删除
|
||||
*/
|
||||
public ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> delete(Long dictId) {
|
||||
if (null == dictId) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
||||
|
||||
dictDao.deleteById(dictId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
// -------------- 字典数据 --------------------
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public List<DictDataVO> queryDictData(Long dictId) {
|
||||
return dictDataDao.queryByDictId(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
|
||||
public DictDataVO getDictData(String dictCode, String dataValue) {
|
||||
return dictManager.getDictData(dictCode, dataValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典Label
|
||||
*/
|
||||
public String getDictDataLabel(String dictCode, String dataValue) {
|
||||
DictDataVO dictData = getDictData(dictCode, dataValue);
|
||||
return dictData == null ? "" : dictData.getDataLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public synchronized ResponseDTO<String> addDictData(DictDataAddForm addForm) {
|
||||
|
||||
addForm.setDataValue(SmartStringUtil.trim(addForm.getDataValue()));
|
||||
|
||||
DictEntity dictEntity = dictDao.selectById(addForm.getDictId());
|
||||
if (null == dictEntity) {
|
||||
return ResponseDTO.userErrorParam("数据字典不存在");
|
||||
}
|
||||
|
||||
DictDataEntity existData = dictDataDao.selectByDictIdAndValue(addForm.getDictId(), addForm.getDataValue());
|
||||
if (null != existData) {
|
||||
return ResponseDTO.userErrorParam("已存在相同value的数据");
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = SmartBeanUtil.copy(addForm, DictDataEntity.class);
|
||||
dictDataDao.insert(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询key
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
* 更新
|
||||
*/
|
||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(DictKeyQueryForm queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictKeyVO> list = dictKeyDao.query(page, queryForm);
|
||||
PageResult<DictKeyVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
@CacheEvict(value = CacheKeyConst.Dict.DICT_DATA, key = "#updateForm.dictCode + '_' + #updateForm.dataValue")
|
||||
public synchronized ResponseDTO<String> updateDictData(DictDataUpdateForm updateForm) {
|
||||
|
||||
updateForm.setDataValue(SmartStringUtil.trim(updateForm.getDataValue()));
|
||||
|
||||
DictEntity dictEntity = dictDao.selectById(updateForm.getDictId());
|
||||
if (null == dictEntity) {
|
||||
return ResponseDTO.userErrorParam("数据字典不存在");
|
||||
}
|
||||
return ResponseDTO.ok(pageResult);
|
||||
|
||||
DictDataEntity existData = dictDataDao.selectByDictIdAndValue(updateForm.getDictId(), updateForm.getDataValue());
|
||||
if (null != existData && !existData.getDictDataId().equals(updateForm.getDictDataId())) {
|
||||
return ResponseDTO.userErrorParam("已存在相同value的数据");
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = SmartBeanUtil.copy(updateForm, DictDataEntity.class);
|
||||
dictDataDao.updateById(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有key
|
||||
*
|
||||
* @return
|
||||
* 批量删除
|
||||
*/
|
||||
public List<DictKeyVO> queryAllKey() {
|
||||
return SmartBeanUtil.copyList(dictKeyDao.selectByDeletedFlag(false), DictKeyVO.class);
|
||||
public synchronized ResponseDTO<String> batchDeleteDictData(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
// 清除缓存
|
||||
clearDictDataCache(idList);
|
||||
// 删除
|
||||
dictDataDao.deleteBatchIds(idList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询值
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
* 单个删除
|
||||
*/
|
||||
public ResponseDTO<PageResult<DictValueVO>> valueQuery(DictValueQueryForm queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictValueVO> list = dictValueDao.query(page, queryForm);
|
||||
PageResult<DictValueVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
public synchronized ResponseDTO<String> deleteDictData(Long dictDataId) {
|
||||
if (null == dictDataId) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
return ResponseDTO.ok(pageResult);
|
||||
// 清除缓存
|
||||
clearDictDataCache(Collections.singletonList(dictDataId));
|
||||
// 删除
|
||||
dictDataDao.deleteById(dictDataId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 清空字典数据缓存
|
||||
*/
|
||||
private void clearDictDataCache(List<Long> idList) {
|
||||
List<DictDataVO> dictDataList = dictDataDao.selectByDictDataIds(idList);
|
||||
Cache cache = cacheManager.getCache(CacheKeyConst.Dict.DICT_DATA);
|
||||
if (cache == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (DictDataVO dictDataVO : dictDataList) {
|
||||
cache.evict(dictDataVO.getDictCode() + "_" + dictDataVO.getDataValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新启用/禁用
|
||||
*/
|
||||
public synchronized ResponseDTO<String> updateDictDataDisabled(Long dictDataId) {
|
||||
DictDataEntity dictDataEntity = dictDataDao.selectById(dictDataId);
|
||||
if (dictDataEntity == null) {
|
||||
return ResponseDTO.userErrorParam("数据不存在");
|
||||
}
|
||||
|
||||
dictDataEntity.setDisabledFlag(!dictDataEntity.getDisabledFlag());
|
||||
dictDataDao.updateById(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FeedbackDao extends BaseMapper<FeedbackEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FileDao extends BaseMapper<FileEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface HeartBeatRecordDao extends BaseMapper<HeartBeatRecordEntity> {
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface HelpDocCatalogDao extends BaseMapper<HelpDocCatalogEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface HelpDocDao extends BaseMapper<HelpDocEntity> {
|
||||
|
||||
// ================================= 帮助文档【主表 t_help_doc 】 =================================
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @date 2024/6/17 21:30
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @date 2024/6/17 21:30
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SmartJobLogDao extends BaseMapper<SmartJobLogEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface LoginLogDao extends BaseMapper<LoginLogEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,6 +60,11 @@ public class LoginLogEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 登录设备
|
||||
*/
|
||||
private String loginDevice;
|
||||
|
||||
/**
|
||||
* 登录类型
|
||||
*/
|
||||
|
||||
@@ -46,6 +46,8 @@ public class LoginLogVO {
|
||||
@SchemaEnum(LoginLogResultEnum.class)
|
||||
private Integer loginResult;
|
||||
|
||||
private String loginDevice;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface MailTemplateDao extends BaseMapper<MailTemplateEntity> {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.List;
|
||||
* @author luoyi
|
||||
* @date 2024/06/22 20:20
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface MessageDao extends BaseMapper<MessageEntity> {
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface OperateLogDao extends BaseMapper<OperateLogEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface ReloadItemDao extends BaseMapper<ReloadItemEntity> {
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface ReloadResultDao extends BaseMapper<ReloadResultEntity> {
|
||||
|
||||
|
||||
@@ -22,18 +22,16 @@ import java.lang.reflect.Method;
|
||||
* @Date 2020-11-25 20:56:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class RepeatSubmitAspect {
|
||||
|
||||
private AbstractRepeatSubmitTicket repeatSubmitTicket;
|
||||
private final AbstractRepeatSubmitTicket repeatSubmitTicket;
|
||||
|
||||
/**
|
||||
* 获取凭证信息
|
||||
*
|
||||
* @param repeatSubmitTicket
|
||||
*/
|
||||
public RepeatSubmitAspect(AbstractRepeatSubmitTicket repeatSubmitTicket) {
|
||||
this.repeatSubmitTicket = repeatSubmitTicket;
|
||||
@@ -41,10 +39,6 @@ public class RepeatSubmitAspect {
|
||||
|
||||
/**
|
||||
* 定义切入点
|
||||
*
|
||||
* @param point
|
||||
* @return
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Around("@annotation(net.lab1024.sa.base.module.support.repeatsubmit.annoation.RepeatSubmit)")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
@@ -55,20 +49,24 @@ public class RepeatSubmitAspect {
|
||||
if (StringUtils.isEmpty(ticket)) {
|
||||
return point.proceed();
|
||||
}
|
||||
|
||||
Method method = ((MethodSignature) point.getSignature()).getMethod();
|
||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||
int limit = annotation.value();
|
||||
|
||||
// 获取上一次请求时间
|
||||
Long lastRequestTime = this.repeatSubmitTicket.getTicketTimestamp(ticket);
|
||||
if (lastRequestTime != null) {
|
||||
Method method = ((MethodSignature) point.getSignature()).getMethod();
|
||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||
int interval = Math.min(annotation.value(), RepeatSubmit.MAX_INTERVAL);
|
||||
if (System.currentTimeMillis() < lastRequestTime + interval) {
|
||||
// 提交频繁
|
||||
return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT);
|
||||
}
|
||||
// 校验是否限制时间内重复提交
|
||||
if (lastRequestTime != null && System.currentTimeMillis() < lastRequestTime + limit) {
|
||||
return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT);
|
||||
}
|
||||
|
||||
// 执行
|
||||
Object obj = null;
|
||||
try {
|
||||
// 先给 ticket 设置在执行中
|
||||
// 给 ticket 设置在执行中
|
||||
this.repeatSubmitTicket.putTicket(ticket);
|
||||
// 执行
|
||||
obj = point.proceed();
|
||||
} catch (Throwable throwable) {
|
||||
log.error("", throwable);
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.lang.annotation.Target;
|
||||
* @Date 2020-11-25 20:56:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
@@ -21,13 +21,7 @@ public @interface RepeatSubmit {
|
||||
|
||||
/**
|
||||
* 重复提交间隔时间/毫秒
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int value() default 300;
|
||||
|
||||
/**
|
||||
* 最长间隔30s
|
||||
*/
|
||||
int MAX_INTERVAL = 30000;
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ import java.util.function.Function;
|
||||
* @Date 2020-11-25 20:56:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public abstract class AbstractRepeatSubmitTicket {
|
||||
|
||||
private Function<String, String> ticketFunction;
|
||||
private final Function<String, String> ticketFunction;
|
||||
|
||||
|
||||
public AbstractRepeatSubmitTicket(Function<String, String> ticketFunction) {
|
||||
@@ -23,9 +23,6 @@ public abstract class AbstractRepeatSubmitTicket {
|
||||
|
||||
/**
|
||||
* 获取凭证
|
||||
*
|
||||
* @param ticketToken
|
||||
* @return
|
||||
*/
|
||||
public String getTicket(String ticketToken) {
|
||||
return this.ticketFunction.apply(ticketToken);
|
||||
@@ -33,24 +30,13 @@ public abstract class AbstractRepeatSubmitTicket {
|
||||
|
||||
/**
|
||||
* 获取凭证 时间戳
|
||||
*
|
||||
* @param ticket
|
||||
* @return
|
||||
*/
|
||||
public abstract Long getTicketTimestamp(String ticket);
|
||||
|
||||
|
||||
/**
|
||||
* 设置本次请求时间
|
||||
*
|
||||
* @param ticket
|
||||
*/
|
||||
public abstract void putTicket(String ticket);
|
||||
|
||||
/**
|
||||
* 移除凭证
|
||||
*
|
||||
* @param ticket
|
||||
*/
|
||||
public abstract void removeTicket(String ticket);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.lab1024.sa.base.module.support.repeatsubmit.ticket;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.annoation.RepeatSubmit;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
@@ -14,7 +13,7 @@ import java.util.function.Function;
|
||||
* @Date 2020-11-25 20:56:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class RepeatSubmitCaffeineTicket extends AbstractRepeatSubmitTicket {
|
||||
|
||||
@@ -23,9 +22,9 @@ public class RepeatSubmitCaffeineTicket extends AbstractRepeatSubmitTicket {
|
||||
* 默认缓存时间
|
||||
* 初始大小为:100万
|
||||
*/
|
||||
private static Cache<String, Long> cache = Caffeine.newBuilder()
|
||||
private static final Cache<String, Long> cache = Caffeine.newBuilder()
|
||||
.maximumSize(100 * 10000)
|
||||
.expireAfterWrite(RepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS).build();
|
||||
.expireAfterWrite(300 * 1000L, TimeUnit.MILLISECONDS).build();
|
||||
|
||||
|
||||
public RepeatSubmitCaffeineTicket(Function<String, String> ticketFunction) {
|
||||
@@ -42,9 +41,4 @@ public class RepeatSubmitCaffeineTicket extends AbstractRepeatSubmitTicket {
|
||||
public void putTicket(String ticket) {
|
||||
cache.put(ticket, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTicket(String ticket) {
|
||||
cache.invalidate(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package net.lab1024.sa.base.module.support.repeatsubmit.ticket;
|
||||
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.annoation.RepeatSubmit;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
@@ -13,11 +11,11 @@ import java.util.function.Function;
|
||||
* @Date 2020-11-25 20:56:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
||||
|
||||
private ValueOperations<String, String> redisValueOperations;
|
||||
private final ValueOperations<String, String> redisValueOperations;
|
||||
|
||||
public RepeatSubmitRedisTicket(ValueOperations<String, String> redisValueOperations,
|
||||
Function<String, String> ticketFunction) {
|
||||
@@ -27,12 +25,8 @@ public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
||||
|
||||
@Override
|
||||
public Long getTicketTimestamp(String ticket) {
|
||||
Long timeStamp = System.currentTimeMillis();
|
||||
boolean setFlag = redisValueOperations.setIfAbsent(ticket, String.valueOf(timeStamp), RepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS);
|
||||
if (!setFlag) {
|
||||
timeStamp = Long.valueOf(redisValueOperations.get(ticket));
|
||||
}
|
||||
return timeStamp;
|
||||
String ticketLastTime = redisValueOperations.get(ticket);
|
||||
return ticketLastTime == null ? null : Long.valueOf(ticketLastTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,8 +35,4 @@ public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
||||
this.getTicketTimestamp(ticket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTicket(String ticket) {
|
||||
redisValueOperations.getOperations().delete(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface LoginFailDao extends BaseMapper<LoginFailEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface PasswordLogDao extends BaseMapper<PasswordLogEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.time.LocalDateTime;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SerialNumberDao extends BaseMapper<SerialNumberEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SerialNumberRecordDao extends BaseMapper<SerialNumberRecordEntity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface ${name.upperCamel}Dao extends BaseMapper<${name.upperCamel}Entity> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ${name.upperCamel}VO {
|
||||
|
||||
#foreach ($field in $fields)
|
||||
|
||||
${field.apiModelProperty}$!{field.notEmpty}$!{field.dict}$!{field.file}
|
||||
${field.apiModelProperty}$!{field.notEmpty}$!{field.file}
|
||||
private $field.javaType $field.fieldName;
|
||||
#end
|
||||
|
||||
|
||||
@@ -29,15 +29,11 @@ public class ${name.upperCamel}Service {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
*/
|
||||
public PageResult<${name.upperCamel}VO> queryPage(${name.upperCamel}QueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<${name.upperCamel}VO> list = ${name.lowerCamel}Dao.queryPage(page, queryForm);
|
||||
PageResult<${name.upperCamel}VO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
return pageResult;
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
#if($insertAndUpdate.isSupportInsertAndUpdate)
|
||||
@@ -53,8 +49,6 @@ public class ${name.upperCamel}Service {
|
||||
/**
|
||||
* 更新
|
||||
*
|
||||
* @param updateForm
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> update(${name.upperCamel}UpdateForm updateForm) {
|
||||
${name.upperCamel}Entity ${name.lowerCamel}Entity = SmartBeanUtil.copy(updateForm, ${name.upperCamel}Entity.class);
|
||||
@@ -67,9 +61,6 @@ public class ${name.upperCamel}Service {
|
||||
#if($deleteInfo.deleteEnum == "Batch" || $deleteInfo.deleteEnum == "SingleAndBatch")
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
public ResponseDTO<String> batchDelete(List<${primaryKeyJavaType}> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)){
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" dictCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
@@ -106,7 +106,7 @@
|
||||
#end
|
||||
#if($field.frontComponent == "DictSelect")
|
||||
<a-form-item label="$codeGeneratorTool.removeEnumDesc($!{field.label})" name="${field.fieldName}">
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" keyCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
<DictSelect width="100%" v-model:value="form.${field.fieldName}" dictCode="$!{field.dict}" placeholder="$!{field.label}"/>
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.frontComponent == "Date")
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#end
|
||||
#if($field.queryTypeEnum == "Dict")
|
||||
<a-form-item label="${field.label}" class="smart-query-form-item">
|
||||
<DictSelect keyCode="$!{field.dict}" placeholder="${field.label}" v-model:value="queryForm.${field.fieldName}" width="${field.width}" />
|
||||
<DictSelect dictCode="$!{field.dict}" placeholder="${field.label}" v-model:value="queryForm.${field.fieldName}" width="${field.width}" />
|
||||
</a-form-item>
|
||||
#end
|
||||
#if($field.queryTypeEnum == "Enum")
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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="net.lab1024.sa.base.module.support.dict.dao.DictDataDao">
|
||||
|
||||
|
||||
<select id="queryByDictId" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO">
|
||||
select *
|
||||
from t_dict_data
|
||||
where dict_id = #{dictId}
|
||||
order by sort_order desc
|
||||
</select>
|
||||
|
||||
<select id="getAll" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO">
|
||||
select t_dict_data.*,
|
||||
t_dict.dict_code
|
||||
from t_dict_data
|
||||
left join t_dict on t_dict_data.dict_id = t_dict.dict_id
|
||||
order by t_dict_data.sort_order desc
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectByDictIdAndValue"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity">
|
||||
select *
|
||||
from t_dict_data
|
||||
where dict_id = #{dictId}
|
||||
and data_value = #{dataValue}
|
||||
</select>
|
||||
|
||||
<select id="selectByDictDataIds" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO">
|
||||
select
|
||||
t_dict_data.*,
|
||||
t_dict.dict_code
|
||||
from t_dict_data
|
||||
left join t_dict on t_dict_data.dict_id = t_dict.dict_id
|
||||
<where>
|
||||
<if test="dictDataIdList != null and dictDataIdList.size > 0">
|
||||
and t_dict_data.dict_data_id in
|
||||
<foreach collection="dictDataIdList" open="(" close=")" item="item" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,37 +0,0 @@
|
||||
<?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="net.lab1024.sa.base.module.support.dict.dao.DictKeyDao">
|
||||
|
||||
<update id="updateDeletedFlagByIdList">
|
||||
update t_dict_key set deleted_flag = #{deletedFlag} where dict_key_id in
|
||||
<foreach collection="dictKeyIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="query" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO">
|
||||
SELECT * FROM t_dict_key
|
||||
<where>
|
||||
<if test="query.searchWord != null and query.searchWord !=''">
|
||||
AND (INSTR(key_code,#{query.searchWord}) or INSTR(key_name,#{query.searchWord}))
|
||||
</if>
|
||||
<if test="query.deletedFlag != null">
|
||||
AND deleted_flag = #{query.deletedFlag}
|
||||
</if>
|
||||
</where>
|
||||
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
||||
ORDER BY dict_key_id DESC
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByCode"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity">
|
||||
select * from t_dict_key where key_code = #{keyCode} and deleted_flag = #{deletedFlag}
|
||||
</select>
|
||||
|
||||
<select id="selectByDeletedFlag"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity">
|
||||
select * from t_dict_key where deleted_flag = #{deletedFlag}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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="net.lab1024.sa.base.module.support.dict.dao.DictDao">
|
||||
|
||||
<!-- 查询结果列 -->
|
||||
<sql id="base_columns">
|
||||
t_dict.dict_id,
|
||||
t_dict.dict_name,
|
||||
t_dict.dict_code,
|
||||
t_dict.remark,
|
||||
t_dict.disabled_flag,
|
||||
t_dict.create_time,
|
||||
t_dict.update_time
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="queryPage" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictVO">
|
||||
SELECT
|
||||
<include refid="base_columns"/>
|
||||
FROM t_dict
|
||||
<where>
|
||||
<!--关键字-->
|
||||
<if test="queryForm.keywords != null and queryForm.keywords != ''">
|
||||
AND (
|
||||
INSTR(t_dict.dict_name,#{queryForm.keywords})
|
||||
OR INSTR(t_dict.dict_code,#{queryForm.keywords})
|
||||
OR INSTR(t_dict.remark,#{queryForm.keywords})
|
||||
)
|
||||
</if>
|
||||
<!--禁用状态-->
|
||||
<if test="queryForm.disabledFlag != null">
|
||||
AND t_dict.disabled_flag = #{queryForm.disabledFlag}
|
||||
</if>
|
||||
</where>
|
||||
<if test="queryForm.sortItemList == null or queryForm.sortItemList.size == 0">
|
||||
order by create_time desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByCode" resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity">
|
||||
select * from t_dict where dict_code = #{code}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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="net.lab1024.sa.base.module.support.dict.dao.DictValueDao">
|
||||
|
||||
<update id="updateDeletedFlagByIdList">
|
||||
update t_dict_value set deleted_flag = #{deletedFlag} where dict_value_id in
|
||||
<foreach collection="dictValueIdList" open="(" close=")" separator="," item="item">
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="query" resultType="net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO">
|
||||
SELECT * FROM t_dict_value
|
||||
<where>
|
||||
<if test="query.dictKeyId != null">
|
||||
AND dict_key_id = #{query.dictKeyId}
|
||||
</if>
|
||||
<if test="query.searchWord != null and query.searchWord !=''">
|
||||
AND (INSTR(value_code,#{query.searchWord}) or INSTR(value_name,#{query.searchWord}))
|
||||
</if>
|
||||
<if test="query.deletedFlag != null">
|
||||
AND deleted_flag = #{query.deletedFlag}
|
||||
</if>
|
||||
</where>
|
||||
<if test="query.sortItemList == null or query.sortItemList.size == 0">
|
||||
ORDER BY sort,dict_value_id DESC
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectByCode"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity">
|
||||
select * from t_dict_value where dict_Key_id = #{dictKeyId} and value_code = #{valueCode} and deleted_flag = #{deletedFlag}
|
||||
</select>
|
||||
|
||||
<select id="selectByDeletedFlag"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity">
|
||||
select * from t_dict_value where deleted_flag = #{deletedFlag} order by sort;
|
||||
</select>
|
||||
<select id="selectByDeletedFlagAndKeyId"
|
||||
resultType="net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity">
|
||||
select * from t_dict_value where dict_key_id = #{dictKeyId} and deleted_flag = #{deletedFlag}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -9,7 +9,7 @@
|
||||
<if test="query.searchWord != null and query.searchWord != '' ">
|
||||
AND (
|
||||
INSTR(feedback_content,#{query.searchWord})
|
||||
OR INSTR(create_name,#{query.searchWord})
|
||||
OR INSTR(user_name,#{query.searchWord})
|
||||
)
|
||||
</if>
|
||||
<if test="query.startDate != null">
|
||||
|
||||
@@ -38,7 +38,7 @@ spring:
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: lab1024@163.com
|
||||
password: 1024lab
|
||||
password: LAB1024LAB
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
@@ -99,12 +99,13 @@ springdoc:
|
||||
enabled: true # 开关
|
||||
doc-expansion: none #关闭展开
|
||||
tags-sorter: alpha
|
||||
server-base-url: https://preview.smartadmin.vip/smart-admin-api
|
||||
api-docs:
|
||||
enabled: true # 开关
|
||||
knife4j:
|
||||
enable: true
|
||||
basic:
|
||||
enable: true
|
||||
enable: false
|
||||
username: api # Basic认证用户名
|
||||
password: 1024 # Basic认证密码
|
||||
|
||||
|
||||
Reference in New Issue
Block a user