feat 同步脚手架代码, 更新数据库脚本和内容

This commit is contained in:
daxpay
2025-05-07 17:58:29 +08:00
parent a9153aa61a
commit 81479301f0
17 changed files with 64 additions and 273 deletions

View File

@@ -13,5 +13,4 @@
<description>项目配置</description>
</project>

View File

@@ -8,7 +8,7 @@ import lombok.Getter;
* 业务异常基类
* @see BizErrorException 致命异常 error级别警告
* @see BizWarnException 业务异常 warn级别
* @see BizInfoException 哦月异常 info级别
* @see BizInfoException 业务异常 info级别
*/
@Getter
public class BizException extends RuntimeException {

View File

@@ -222,7 +222,7 @@ public class PermPathSyncService {
.stream()
.filter(pathKey -> {
HandlerMethod handlerMethod = map.get(pathKey);
return Objects.nonNull(handlerMethod.getMethodAnnotation(cn.bootx.platform.core.annotation.RequestPath.class))
return Objects.nonNull(handlerMethod.getMethodAnnotation(RequestPath.class))
&&Objects.nonNull(handlerMethod.getBeanType().getAnnotation(RequestGroup.class));
}).toList();

View File

@@ -21,13 +21,10 @@ public class AuthProperties {
/** 不进行鉴权的路径 */
private List<String> ignoreUrls = new ArrayList<>();
/** 盐值 */
private String salt = "salt";
/** 开启超级管理员(生产模式推荐关闭) */
/** 开启超级管理员(生产模式请关闭) */
private boolean enableAdmin = true;
/** 用户管理列表中是否显示 */
/** 用户管理列表中是否显示超级管理员用户 */
private boolean adminInList = true;
}

View File

@@ -37,6 +37,7 @@ public class TokenEndpoint {
@Operation(summary = "退出")
@PostMapping("/logout")
public Result<Void> logout() {
tokenService.logout();
return Res.ok();
}

View File

@@ -9,10 +9,7 @@ import cn.bootx.platform.starter.cache.service.CacheClearService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -30,7 +27,6 @@ public class CacheClearController {
private final CacheClearProcessor cacheClearProcessor;
private final CacheClearService cacheClearService;
@RequestPath("查询所有缓存前缀")
@Operation(summary = "查询所有缓存前缀")
@GetMapping("/getCachePrefix")
@@ -41,7 +37,7 @@ public class CacheClearController {
@RequestPath("清除指定前缀的缓存")
@Operation(summary = "清除指定前缀的缓存")
@PostMapping("/prefix")
public Result<Void> clearCacheByPrefix(List<String> prefix) {
public Result<Void> clearCacheByPrefix(@RequestBody List<String> prefix) {
cacheClearService.clearCacheByPrefix(prefix);
return Res.ok();
}

View File

@@ -2,9 +2,12 @@ package cn.bootx.platform.starter.cache.service;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
@@ -22,6 +25,37 @@ public class CacheClearService {
* 根据前缀清除缓存
*/
public void clearCacheByPrefix(List<String> prefixes){
prefixes.forEach(prefix->redisTemplate.delete(redisTemplate.keys(prefix + "*")));
prefixes.forEach(prefix->{
deleteStringKeysWithPrefix(prefix,500);
});
}
/**
* 扫描删除前缀的缓存
*/
private void deleteStringKeysWithPrefix(String prefix, int batchSize) {
ScanOptions options = ScanOptions.scanOptions()
.match(prefix + "*")
.count(batchSize)
.build();
List<String> deleteKeys;
try (Cursor<String> cursor = redisTemplate.scan(options)) {
deleteKeys = new ArrayList<>();
while (cursor.hasNext()) {
deleteKeys.add(cursor.next());
//
if (deleteKeys.size() >= batchSize) {
redisTemplate.delete(deleteKeys);
deleteKeys.clear();
}
}
}
// 删除剩余的 key
if (!deleteKeys.isEmpty()) {
redisTemplate.delete(deleteKeys);
deleteKeys.clear();
}
}
}

View File

@@ -4,19 +4,15 @@ import cn.bootx.platform.core.rest.Res;
import cn.bootx.platform.core.rest.param.PageParam;
import cn.bootx.platform.core.rest.result.PageResult;
import cn.bootx.platform.core.rest.result.Result;
import cn.bootx.platform.starter.quartz.param.QuartzJobParam;
import cn.bootx.platform.starter.quartz.result.QuartzJobResult;
import cn.bootx.platform.starter.quartz.param.QuartzJobParam;
import cn.bootx.platform.starter.quartz.service.QuartzJobService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* 定时任务