Merge remote-tracking branch 'base-version/main' into test
This commit is contained in:
@@ -13,7 +13,6 @@ import com.zt.plat.framework.web.core.util.WebFrameworkUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -28,7 +27,6 @@ import static com.zt.plat.framework.security.core.util.SecurityFrameworkUtils.ge
|
||||
*
|
||||
* @author hexiaowu
|
||||
*/
|
||||
@Component
|
||||
public class DefaultDBFieldHandler implements MetaObjectHandler {
|
||||
|
||||
@Resource
|
||||
|
||||
@@ -263,6 +263,15 @@ public class DocFileController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get-file-token")
|
||||
@Operation(summary = "根据fileId获取文件访问Token")
|
||||
@PreAuthorize("@ss.hasPermission('infra:doc:query')")
|
||||
public CommonResult<String> getFileToken(@RequestParam("fileId") Long fileId) {
|
||||
// 使用service中的公共方法生成文件访问token
|
||||
String fileToken = docFileService.generateFileToken(fileId);
|
||||
return success(fileToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户端真实IP地址
|
||||
*/
|
||||
|
||||
@@ -169,4 +169,12 @@ public interface DocFileService {
|
||||
*/
|
||||
void restoreDocFileToVersion(Long docFileId, Long versionId);
|
||||
|
||||
/**
|
||||
* 生成文件访问Token
|
||||
*
|
||||
* @param fileId 文件编号
|
||||
* @return JWT token
|
||||
*/
|
||||
String generateFileToken(Long fileId);
|
||||
|
||||
}
|
||||
|
||||
@@ -285,17 +285,7 @@ public class DocFileServiceImpl implements DocFileService {
|
||||
respVO.setFileSize(fileInfo.getSize().longValue());
|
||||
|
||||
// 生成文件访问的JWT token
|
||||
String fileToken = "";
|
||||
if (StrUtil.isNotBlank(onlyOfficeJwtSecret)) {
|
||||
// 创建文件访问token,包含fileId和过期时间(1小时后过期)
|
||||
long expTime = System.currentTimeMillis() / 1000 + 3600; // 1小时后过期
|
||||
fileToken = JWT.create()
|
||||
.setPayload("fileId", doc.getFileId())
|
||||
.setPayload("exp", expTime)
|
||||
.setPayload("iat", System.currentTimeMillis() / 1000)
|
||||
.setKey(onlyOfficeJwtSecret.getBytes())
|
||||
.sign();
|
||||
}
|
||||
String fileToken = generateFileToken(doc.getFileId());
|
||||
|
||||
// 使用新的接口生成文件URL,包含JWT token
|
||||
String fileUrl = StrUtil.removeSuffix(onlyOfficeCallbackBaseUrl, "/") + "/admin-api/infra/doc-file/file-content?fileId=" + doc.getFileId();
|
||||
@@ -422,17 +412,7 @@ public class DocFileServiceImpl implements DocFileService {
|
||||
String fileUrl = "";
|
||||
if (doc.getFileId() != null) {
|
||||
// 生成文件访问的JWT token
|
||||
String fileToken = "";
|
||||
if (StrUtil.isNotBlank(onlyOfficeJwtSecret)) {
|
||||
// 创建文件访问token,包含fileId和过期时间(1小时后过期)
|
||||
long expTime = System.currentTimeMillis() / 1000 + 3600; // 1小时后过期
|
||||
fileToken = JWT.create()
|
||||
.setPayload("fileId", doc.getFileId())
|
||||
.setPayload("exp", expTime)
|
||||
.setPayload("iat", System.currentTimeMillis() / 1000)
|
||||
.setKey(onlyOfficeJwtSecret.getBytes())
|
||||
.sign();
|
||||
}
|
||||
String fileToken = generateFileToken(doc.getFileId());
|
||||
|
||||
// 生成通过新接口访问文件的URL,包含JWT token
|
||||
fileUrl = StrUtil.removeSuffix(onlyOfficeCallbackBaseUrl, "/") + "/admin-api/infra/doc-file/file-content?fileId=" + doc.getFileId();
|
||||
@@ -845,5 +825,21 @@ public class DocFileServiceImpl implements DocFileService {
|
||||
log.info("文档版本恢复完成: docId={}, 恢复到版本={}, 新版本={}",
|
||||
docFileId, version.getVersionNo(), newVersionNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateFileToken(Long fileId) {
|
||||
String fileToken = "";
|
||||
if (StrUtil.isNotBlank(onlyOfficeJwtSecret)) {
|
||||
// 创建文件访问token,包含fileId和过期时间(1小时后过期)
|
||||
long expTime = System.currentTimeMillis() / 1000 + 3600; // 1小时后过期
|
||||
fileToken = JWT.create()
|
||||
.setPayload("fileId", fileId)
|
||||
.setPayload("exp", expTime)
|
||||
.setPayload("iat", System.currentTimeMillis() / 1000)
|
||||
.setKey(onlyOfficeJwtSecret.getBytes())
|
||||
.sign();
|
||||
}
|
||||
return fileToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,4 +92,18 @@ public class SyncLogController {
|
||||
return success(count);
|
||||
}
|
||||
|
||||
@PostMapping("/batch-rerun/process")
|
||||
@Operation(summary = "处理批量重跑(处理重试中状态的记录)")
|
||||
@PreAuthorize("@ss.hasPermission('system:sync-log:batch-rerun')")
|
||||
public CommonResult<Integer> processBatchRerun(
|
||||
@RequestParam(value = "batchSize", defaultValue = "50") Integer batchSize) {
|
||||
// 参数校验
|
||||
if (batchSize <= 0 || batchSize > 500) {
|
||||
throw new IllegalArgumentException("批次大小必须在1-500之间");
|
||||
}
|
||||
|
||||
int processedCount = syncLogService.processBatchRerun(batchSize);
|
||||
return success(processedCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.zt.plat.module.system.dal.mysql.sync.SyncLogMapper;
|
||||
import com.zt.plat.module.system.enums.sync.SyncLogStatusEnum;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -426,12 +427,23 @@ public class SyncLogServiceImpl implements SyncLogService {
|
||||
@Override
|
||||
public Map<String, Object> getBatchRerunProgress(String serviceName) {
|
||||
// 统计各状态的记录数量
|
||||
Map<Integer, Long> statusCounts = syncLogMapper.selectList(
|
||||
new LambdaQueryWrapper<SyncLogDO>()
|
||||
.eq(SyncLogDO::getServiceName, serviceName)
|
||||
.groupBy(SyncLogDO::getStatus))
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(SyncLogDO::getStatus, Collectors.counting()));
|
||||
// 使用MyBatis-Plus的聚合查询方式,避免DM8数据库GROUP BY语法问题
|
||||
List<Map<String, Object>> statusCountsList = syncLogMapper.selectMaps(
|
||||
new QueryWrapper<SyncLogDO>()
|
||||
.select("status, COUNT(*) as count")
|
||||
.eq("service_name", serviceName)
|
||||
.groupBy("status"));
|
||||
|
||||
// 转换为Map结构
|
||||
Map<Integer, Long> statusCounts = statusCountsList.stream()
|
||||
.filter(map -> map.get("status") != null && map.get("count") != null)
|
||||
.collect(Collectors.toMap(
|
||||
map -> (Integer) map.get("status"),
|
||||
map -> {
|
||||
Object countObj = map.get("count");
|
||||
return countObj instanceof Number ? ((Number) countObj).longValue() : 0L;
|
||||
}
|
||||
));
|
||||
|
||||
Map<String, Object> progress = new HashMap<>();
|
||||
progress.put("serviceName", serviceName);
|
||||
|
||||
Reference in New Issue
Block a user