feat: wps对接修复
parent
197efe3e74
commit
e993d2c2f5
|
|
@ -1,26 +1,19 @@
|
||||||
package org.qinan.safetyeval.adapter.web;
|
package org.qinan.safetyeval.adapter.web;
|
||||||
|
|
||||||
import com.alibaba.cola.dto.SingleResponse;
|
import com.alibaba.cola.dto.SingleResponse;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.qinan.safetyeval.client.api.WpsApi;
|
import org.qinan.safetyeval.client.api.WpsApi;
|
||||||
import org.qinan.safetyeval.client.co.WpsDocOpenCO;
|
import org.qinan.safetyeval.client.co.WpsDocOpenCO;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -37,8 +30,6 @@ public class H5OpenController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private WpsApi wpsApi;
|
private WpsApi wpsApi;
|
||||||
@Resource
|
|
||||||
private ObjectMapper objectMapper;
|
|
||||||
|
|
||||||
@ApiOperation("wps回调-获取文件信息")
|
@ApiOperation("wps回调-获取文件信息")
|
||||||
@GetMapping(value = "/v3/3rd/files/{file_id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/v3/3rd/files/{file_id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
|
@ -143,10 +134,20 @@ public class H5OpenController {
|
||||||
return SingleResponse.of(wpsApi.createBlank(docxUrl));
|
return SingleResponse.of(wpsApi.createBlank(docxUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("模版文档(固定)")
|
||||||
|
@PostMapping(value = "/doc/template")
|
||||||
|
public SingleResponse<Map<String, Object>> template() {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("安全预评价报告", "https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a5dd9010dc588e38bfb4cce.docx");
|
||||||
|
map.put("安全验收评价报告", "https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a5dd9010dc588e38bfb4cce.docx");
|
||||||
|
map.put("安全现状评价报告", "https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a5dd9010dc588e38bfb4cce.docx");
|
||||||
|
return SingleResponse.of(map);
|
||||||
|
}
|
||||||
|
|
||||||
private String toJson(Map<String, Object> result) {
|
private String toJson(Map<String, Object> result) {
|
||||||
try {
|
try {
|
||||||
return objectMapper.writeValueAsString(result);
|
return JSONObject.toJSONString(result).toString();
|
||||||
} catch (JsonProcessingException e) {
|
} catch (Exception e) {
|
||||||
log.error("wps response serialize failed", e);
|
log.error("wps response serialize failed", e);
|
||||||
return "{\"code\":40001,\"message\":\"serialize error\"}";
|
return "{\"code\":40001,\"message\":\"serialize error\"}";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue