模版编制相关实现
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user