处理依赖
This commit is contained in:
parent
91e8ca193d
commit
81737962f3
@ -17,6 +17,12 @@
|
|||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ink.wgink</groupId>
|
||||||
|
<artifactId>module-file</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -344,4 +344,6 @@ public class FormController extends DefaultBaseController {
|
|||||||
return formService.listPageHistoryByFormId(formId, page);
|
return formService.listPageHistoryByFormId(formId, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package ink.wgink.module.form.controller.app.api.onlyoffice;
|
||||||
|
|
||||||
|
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||||
|
import ink.wgink.common.base.DefaultBaseController;
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.form.pojo.vos.onlyoffice.OnlyOfficeSaveVO;
|
||||||
|
import ink.wgink.module.form.service.onlyoffice.IOnlyOfficeService;
|
||||||
|
import ink.wgink.pojo.result.ErrorResult;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: OnlyOfficeController
|
||||||
|
* @Description: OnlyOffice
|
||||||
|
* @Author: CodeFactory
|
||||||
|
* @Date: 2022-06-24 15:06:48
|
||||||
|
* @Version: 3.0
|
||||||
|
**/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "OnlyOffice")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(ISystemConstant.APP_PREFIX + "/only-office")
|
||||||
|
public class OnlyOfficeAppController extends DefaultBaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOnlyOfficeService onlyOfficeService;
|
||||||
|
|
||||||
|
@ApiOperation(value = "保存文件", notes = "保存文件接口")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "fileId", value = "文件ID", paramType = "path")
|
||||||
|
})
|
||||||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||||
|
@PostMapping("save-release/code/{formCode}/version/{formVersion}/uid/{uid}/file-id/{fileId}")
|
||||||
|
@CheckRequestBodyAnnotation
|
||||||
|
public Map<String, Object> save(@PathVariable("formCode") String formCode,
|
||||||
|
@PathVariable("formVersion") Integer formVersion,
|
||||||
|
@PathVariable("uid") String uid,
|
||||||
|
@PathVariable("fileId") String fileId,
|
||||||
|
@RequestBody OnlyOfficeSaveVO onlyOfficeSaveVO) {
|
||||||
|
if(onlyOfficeSaveVO.getStatus() == 2) {
|
||||||
|
onlyOfficeService.save(formCode, formVersion, uid, fileId, onlyOfficeSaveVO);
|
||||||
|
}
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("error", 0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package ink.wgink.module.form.controller.route.onlyoffice;
|
||||||
|
|
||||||
|
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||||
|
import ink.wgink.module.form.service.onlyoffice.IOnlyOfficeService;
|
||||||
|
import ink.wgink.properties.onlyoffice.OnlyOfficeProperties;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: OnlyOfficeRouteController
|
||||||
|
* @Description: OnlyOffice
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 14:45
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "OnlyOffice")
|
||||||
|
@Controller
|
||||||
|
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/only-office")
|
||||||
|
public class OnlyOfficeRouteController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OnlyOfficeProperties onlyOfficeProperties;
|
||||||
|
@Autowired
|
||||||
|
private IOnlyOfficeService onlyOfficeService;
|
||||||
|
|
||||||
|
@GetMapping("edit/code/{formCode}/version/{formVersion}/uid/{uid}/file-id/{fileId}")
|
||||||
|
public ModelAndView edit(@PathVariable("formCode") String formCode,
|
||||||
|
@PathVariable("formVersion") Integer formVersion,
|
||||||
|
@PathVariable("uid") String uid,
|
||||||
|
@PathVariable("fileId") String fileId) {
|
||||||
|
ModelAndView modelAndView = new ModelAndView("only-office/edit");
|
||||||
|
modelAndView.addObject("fileId", fileId);
|
||||||
|
modelAndView.addObject("server", onlyOfficeProperties.getServer());
|
||||||
|
modelAndView.addObject("config", onlyOfficeService.getConfig(formCode, formVersion, uid, fileId));
|
||||||
|
return modelAndView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package ink.wgink.module.form.pojo.dtos.onlyoffice.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: DocumentDTO
|
||||||
|
* @Description: 配置
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 16:26
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class DocumentDTO {
|
||||||
|
|
||||||
|
private String fileType;
|
||||||
|
private String key;
|
||||||
|
private String title;
|
||||||
|
private String url;
|
||||||
|
private PermissionsDTO permissionsDTO;
|
||||||
|
|
||||||
|
public String getFileType() {
|
||||||
|
return fileType == null ? "" : fileType.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileType(String fileType) {
|
||||||
|
this.fileType = fileType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key == null ? "" : key.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title == null ? "" : title.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url == null ? "" : url.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PermissionsDTO getPermissionsDTO() {
|
||||||
|
return permissionsDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissionsDTO(PermissionsDTO permissionsDTO) {
|
||||||
|
this.permissionsDTO = permissionsDTO;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package ink.wgink.module.form.pojo.dtos.onlyoffice.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: EditConfigDTO
|
||||||
|
* @Description: 编辑配置
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 20:01
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class EditConfigDTO {
|
||||||
|
|
||||||
|
private String callbackUrl;
|
||||||
|
private String lang;
|
||||||
|
private String location;
|
||||||
|
private String region;
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public String getCallbackUrl() {
|
||||||
|
return callbackUrl == null ? "" : callbackUrl.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCallbackUrl(String callbackUrl) {
|
||||||
|
this.callbackUrl = callbackUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLang() {
|
||||||
|
return lang == null ? "" : lang.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLang(String lang) {
|
||||||
|
this.lang = lang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocation() {
|
||||||
|
return location == null ? "" : location.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(String location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegion() {
|
||||||
|
return region == null ? "" : region.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(String region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class User {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id == null ? "" : id.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name == null ? "" : name.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
package ink.wgink.module.form.pojo.dtos.onlyoffice.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: permissions
|
||||||
|
* @Description: 权限
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 16:29
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class PermissionsDTO {
|
||||||
|
|
||||||
|
private Boolean chat;
|
||||||
|
private Boolean comment;
|
||||||
|
private Boolean copy;
|
||||||
|
private Boolean deleteCommentAuthorOnly;
|
||||||
|
private Boolean download;
|
||||||
|
private Boolean edit;
|
||||||
|
private Boolean editCommentAuthorOnly;
|
||||||
|
private Boolean fillForms;
|
||||||
|
private Boolean modifyContentControl;
|
||||||
|
private Boolean modifyFilter;
|
||||||
|
private Boolean print;
|
||||||
|
private Boolean protect;
|
||||||
|
private Boolean review;
|
||||||
|
|
||||||
|
public Boolean getChat() {
|
||||||
|
return chat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChat(Boolean chat) {
|
||||||
|
this.chat = chat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getComment() {
|
||||||
|
return comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComment(Boolean comment) {
|
||||||
|
this.comment = comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCopy() {
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCopy(Boolean copy) {
|
||||||
|
this.copy = copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDeleteCommentAuthorOnly() {
|
||||||
|
return deleteCommentAuthorOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleteCommentAuthorOnly(Boolean deleteCommentAuthorOnly) {
|
||||||
|
this.deleteCommentAuthorOnly = deleteCommentAuthorOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDownload() {
|
||||||
|
return download;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDownload(Boolean download) {
|
||||||
|
this.download = download;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEdit() {
|
||||||
|
return edit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEdit(Boolean edit) {
|
||||||
|
this.edit = edit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEditCommentAuthorOnly() {
|
||||||
|
return editCommentAuthorOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEditCommentAuthorOnly(Boolean editCommentAuthorOnly) {
|
||||||
|
this.editCommentAuthorOnly = editCommentAuthorOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getFillForms() {
|
||||||
|
return fillForms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFillForms(Boolean fillForms) {
|
||||||
|
this.fillForms = fillForms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getModifyContentControl() {
|
||||||
|
return modifyContentControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifyContentControl(Boolean modifyContentControl) {
|
||||||
|
this.modifyContentControl = modifyContentControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getModifyFilter() {
|
||||||
|
return modifyFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifyFilter(Boolean modifyFilter) {
|
||||||
|
this.modifyFilter = modifyFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPrint() {
|
||||||
|
return print;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrint(Boolean print) {
|
||||||
|
this.print = print;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getProtect() {
|
||||||
|
return protect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProtect(Boolean protect) {
|
||||||
|
this.protect = protect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getReview() {
|
||||||
|
return review;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReview(Boolean review) {
|
||||||
|
this.review = review;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,190 @@
|
|||||||
|
package ink.wgink.module.form.pojo.vos.onlyoffice;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: OnlyOfficeSaveVO
|
||||||
|
* @Description: 保存
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 20:20
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class OnlyOfficeSaveVO {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private Integer status;
|
||||||
|
private String url;
|
||||||
|
private String changeUrl;
|
||||||
|
private List<String> users;
|
||||||
|
private String lastsave;
|
||||||
|
private Boolean notmodified;
|
||||||
|
private String filetype;
|
||||||
|
private History history;
|
||||||
|
private List<Action> actions;
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key == null ? "" : key.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status == null ? 0 : status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url == null ? "" : url.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChangeUrl() {
|
||||||
|
return changeUrl == null ? "" : changeUrl.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChangeUrl(String changeUrl) {
|
||||||
|
this.changeUrl = changeUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUsers() {
|
||||||
|
return users == null ? new ArrayList() : users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(List<String> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastsave() {
|
||||||
|
return lastsave == null ? "" : lastsave.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastsave(String lastsave) {
|
||||||
|
this.lastsave = lastsave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getNotmodified() {
|
||||||
|
return notmodified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotmodified(Boolean notmodified) {
|
||||||
|
this.notmodified = notmodified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFiletype() {
|
||||||
|
return filetype == null ? "" : filetype.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFiletype(String filetype) {
|
||||||
|
this.filetype = filetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public History getHistory() {
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHistory(History history) {
|
||||||
|
this.history = history;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Action> getActions() {
|
||||||
|
return actions == null ? new ArrayList() : actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActions(List<Action> actions) {
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class History {
|
||||||
|
private String serverVersion;
|
||||||
|
private List<Change> changes;
|
||||||
|
|
||||||
|
public String getServerVersion() {
|
||||||
|
return serverVersion == null ? "" : serverVersion.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerVersion(String serverVersion) {
|
||||||
|
this.serverVersion = serverVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Change> getChanges() {
|
||||||
|
return changes == null ? new ArrayList() : changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChanges(List<Change> changes) {
|
||||||
|
this.changes = changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Change {
|
||||||
|
private String created;
|
||||||
|
private User user;
|
||||||
|
|
||||||
|
public String getCreated() {
|
||||||
|
return created == null ? "" : created.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreated(String created) {
|
||||||
|
this.created = created;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class User {
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id == null ? "" : id.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name == null ? "" : name.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Action {
|
||||||
|
private Integer type;
|
||||||
|
private String userid;
|
||||||
|
|
||||||
|
public Integer getType() {
|
||||||
|
return type == null ? 0 : type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Integer type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserid() {
|
||||||
|
return userid == null ? "" : userid.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserid(String userid) {
|
||||||
|
this.userid = userid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package ink.wgink.module.form.service.onlyoffice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import ink.wgink.module.form.pojo.vos.onlyoffice.OnlyOfficeSaveVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IOnlyOfficeService
|
||||||
|
* @Description: OnlyOffice
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 15:32
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IOnlyOfficeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @param formCode 表单编码
|
||||||
|
* @param formVersion 表单版本
|
||||||
|
* @param uid 上报id
|
||||||
|
* @param fileId 文件ID
|
||||||
|
* @param onlyOfficeSaveVO 文档内容
|
||||||
|
*/
|
||||||
|
void save(String formCode, Integer formVersion, String uid, String fileId, OnlyOfficeSaveVO onlyOfficeSaveVO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取配置
|
||||||
|
*
|
||||||
|
* @param formCode
|
||||||
|
* @param formVersion
|
||||||
|
* @param uid
|
||||||
|
* @param fileId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JSONObject getConfig(String formCode, Integer formVersion, String uid, String fileId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,166 @@
|
|||||||
|
package ink.wgink.module.form.service.onlyoffice.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
|
import ink.wgink.exceptions.ParamsException;
|
||||||
|
import ink.wgink.exceptions.SearchException;
|
||||||
|
import ink.wgink.module.file.enums.UploadTypeEnum;
|
||||||
|
import ink.wgink.module.file.pojo.dtos.v2.FileUploadSuccessDTO;
|
||||||
|
import ink.wgink.module.file.pojo.vos.v2.FileUpdateVO;
|
||||||
|
import ink.wgink.module.file.service.v2.IFileService;
|
||||||
|
import ink.wgink.module.form.pojo.dtos.onlyoffice.config.DocumentDTO;
|
||||||
|
import ink.wgink.module.form.pojo.dtos.onlyoffice.config.EditConfigDTO;
|
||||||
|
import ink.wgink.module.form.pojo.dtos.onlyoffice.config.PermissionsDTO;
|
||||||
|
import ink.wgink.module.form.pojo.vos.onlyoffice.OnlyOfficeSaveVO;
|
||||||
|
import ink.wgink.module.form.service.onlyoffice.IOnlyOfficeService;
|
||||||
|
import ink.wgink.pojo.bos.UserInfoBO;
|
||||||
|
import ink.wgink.pojo.pos.FilePO;
|
||||||
|
import ink.wgink.properties.ServerProperties;
|
||||||
|
import ink.wgink.util.UUIDUtil;
|
||||||
|
import ink.wgink.util.string.WStringUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: OnlyOfficeServiceImpl
|
||||||
|
* @Description: onlyoffice
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2022/7/24 15:33
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OnlyOfficeServiceImpl extends DefaultBaseService implements IOnlyOfficeService {
|
||||||
|
|
||||||
|
public static final String[] WORD_FILE_TYPE_ARRAY = new String[]{
|
||||||
|
"doc", "docx", "docm", "docxf", "dot", "dotm", "dotx", "epub", "fodt", "fb2", "htm", "html", "mht", "odt",
|
||||||
|
"oform", "ott", "oxps", "pdf", "rtf", "txt", "djvu", "xml", "xps"};
|
||||||
|
public static final String[] CELL_FILE_TYPE_ARRAY = new String[]{
|
||||||
|
"csv", "fods", "ods", "ots", "xls", "xlsb", "xlsm", "xlsx", "xlt", "xltm", "xltx"};
|
||||||
|
public static final String[] SLIDE_FILE_TYPE_ARRAY = new String[]{
|
||||||
|
"fodp", "odp", "otp", "pot", "potm", "potx", "pps", "ppsm", "ppsx", "ppt", "pptm", "pptx"};
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServerProperties serverProperties;
|
||||||
|
@Autowired
|
||||||
|
private IFileService fileV2Service;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(String formCode, Integer formVersion, String uid, String fileId, OnlyOfficeSaveVO onlyOfficeSaveVO) {
|
||||||
|
FilePO filePO = fileV2Service.getPO(fileId);
|
||||||
|
if (filePO == null) {
|
||||||
|
throw new SearchException("文件不存在");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
URL url = new URL(onlyOfficeSaveVO.getUrl());
|
||||||
|
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
|
||||||
|
InputStream inputStream = httpURLConnection.getInputStream();
|
||||||
|
FileUploadSuccessDTO uploadSuccessDTO = fileV2Service.uploadSingleByUserId(onlyOfficeSaveVO.getUsers().get(0), inputStream, UploadTypeEnum.FILE, filePO.getFileName());
|
||||||
|
// 调换文件信息,保留原来的ID不变
|
||||||
|
String newFileId = uploadSuccessDTO.getFileId();
|
||||||
|
FilePO newFilePO = fileV2Service.getPO(newFileId);
|
||||||
|
|
||||||
|
// 新文件信息 -> 旧文件
|
||||||
|
FileUpdateVO fileUpdateVO = new FileUpdateVO();
|
||||||
|
BeanUtils.copyProperties(newFilePO, fileUpdateVO);
|
||||||
|
fileUpdateVO.setUploadPath(newFilePO.getFilePath());
|
||||||
|
fileUpdateVO.setFileId(filePO.getFileId());
|
||||||
|
fileV2Service.update(fileUpdateVO);
|
||||||
|
|
||||||
|
// 旧的文件信息 -> 新文件
|
||||||
|
BeanUtils.copyProperties(filePO, fileUpdateVO);
|
||||||
|
fileUpdateVO.setUploadPath(filePO.getFilePath());
|
||||||
|
fileUpdateVO.setFileId(newFilePO.getFileId());
|
||||||
|
fileV2Service.update(fileUpdateVO);
|
||||||
|
} catch (RuntimeException | IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getConfig(String formCode, Integer formVersion, String uid, String fileId) {
|
||||||
|
FilePO filePO = fileV2Service.getPO(fileId);
|
||||||
|
if (filePO == null) {
|
||||||
|
throw new SearchException("文件不存在");
|
||||||
|
}
|
||||||
|
DocumentDTO documentDTO = new DocumentDTO();
|
||||||
|
documentDTO.setFileType(filePO.getFileType());
|
||||||
|
documentDTO.setTitle(filePO.getFileName());
|
||||||
|
documentDTO.setKey(WStringUtil.randomSubStr(UUIDUtil.get32UUID(), 20));
|
||||||
|
documentDTO.setUrl(serverProperties.getUrl() + "/route/file/download/false/" + fileId);
|
||||||
|
// 权限
|
||||||
|
PermissionsDTO permissionsDTO = new PermissionsDTO();
|
||||||
|
permissionsDTO.setChat(false);
|
||||||
|
permissionsDTO.setComment(true);
|
||||||
|
permissionsDTO.setCopy(true);
|
||||||
|
permissionsDTO.setDeleteCommentAuthorOnly(false);
|
||||||
|
permissionsDTO.setDownload(true);
|
||||||
|
permissionsDTO.setEdit(true);
|
||||||
|
permissionsDTO.setEditCommentAuthorOnly(false);
|
||||||
|
permissionsDTO.setFillForms(true);
|
||||||
|
permissionsDTO.setModifyContentControl(true);
|
||||||
|
permissionsDTO.setModifyFilter(true);
|
||||||
|
permissionsDTO.setPrint(true);
|
||||||
|
permissionsDTO.setProtect(true);
|
||||||
|
permissionsDTO.setReview(true);
|
||||||
|
documentDTO.setPermissionsDTO(permissionsDTO);
|
||||||
|
// 编辑配置
|
||||||
|
EditConfigDTO editConfigDTO = new EditConfigDTO();
|
||||||
|
editConfigDTO.setCallbackUrl(String.format("%s/app/only-office/save-release/code/%s/version/%d/uid/%s/file-id/%s",
|
||||||
|
serverProperties.getUrl(),
|
||||||
|
formCode,
|
||||||
|
formVersion,
|
||||||
|
uid,
|
||||||
|
fileId));
|
||||||
|
// 菜单语言
|
||||||
|
editConfigDTO.setLang("zh");
|
||||||
|
// 文档语言
|
||||||
|
editConfigDTO.setRegion("zh-CN");
|
||||||
|
|
||||||
|
EditConfigDTO.User user = new EditConfigDTO.User();
|
||||||
|
UserInfoBO currentUser = securityComponent.getCurrentUser();
|
||||||
|
user.setId(currentUser.getUserId());
|
||||||
|
user.setName(currentUser.getUserName());
|
||||||
|
editConfigDTO.setUser(user);
|
||||||
|
|
||||||
|
JSONObject config = new JSONObject();
|
||||||
|
config.put("document", documentDTO);
|
||||||
|
config.put("documentType", getDocumentType(filePO.getFileType()));
|
||||||
|
config.put("editorConfig", editConfigDTO);
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件类型
|
||||||
|
*
|
||||||
|
* @param fileType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getDocumentType(String fileType) {
|
||||||
|
// 打开excel时会有问题,目前只支持word
|
||||||
|
for (String wordFileType : WORD_FILE_TYPE_ARRAY) {
|
||||||
|
if (StringUtils.equals(fileType, wordFileType)) {
|
||||||
|
return "word";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String cellFileType : CELL_FILE_TYPE_ARRAY) {
|
||||||
|
if (StringUtils.equals(fileType, cellFileType)) {
|
||||||
|
return "cell";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (String slideFileType : SLIDE_FILE_TYPE_ARRAY) {
|
||||||
|
if (StringUtils.equals(fileType, slideFileType)) {
|
||||||
|
return "slide";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new ParamsException("文件类型不支持");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<base th:href="${#request.getContextPath() + '/'} ">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="renderer" content="webkit">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||||
|
<style>
|
||||||
|
html, body {padding: 0;margin: 0;height: 100%;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="placeholder"></div>
|
||||||
|
<script type="text/javascript" th:src="${server +'/web-apps/apps/api/documents/api.js'}"></script>
|
||||||
|
<script th:inline="javascript">
|
||||||
|
var config = [[${config}]]
|
||||||
|
var docEditor = new DocsAPI.DocEditor("placeholder", config);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user