package jnpf.bizcommon.onlyoffice.controller;
|
|
import cn.dev33.satoken.same.SaSameUtil;
|
import jnpf.base.ActionResult;
|
import jnpf.bizcommon.onlyoffice.service.impl.OnlyOfficeRecordRevisionFenceService;
|
import jnpf.onlyoffice.RecordRevisionFenceApi;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/** 仅供 ELN 服务调用的记录修订 fence 内部端点。 */
|
@RestController
|
@RequestMapping("/Internal/onlyoffice/record-revision")
|
public class OnlyOfficeRecordRevisionFenceController implements RecordRevisionFenceApi {
|
|
private final SameTokenChecker sameTokenChecker;
|
private final OnlyOfficeRecordRevisionFenceService fenceService;
|
|
@Autowired
|
public OnlyOfficeRecordRevisionFenceController(
|
OnlyOfficeRecordRevisionFenceService fenceService) {
|
this(SaSameUtil::checkCurrentRequestToken, fenceService);
|
}
|
|
OnlyOfficeRecordRevisionFenceController(
|
SameTokenChecker sameTokenChecker,
|
OnlyOfficeRecordRevisionFenceService fenceService) {
|
this.sameTokenChecker = sameTokenChecker;
|
this.fenceService = fenceService;
|
}
|
|
@Override
|
@PostMapping("/acquire")
|
public ActionResult<String> acquire(@RequestParam("tenantId") String tenantId,
|
@RequestParam("recordId") String recordId,
|
@RequestParam("fileId") String fileId,
|
@RequestParam("fileType") String fileType) {
|
sameTokenChecker.check();
|
return ActionResult.success("记录修订 fence 获取成功", fenceService.acquire(
|
tenantId, recordId, fileId, fileType));
|
}
|
|
@Override
|
@PostMapping("/acquire-for-operation")
|
public ActionResult<String> acquireForOperation(@RequestParam("tenantId") String tenantId,
|
@RequestParam("recordId") String recordId,
|
@RequestParam("fileId") String fileId,
|
@RequestParam("fileType") String fileType,
|
@RequestParam("operationCode") String operationCode) {
|
sameTokenChecker.check();
|
return ActionResult.success("记录冻结 fence 获取成功", fenceService.acquireForOperation(
|
tenantId, recordId, fileId, fileType, operationCode));
|
}
|
|
@Override
|
@PostMapping("/complete")
|
public ActionResult<Boolean> complete(@RequestParam("tenantId") String tenantId,
|
@RequestParam("recordId") String recordId,
|
@RequestParam("fileId") String fileId,
|
@RequestParam("fileType") String fileType,
|
@RequestParam("token") String token) {
|
sameTokenChecker.check();
|
return ActionResult.success(fenceService.complete(
|
tenantId, recordId, fileId, fileType, token));
|
}
|
|
@Override
|
@PostMapping("/release")
|
public ActionResult<Boolean> release(@RequestParam("tenantId") String tenantId,
|
@RequestParam("recordId") String recordId,
|
@RequestParam("fileId") String fileId,
|
@RequestParam("fileType") String fileType,
|
@RequestParam("token") String token) {
|
sameTokenChecker.check();
|
return ActionResult.success(fenceService.release(
|
tenantId, recordId, fileId, fileType, token));
|
}
|
|
@Override
|
@PostMapping("/release-after-document-update")
|
public ActionResult<Boolean> releaseAfterDocumentUpdate(
|
@RequestParam("tenantId") String tenantId,
|
@RequestParam("recordId") String recordId,
|
@RequestParam("fileId") String fileId,
|
@RequestParam("fileType") String fileType,
|
@RequestParam("token") String token) {
|
sameTokenChecker.check();
|
return ActionResult.success(fenceService.releaseAfterDocumentUpdate(
|
tenantId, recordId, fileId, fileType, token));
|
}
|
|
@FunctionalInterface
|
interface SameTokenChecker {
|
void check();
|
}
|
}
|