refactor: 版本号由PAR审核通过时自动分配
- submitConfig: 不再比较版本号,相同hash跳过,不同hash都插入pending - approveConfig: 自动取最大版本号+1 分配(如 1, 2, 3...) - 存储路径含hash前缀避免同名冲突
This commit is contained in:
@@ -71,6 +71,19 @@ public class AdminController {
|
||||
|
||||
Long reviewerId = (Long) request.getAttribute("accountId");
|
||||
|
||||
// 自动分配版本号:取该站点已审批的最大版本号 + 1
|
||||
var latestApproved = siteConfigMapper.selectList(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<SiteConfig>()
|
||||
.eq(SiteConfig::getSiteId, config.getSiteId())
|
||||
.eq(SiteConfig::getStatus, ConfigStatus.APPROVED)
|
||||
.orderByDesc(SiteConfig::getVersion));
|
||||
int nextVersion = 1;
|
||||
if (!latestApproved.isEmpty()) {
|
||||
try { nextVersion = Integer.parseInt(latestApproved.get(0).getVersion()) + 1; }
|
||||
catch (NumberFormatException ignored) {}
|
||||
}
|
||||
config.setVersion(String.valueOf(nextVersion));
|
||||
|
||||
config.setStatus(ConfigStatus.APPROVED);
|
||||
config.setReviewerId(reviewerId);
|
||||
config.setReviewedAt(LocalDateTime.now());
|
||||
|
||||
Reference in New Issue
Block a user