feat: wps对接修复
parent
3aabb226e9
commit
06b173514f
|
|
@ -131,16 +131,16 @@ public class H5OpenController {
|
||||||
|
|
||||||
@ApiOperation("打开页:当前用户有文档返回最近一份,没有则创建空白docx")
|
@ApiOperation("打开页:当前用户有文档返回最近一份,没有则创建空白docx")
|
||||||
@GetMapping(value = "/doc/my-or-create", produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/doc/my-or-create", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public SingleResponse<WpsDocOpenCO> myOrCreate() {
|
public SingleResponse<WpsDocOpenCO> myOrCreate(@RequestParam("docxUrl") String docxUrl) {
|
||||||
log.info("wps my-or-create");
|
log.info("wps my-or-create");
|
||||||
return SingleResponse.of(wpsApi.myOrCreate());
|
return SingleResponse.of(wpsApi.myOrCreate(docxUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("始终新建一份空白docx")
|
@ApiOperation("始终新建一份空白docx")
|
||||||
@PostMapping(value = "/doc/create", produces = MediaType.APPLICATION_JSON_VALUE)
|
@PostMapping(value = "/doc/create", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public SingleResponse<WpsDocOpenCO> createBlank() {
|
public SingleResponse<WpsDocOpenCO> createBlank(@RequestParam("docxUrl") String docxUrl) {
|
||||||
log.info("wps create blank");
|
log.info("wps create blank");
|
||||||
return SingleResponse.of(wpsApi.createBlank());
|
return SingleResponse.of(wpsApi.createBlank(docxUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String toJson(Map<String, Object> result) {
|
private String toJson(Map<String, Object> result) {
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,7 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WpsDocOpenCO myOrCreate() {
|
public WpsDocOpenCO myOrCreate(String docxUrl) {
|
||||||
try {
|
try {
|
||||||
Long userId = requireUserId();
|
Long userId = requireUserId();
|
||||||
String creatorId = String.valueOf(userId);
|
String creatorId = String.valueOf(userId);
|
||||||
|
|
@ -323,7 +323,7 @@ public class WpsExecutor implements WpsApi {
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
return toOpenCO(existing, false);
|
return toOpenCO(existing, false);
|
||||||
}
|
}
|
||||||
WpsDocEntity created = doCreateBlankDoc(userId);
|
WpsDocEntity created = doCreateBlankDoc(userId, docxUrl);
|
||||||
return toOpenCO(created, true);
|
return toOpenCO(created, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("wps myOrCreate failed", e);
|
log.error("wps myOrCreate failed", e);
|
||||||
|
|
@ -332,10 +332,10 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WpsDocOpenCO createBlank() {
|
public WpsDocOpenCO createBlank(String docxUrl) {
|
||||||
try {
|
try {
|
||||||
Long userId = requireUserId();
|
Long userId = requireUserId();
|
||||||
WpsDocEntity created = doCreateBlankDoc(userId);
|
WpsDocEntity created = doCreateBlankDoc(userId, docxUrl);
|
||||||
return toOpenCO(created, true);
|
return toOpenCO(created, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("wps createBlank failed", e);
|
log.error("wps createBlank failed", e);
|
||||||
|
|
@ -343,8 +343,9 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WpsDocEntity doCreateBlankDoc(Long userId) {
|
protected WpsDocEntity doCreateBlankDoc(Long userId, String docxUrl) {
|
||||||
if (!StringUtils.hasText(defDocxUrl)) {
|
String resDocxUrl = !StringUtils.hasText(docxUrl) ? defDocxUrl : docxUrl;
|
||||||
|
if (!StringUtils.hasText(resDocxUrl)) {
|
||||||
throw new BizException(ErrorCode.WPS_BLANK_DOCX_URL_EMPTY);
|
throw new BizException(ErrorCode.WPS_BLANK_DOCX_URL_EMPTY);
|
||||||
}
|
}
|
||||||
Long orgId = requireOrgId();
|
Long orgId = requireOrgId();
|
||||||
|
|
@ -354,14 +355,14 @@ public class WpsExecutor implements WpsApi {
|
||||||
long nowEpoch = System.currentTimeMillis() / 1000;
|
long nowEpoch = System.currentTimeMillis() / 1000;
|
||||||
|
|
||||||
FileStorage saved;
|
FileStorage saved;
|
||||||
try (InputStream inputStream = new URL(defDocxUrl).openStream()) {
|
try (InputStream inputStream = new URL(resDocxUrl).openStream()) {
|
||||||
FileInfo ossFileInfo = fileStorageService.of(inputStream, docName).upload();
|
FileInfo ossFileInfo = fileStorageService.of(inputStream, docName).upload();
|
||||||
FileStorage fileStorage = FileStorageHelper.buildResource(ossFileInfo, docName, true);
|
FileStorage fileStorage = FileStorageHelper.buildResource(ossFileInfo, docName, true);
|
||||||
saved = fileStorageDomainService.saveResource(fileStorage);
|
saved = fileStorageDomainService.saveResource(fileStorage);
|
||||||
} catch (BizException e) {
|
} catch (BizException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("download blank docx failed, url={}", defDocxUrl, e);
|
log.error("download blank docx failed, url={}", resDocxUrl, e);
|
||||||
throw new BizException(ErrorCode.WPS_BLANK_DOCX_DOWNLOAD_FAILED, e);
|
throw new BizException(ErrorCode.WPS_BLANK_DOCX_DOWNLOAD_FAILED, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -417,11 +418,7 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Long requireOrgId() {
|
private Long requireOrgId() {
|
||||||
Long orgId = AuthUserContextAdapter.getCurrentOrgId();
|
Long orgId = ThreadLocalUserInfoAdapter.get();
|
||||||
if (orgId != null) {
|
|
||||||
return orgId;
|
|
||||||
}
|
|
||||||
orgId = ThreadLocalUserInfoAdapter.get();
|
|
||||||
if (orgId != null) {
|
if (orgId != null) {
|
||||||
return orgId;
|
return orgId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@ public interface WpsApi {
|
||||||
/**
|
/**
|
||||||
* 打开页:当前用户有文档则返回最近一份,没有则创建空白 docx
|
* 打开页:当前用户有文档则返回最近一份,没有则创建空白 docx
|
||||||
*/
|
*/
|
||||||
WpsDocOpenCO myOrCreate();
|
WpsDocOpenCO myOrCreate(String docxUrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 始终新建一份空白 docx(即使用户已有文档)
|
* 始终新建一份空白 docx(即使用户已有文档)
|
||||||
*/
|
*/
|
||||||
WpsDocOpenCO createBlank();
|
WpsDocOpenCO createBlank(String docxUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,4 @@ import org.qinan.safetyeval.infrastructure.dataobject.AccountDO;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AccountMapper extends BaseMapper<AccountDO> {
|
public interface AccountMapper extends BaseMapper<AccountDO> {
|
||||||
String getWps(int i);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,5 @@
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
`id`, `user_name`, `account`, `phone`, `password`, `profile_url`, `type`, `delete_enum`, `remarks`, `create_name`, `update_name`, `tenant_id`, `version`, `create_time`, `update_time`, `create_id`, `update_id`, `env`
|
`id`, `user_name`, `account`, `phone`, `password`, `profile_url`, `type`, `delete_enum`, `remarks`, `create_name`, `update_name`, `tenant_id`, `version`, `create_time`, `update_time`, `create_id`, `update_id`, `env`
|
||||||
</sql>
|
</sql>
|
||||||
<select id="getWps" resultType="java.lang.String">
|
|
||||||
SELECT val FROM `wps` WHERE `key` = #{id}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -175,3 +175,4 @@ def:
|
||||||
wps:
|
wps:
|
||||||
upload-base-url: ${WPS_UPLOAD_BASE_URL:https://gbs-gateway.qhdsafety.com/safetyEval-h5/wsp}
|
upload-base-url: ${WPS_UPLOAD_BASE_URL:https://gbs-gateway.qhdsafety.com/safetyEval-h5/wsp}
|
||||||
def-docx-url: https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a59d83ee4b0b4541389511f.docx
|
def-docx-url: https://test-dragon-yf-pub.oss-cn-hangzhou.aliyuncs.com/jjb/6a59d83ee4b0b4541389511f.docx
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue