模版编制相关实现

This commit is contained in:
潘荣晟
2025-09-26 11:12:36 +08:00
parent 0149b66631
commit 73cc6f6ee3
4 changed files with 7 additions and 4 deletions

View File

@@ -166,7 +166,7 @@ public class TemplateInstanceController extends AbstractFileUploadController {
//根据id获取实例版本号
@GetMapping("/get-version")
@Operation(summary = "根据id获取实例版本号")
public CommonResult<Map<String,Object>> getVersion(@RequestParam("id") String id) {
public CommonResult<Map<String,Object>> getVersion(@Valid @NotEmpty(message = "模版实例id不能为空") @RequestParam("id") String id) {
return success(templateInstanceService.getVersion(id));
}

View File

@@ -6,6 +6,7 @@ import com.zt.plat.module.base.controller.admin.templtp.onlyoffice.pojo.OnlyOffi
import com.zt.plat.module.base.controller.admin.templtp.onlyoffice.service.OnlyOfficeCallbackService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -33,7 +34,6 @@ public class OnlyOfficeCallbackController {
public ResponseEntity<Map<String, Integer>> handleCallback(@RequestBody OnlyOfficeCallback callback, @PathVariable String id) {
// 处理回调逻辑
callbackService.processCallback(callback,id);
// 返回必须的响应否则OnlyOffice会显示错误
Map<String, Integer> response = new HashMap<>();
response.put("error", 0);

View File

@@ -143,7 +143,7 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
// 2. 获取并验证文件名
String fileName = file.getOriginalFilename();
String directory = "template-instance";
String directory = "模版实例";
FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO();
fileCreateReqDTO.setName(fileName);
fileCreateReqDTO.setContent(file.getBytes());
@@ -152,6 +152,7 @@ public class OnlyOfficeCallbackServiceImpl implements OnlyOfficeCallbackService
// 7. 调用文件服务创建文件
CommonResult<String> result = fileApi.createFile(fileCreateReqDTO);
log.info("文件创建结果:{}", result);
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@@ -359,7 +359,9 @@ private String incrementVersion(String currentVersion) {
@Override
public Map<String, Object> getVersion(String id) {
validateTemplateInstanceExists(Long.valueOf(id));
return Map.of("version", templateInstanceMapper.selectById(id).getVer());
String ver = templateInstanceMapper.selectById(id).getVer();
String newVer = incrementVersion(ver);
return Map.of("version",ver,"newVersion",newVer);
}
@Override