package jnpf.bizcommon.onlyoffice.controller;
|
|
import jnpf.base.ActionResult;
|
import jnpf.bizcommon.onlyoffice.entity.OnlyOfficeCallbackParam;
|
import jnpf.bizcommon.onlyoffice.service.impl.OnlyOfficeCompareService;
|
import jnpf.bizcommon.onlyoffice.service.impl.OnlyOfficeComparisonRenderer;
|
import org.springframework.http.ResponseEntity;
|
import jnpf.util.UserProvider;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
import java.util.Collections;
|
import java.util.Map;
|
|
@RestController
|
@RequestMapping("/onlyoffice/compare")
|
@RequiredArgsConstructor
|
public class OnlyOfficeCompareController {
|
private final OnlyOfficeCompareService service;
|
|
@PostMapping("/config")
|
public ActionResult<Map<String, Object>> config(@RequestBody Map<String, String> request) {
|
return ActionResult.success(service.createConfig(request.get("ticket"), UserProvider.getUser()));
|
}
|
|
@GetMapping(value = "/script.js", produces = "application/javascript")
|
public String script() {
|
return OnlyOfficeComparisonRenderer.SCRIPT;
|
}
|
|
@GetMapping("/result")
|
public ResponseEntity<byte[]> result(@RequestParam String ticket) {
|
return ResponseEntity.ok()
|
.header("Content-Type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
.header("Cache-Control", "no-store")
|
.body(service.readResult(ticket));
|
}
|
|
@PostMapping("/callback")
|
public Map<String, Object> callback(@RequestBody OnlyOfficeCallbackParam body,
|
@RequestHeader(value = "Authorization", required = false) String authorization) {
|
service.acknowledgeCallback(body, authorization);
|
return Collections.singletonMap("error", 0);
|
}
|
}
|