线上: bug
parent
7b3eb56ad6
commit
59f3fa5301
|
|
@ -48,9 +48,29 @@ public class H5OpenController {
|
||||||
|
|
||||||
@ApiOperation("wps回调-文档权限")
|
@ApiOperation("wps回调-文档权限")
|
||||||
@GetMapping(value = "/v3/3rd/files/{file_id}/permission", produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(value = "/v3/3rd/files/{file_id}/permission", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
public String getWpsPermissionByFileId(@PathVariable("file_id") String fileId) {
|
public String getWpsPermissionByFileId(@PathVariable("file_id") String fileId, @RequestHeader("X-User-Query") String xUserQuery) {
|
||||||
log.info("wps回调权限信息:{}", fileId);
|
log.info("wps回调权限信息:{}", fileId);
|
||||||
return toJson(wpsApi.getPermission(fileId));
|
String readOnlyValue = getReadOnlyValue(xUserQuery);
|
||||||
|
return toJson(wpsApi.getPermission(fileId, readOnlyValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件权限值
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getReadOnlyValue(String query) {
|
||||||
|
if (query == null || query.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String[] pairs = query.split("&");
|
||||||
|
for (String pair : pairs) {
|
||||||
|
String[] keyValue = pair.split("=", 2);
|
||||||
|
if (keyValue.length == 2 && "readOnly".equals(keyValue[0])) {
|
||||||
|
return keyValue[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // 未找到
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("wps回调-批量用户信息")
|
@ApiOperation("wps回调-批量用户信息")
|
||||||
|
|
@ -128,6 +148,12 @@ public class H5OpenController {
|
||||||
return SingleResponse.of(wpsApi.myOrCreate(docxUrl, projectId));
|
return SingleResponse.of(wpsApi.myOrCreate(docxUrl, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询项目文档")
|
||||||
|
@GetMapping(value = "/doc/getDocByProjectId")
|
||||||
|
public SingleResponse<WpsDocOpenCO> getDocByProjectId(@RequestParam("projectId") String projectId) {
|
||||||
|
return SingleResponse.of(wpsApi.getDocByProjectId(projectId));
|
||||||
|
}
|
||||||
|
|
||||||
@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(@RequestBody Req<Map<String, String>> req) {
|
public SingleResponse<WpsDocOpenCO> createBlank(@RequestBody Req<Map<String, String>> req) {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.qinan.safetyeval.app.executor;
|
package org.qinan.safetyeval.app.executor;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.x.file.storage.core.FileInfo;
|
import org.dromara.x.file.storage.core.FileInfo;
|
||||||
import org.dromara.x.file.storage.core.FileStorageService;
|
import org.dromara.x.file.storage.core.FileStorageService;
|
||||||
|
|
@ -23,6 +24,9 @@ import org.qinan.safetyeval.domain.service.ProjectStageSyncService;
|
||||||
import org.qinan.safetyeval.domain.service.WpsDocDomainService;
|
import org.qinan.safetyeval.domain.service.WpsDocDomainService;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.ThreadLocalUserInfoAdapter;
|
||||||
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
import org.qinan.safetyeval.infrastructure.adapter.auth.AuthUserContextAdapter;
|
||||||
|
import org.qinan.safetyeval.infrastructure.convertor.WpsDocDoConvertor;
|
||||||
|
import org.qinan.safetyeval.infrastructure.dataobject.WpsDocDO;
|
||||||
|
import org.qinan.safetyeval.infrastructure.mapper.WpsDocMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -64,6 +68,10 @@ public class WpsExecutor implements WpsApi {
|
||||||
private String defDocxUrl;
|
private String defDocxUrl;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProjectStageSyncService projectStageSyncService;
|
private ProjectStageSyncService projectStageSyncService;
|
||||||
|
@Autowired
|
||||||
|
private WpsDocMapper wpsDocMapper;
|
||||||
|
@Autowired
|
||||||
|
private WpsDocDoConvertor wpsDocDoConvertor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getFileInfo(String fileId) {
|
public Map<String, Object> getFileInfo(String fileId) {
|
||||||
|
|
@ -88,14 +96,25 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getPermission(String fileId) {
|
public Map<String, Object> getPermission(String fileId, String readOnlyValue) {
|
||||||
try {
|
try {
|
||||||
|
WpsPermissionCO permission = new WpsPermissionCO();
|
||||||
|
if (StringUtils.hasText(readOnlyValue) && "true".equals(readOnlyValue)) {
|
||||||
|
permission.setRead(1);
|
||||||
|
permission.setUpdate(0);
|
||||||
|
permission.setDownload(1);
|
||||||
|
permission.setPrint(0);
|
||||||
|
permission.setCopy(0);
|
||||||
|
permission.setComment(0);
|
||||||
|
permission.setRename(0);
|
||||||
|
permission.setHistory(0);
|
||||||
|
permission.setSaveas(0);
|
||||||
|
} else {
|
||||||
wpsDocDomainService.getByFileId(fileId);
|
wpsDocDomainService.getByFileId(fileId);
|
||||||
Long userId = AuthUserContextAdapter.getCurrentUserId();
|
Long userId = AuthUserContextAdapter.getCurrentUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
throw new BizException(ErrorCode.WPS_USER_NOT_LOGIN);
|
throw new BizException(ErrorCode.WPS_USER_NOT_LOGIN);
|
||||||
}
|
}
|
||||||
WpsPermissionCO permission = new WpsPermissionCO();
|
|
||||||
permission.setUserId(String.valueOf(userId));
|
permission.setUserId(String.valueOf(userId));
|
||||||
permission.setRead(1);
|
permission.setRead(1);
|
||||||
permission.setUpdate(1);
|
permission.setUpdate(1);
|
||||||
|
|
@ -103,10 +122,10 @@ public class WpsExecutor implements WpsApi {
|
||||||
permission.setPrint(1);
|
permission.setPrint(1);
|
||||||
permission.setCopy(1);
|
permission.setCopy(1);
|
||||||
permission.setComment(1);
|
permission.setComment(1);
|
||||||
// 未实现重命名回调,保持 0
|
|
||||||
permission.setRename(1);
|
permission.setRename(1);
|
||||||
permission.setHistory(1);
|
permission.setHistory(1);
|
||||||
permission.setSaveas(1);
|
permission.setSaveas(1);
|
||||||
|
}
|
||||||
return ok(permission);
|
return ok(permission);
|
||||||
} catch (BizException e) {
|
} catch (BizException e) {
|
||||||
return fail(e);
|
return fail(e);
|
||||||
|
|
@ -345,6 +364,21 @@ public class WpsExecutor implements WpsApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WpsDocOpenCO getDocByProjectId(String projectId) {
|
||||||
|
LambdaQueryWrapper<WpsDocDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(WpsDocDO::getProjectId, projectId);
|
||||||
|
wrapper.eq(WpsDocDO::getDeleteEnum, "false");
|
||||||
|
wrapper.orderByDesc(WpsDocDO::getId);
|
||||||
|
wrapper.last("limit 1");
|
||||||
|
WpsDocDO wpsDocDO = wpsDocMapper.selectOne(wrapper);
|
||||||
|
WpsDocEntity entity = wpsDocDoConvertor.toEntity(wpsDocDO);
|
||||||
|
if (entity != null) {
|
||||||
|
return toOpenCO(entity, false);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected WpsDocEntity doCreateBlankDoc(Long userId, String docxUrl, Long projectId) {
|
protected WpsDocEntity doCreateBlankDoc(Long userId, String docxUrl, Long projectId) {
|
||||||
if(Objects.isNull(projectId)) {
|
if(Objects.isNull(projectId)) {
|
||||||
throw new BizException(ErrorCode.EVAL_PROJECT_ERROR);
|
throw new BizException(ErrorCode.EVAL_PROJECT_ERROR);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ public interface WpsApi {
|
||||||
|
|
||||||
Map<String, Object> getDownload(String fileId);
|
Map<String, Object> getDownload(String fileId);
|
||||||
|
|
||||||
Map<String, Object> getPermission(String fileId);
|
Map<String, Object> getPermission(String fileId, String readOnlyValue);
|
||||||
|
|
||||||
Map<String, Object> getUsers(List<String> userIds);
|
Map<String, Object> getUsers(List<String> userIds);
|
||||||
|
|
||||||
|
|
@ -46,4 +46,6 @@ public interface WpsApi {
|
||||||
* 始终新建一份空白 docx(即使用户已有文档)
|
* 始终新建一份空白 docx(即使用户已有文档)
|
||||||
*/
|
*/
|
||||||
WpsDocOpenCO createBlank(String docxUrl, Long projectId);
|
WpsDocOpenCO createBlank(String docxUrl, Long projectId);
|
||||||
|
|
||||||
|
WpsDocOpenCO getDocByProjectId(String projectId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class WpsDocGatewayImpl implements WpsDocGateway {
|
||||||
@Override
|
@Override
|
||||||
public WpsDocEntity getLatestByCreatorId(String creatorId, Long projectId) {
|
public WpsDocEntity getLatestByCreatorId(String creatorId, Long projectId) {
|
||||||
LambdaQueryWrapper<WpsDocDO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WpsDocDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(WpsDocDO::getCreatorId, creatorId);
|
// wrapper.eq(WpsDocDO::getCreatorId, creatorId); 目前只做项目级查询, 人员+项目查询待定
|
||||||
wrapper.eq(WpsDocDO::getProjectId, projectId);
|
wrapper.eq(WpsDocDO::getProjectId, projectId);
|
||||||
wrapper.eq(WpsDocDO::getDeleteEnum, "false");
|
wrapper.eq(WpsDocDO::getDeleteEnum, "false");
|
||||||
wrapper.orderByDesc(WpsDocDO::getId);
|
wrapper.orderByDesc(WpsDocDO::getId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue