onlyOffice缺失文件修补
This commit is contained in:
parent
e8e141a26b
commit
400210f5b5
@ -0,0 +1,326 @@
|
||||
package cn.iocoder.yudao.module.only.controller.admin.only;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.onlyoffice.utils.DocumentConstants;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.onlyoffice.utils.FileUtil;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.onlyoffice.utils.Md5Utils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.onlyoffice.vo.Document;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.onlyoffice.onlyofficeDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.onlyoffice.document.DocumentService;
|
||||
import cn.iocoder.yudao.module.bpm.service.onlyoffice.fileupload.FileUploadService;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofPageReqVO;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofRespVO;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofSaveReqVO;
|
||||
import cn.iocoder.yudao.module.only.dal.dataobject.only.onlyofDO;
|
||||
import cn.iocoder.yudao.module.only.service.only.onlyofService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hashids.Hashids;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - 文件编辑")
|
||||
@RestController
|
||||
@RequestMapping("/only/onlyof")
|
||||
@Validated
|
||||
@Controller
|
||||
public class onlyofController {
|
||||
|
||||
|
||||
@Value("${files.savePath}")
|
||||
private String filePath;
|
||||
@Value("${files.docservice.url.site}")
|
||||
private String officeUrl;
|
||||
@Value("${files.docservice.url.command}")
|
||||
private String officeCommand;
|
||||
@Autowired
|
||||
private DocumentService documentService;
|
||||
@Autowired
|
||||
private FileUploadService uploadService;
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
// @Resource
|
||||
// private DocumentService documentService;
|
||||
|
||||
@Resource
|
||||
private onlyofService onlyofService;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得文件编辑分页")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:query')")
|
||||
public CommonResult<PageResult<onlyofRespVO>> getonlyofPage(@Valid onlyofPageReqVO pageReqVO) {
|
||||
PageResult<onlyofDO> pageResult = onlyofService.getonlyofPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, onlyofRespVO.class));
|
||||
}
|
||||
/**
|
||||
* \
|
||||
* 查询所有上传文档信息接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/filelist")
|
||||
@Operation(summary = "获取文件列表")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:filelist')")
|
||||
public ResponseEntity<Object> listFile() {
|
||||
return new ResponseEntity<Object>(uploadService.list(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件编辑的上传文件接口
|
||||
* @param file
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "更新文件编辑")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:update')")
|
||||
public ResponseEntity<Object> upload(@RequestParam("file") MultipartFile file,@RequestParam("cDate") String cDate,HttpServletRequest request) throws Exception {
|
||||
cDate = cDate.isEmpty() ? cDate : cDate + "\\";
|
||||
// System.out.println("update"+file.getOriginalFilename()+uuid);
|
||||
if (file.isEmpty()){
|
||||
throw new Exception("上传文件不能为空");
|
||||
}
|
||||
onlyofficeDO upload = new onlyofficeDO();
|
||||
String fileName = file.getOriginalFilename();
|
||||
//更新保存文件信息到数据库
|
||||
FileUtil.saveFile(file.getInputStream(),filePath+cDate+file.getOriginalFilename(),filePath+cDate);
|
||||
upload.setUploadDate(new Date());
|
||||
upload.setFilePath(filePath+cDate);
|
||||
upload.setFileName(file.getOriginalFilename());
|
||||
upload.setFileSize(file.getSize());
|
||||
// System.out.println("111"+upload);
|
||||
uploadService.save(upload);
|
||||
System.gc();
|
||||
|
||||
return new ResponseEntity<Object>("上传成功", HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑文件的接口
|
||||
* @param name
|
||||
* @param userName
|
||||
* @param userId
|
||||
* @param token
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/edit")
|
||||
@Operation(summary = "编辑文件")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:edit')")
|
||||
public ModelAndView editDocFile(@RequestParam String name, String userName, String userId ,String cDate ,String token, Model model) {
|
||||
String cDate2 = "";
|
||||
cDate2 = cDate.isEmpty() ? cDate : cDate + "\\";
|
||||
String path = filePath+cDate2+name;
|
||||
// System.out.println("path:"+path);
|
||||
// System.out.println("edit"+uuid2);
|
||||
// System.out.println("token"+token);
|
||||
ModelAndView mav = new ModelAndView();
|
||||
Document document = documentService.getDocumentToken(documentService.buildDocument(path, name),token,cDate);
|
||||
mav.addObject("document", document);
|
||||
if (!documentService.canEdit(document)) {
|
||||
// System.out.println("demo");
|
||||
return mav;
|
||||
}
|
||||
mav.addObject("documentEditParam", documentService.buildDocumentEditParamToken(userId, userName, name,token,cDate2));
|
||||
mav.setViewName("editor");
|
||||
// System.out.println(mav);
|
||||
return mav;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文档接口
|
||||
* @param name
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping("/download")
|
||||
@Operation(summary = "下载文件")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:download')")
|
||||
public void download(String name, String cDate,HttpServletResponse response) {
|
||||
cDate = cDate.equals("") ? cDate : cDate + "\\";
|
||||
// System.out.println("download: "+name+"---"+response+"---"+uuid);
|
||||
System.out.println("cDate:"+cDate);
|
||||
try {
|
||||
FileUtil.downLoadFile(name,filePath+cDate,response);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件编辑打开保存后的回调函数
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
@RequestMapping("/callback")
|
||||
@Operation(summary = "回调文件")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:callback')")
|
||||
public void saveDocumentFile(HttpServletRequest request, HttpServletResponse response,String cDate) throws IOException {
|
||||
// System.out.println("callback"+uuid);
|
||||
//处理编辑回调逻辑
|
||||
callBack(request, response,cDate);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件状态的接口
|
||||
* @param name
|
||||
* @return
|
||||
* @throws ParseException
|
||||
*/
|
||||
@GetMapping("/editStatus")
|
||||
@Operation(summary = "文件状态")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:editStatus')")
|
||||
public ResponseEntity<Object> getDoucmentEditStatus(String name,String cDate) throws ParseException {
|
||||
cDate = (cDate != null && !cDate.isEmpty()) ? cDate + "\\" : cDate;
|
||||
// System.out.println("editStatus");
|
||||
String url = officeUrl+officeCommand;
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put("c", "forcesave");
|
||||
String docFileMd5 = Md5Utils.getFileMd5(new File(filePath+cDate+name));
|
||||
if (StringUtils.isBlank(docFileMd5)) {
|
||||
// throw new DocumentException(ErrorCodeEnum.DOC_FILE_MD5_ERROR);
|
||||
}
|
||||
String pathShortMd5 = Md5Utils.md5(filePath + name);
|
||||
String nameShortMd5 = Md5Utils.md5(name);
|
||||
Hashids hashids = new Hashids(DocumentConstants.HASH_KEY);
|
||||
// (将路径字符串短md5值 + 名称字符串短md5值) ==> 再转成短id形式 ==> 作为文档的key(暂且认为是不会重复的)
|
||||
String key = hashids.encodeHex(String.format("%s%s%s", docFileMd5,pathShortMd5, nameShortMd5));
|
||||
map.put("key", key);
|
||||
map.put("userdata", "sample userdata");
|
||||
JSONObject obj = (JSONObject) new JSONParser().parse(FileUtil.editStatus(url, JSON.toJSONString(map)));
|
||||
// System.out.println("obj"+obj);
|
||||
return new ResponseEntity<Object>(obj, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理在线编辑文档的逻辑
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
/* 状态
|
||||
0 - no document with the key identifier could be found,
|
||||
1 - document is being edited,
|
||||
2 - document is ready for saving,
|
||||
3 - document saving error has occurred,
|
||||
4 - document is closed with no changes,
|
||||
6 - document is being edited, but the current document state is saved,
|
||||
7 - error has occurred while force saving the document.
|
||||
* */
|
||||
private void callBack(HttpServletRequest request, HttpServletResponse response, String cDate) throws IOException {
|
||||
PrintWriter writer = null;
|
||||
JSONObject jsonObj = null;
|
||||
// System.out.println("===saveeditedfile------------");
|
||||
try {
|
||||
writer = response.getWriter();
|
||||
Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
|
||||
String body = scanner.hasNext() ? scanner.next() : "";
|
||||
jsonObj = (JSONObject) new JSONParser().parse(body);
|
||||
// System.out.println(jsonObj);
|
||||
// System.out.println("===saveeditedfile:" + jsonObj.get("status"));
|
||||
if ((long) jsonObj.get("status") == 2) {
|
||||
FileUtil.callBackSaveDocument(jsonObj,filePath+cDate,request, response);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
/*
|
||||
* status = 1,我们给onlyoffice的服务返回{"error":"0"}的信息,这样onlyoffice会认为回调接口是没问题的,这样就可以在线编辑文档了,否则的话会弹出窗口说明
|
||||
* 在线编辑还没有关闭,前端有人下载文档时,强制保存最新内容 当status 是6时说明有人在编辑时下载文档
|
||||
* */
|
||||
// System.out.println(jsonObj.get("status"));
|
||||
if ((long) jsonObj.get("status") == 6) {
|
||||
//处理当文档正在编辑为关闭时,下载文档
|
||||
if (((String)jsonObj.get("userdata")).equals("sample userdata")){
|
||||
FileUtil.callBackSaveDocument(jsonObj,filePath+cDate,request, response);
|
||||
}
|
||||
|
||||
// System.out.println("====保存失败:");
|
||||
writer.write("{\"error\":1}");
|
||||
} else {
|
||||
//执行删除编辑时下载保存的文件:
|
||||
FileUtil.deleteTempFile(filePath+cDate,request.getParameter("fileName"));
|
||||
writer.write("{\"error\":0}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//下面是暂时没用到的接口留着
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件编辑")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:create')")
|
||||
public CommonResult<Integer> createonlyof(@Valid @RequestBody onlyofSaveReqVO createReqVO) {
|
||||
return success(onlyofService.createonlyof(createReqVO));
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除文件编辑")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:delete')")
|
||||
public CommonResult<Boolean> deleteonlyof(@RequestParam("id") Integer id) {
|
||||
onlyofService.deleteonlyof(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得文件编辑")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:query')")
|
||||
public CommonResult<onlyofRespVO> getonlyof(@RequestParam("id") Integer id) {
|
||||
onlyofDO onlyof = onlyofService.getonlyof(id);
|
||||
return success(BeanUtils.toBean(onlyof, onlyofRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出文件编辑 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('only:onlyof:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportonlyofExcel(@Valid onlyofPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<onlyofDO> list = onlyofService.getonlyofPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "文件编辑.xls", "数据", onlyofRespVO.class,
|
||||
BeanUtils.toBean(list, onlyofRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.only.controller.admin.only.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 文件编辑分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class onlyofPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "文件名", example = "芋艿")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "文件路径")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] uploadDate;
|
||||
|
||||
@Schema(description = "知识状态(0正常 1停用)", example = "1")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.only.controller.admin.only.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文件编辑 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class onlyofRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32318")
|
||||
@ExcelProperty("id")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "文件名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@ExcelProperty("文件名")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "文件大小")
|
||||
@ExcelProperty("文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
@ExcelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("文件路径")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime uploadDate;
|
||||
|
||||
@Schema(description = "知识状态(0正常 1停用)", example = "1")
|
||||
@ExcelProperty("知识状态(0正常 1停用)")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.yudao.module.only.controller.admin.only.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 文件编辑新增/修改 Request VO")
|
||||
@Data
|
||||
public class onlyofSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "32318")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "文件名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||
@NotEmpty(message = "文件名不能为空")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "文件路径不能为空")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime uploadDate;
|
||||
|
||||
@Schema(description = "知识状态(0正常 1停用)", example = "1")
|
||||
private String status;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package cn.iocoder.yudao.module.only.dal.dataobject.only;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 文件编辑 DO
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@TableName("file_info")
|
||||
@KeySequence("file_info_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class onlyofDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Long fileSize;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
private String filePath;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime uploadDate;
|
||||
/**
|
||||
* 知识状态(0正常 1停用)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.only.dal.mysql.only;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofPageReqVO;
|
||||
import cn.iocoder.yudao.module.only.dal.dataobject.only.onlyofDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 文件编辑 Mapper
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Mapper
|
||||
public interface onlyofMapper extends BaseMapperX<onlyofDO> {
|
||||
|
||||
default PageResult<onlyofDO> selectPage(onlyofPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<onlyofDO>()
|
||||
.eqIfPresent(onlyofDO::getFileName, reqVO.getFileName())
|
||||
.eqIfPresent(onlyofDO::getFileSize, reqVO.getFileSize())
|
||||
.eqIfPresent(onlyofDO::getFileType, reqVO.getFileType())
|
||||
.eqIfPresent(onlyofDO::getFilePath, reqVO.getFilePath())
|
||||
.betweenIfPresent(onlyofDO::getUploadDate, reqVO.getUploadDate())
|
||||
.eqIfPresent(onlyofDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(onlyofDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(onlyofDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.only.service.only;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofPageReqVO;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofSaveReqVO;
|
||||
import cn.iocoder.yudao.module.only.dal.dataobject.only.onlyofDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 文件编辑 Service 接口
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
public interface onlyofService {
|
||||
|
||||
/**
|
||||
* 创建文件编辑
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createonlyof(@Valid onlyofSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新文件编辑
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateonlyof(@Valid onlyofSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除文件编辑
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteonlyof(Integer id);
|
||||
|
||||
/**
|
||||
* 获得文件编辑
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 文件编辑
|
||||
*/
|
||||
onlyofDO getonlyof(Integer id);
|
||||
|
||||
/**
|
||||
* 获得文件编辑分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 文件编辑分页
|
||||
*/
|
||||
PageResult<onlyofDO> getonlyofPage(onlyofPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.only.service.only;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofPageReqVO;
|
||||
import cn.iocoder.yudao.module.only.controller.admin.only.vo.onlyofSaveReqVO;
|
||||
import cn.iocoder.yudao.module.only.dal.dataobject.only.onlyofDO;
|
||||
import cn.iocoder.yudao.module.only.dal.mysql.only.onlyofMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.ONLYOF_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 文件编辑 Service 实现类
|
||||
*
|
||||
* @author 君风
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class onlyofServiceImpl implements onlyofService {
|
||||
|
||||
@Resource
|
||||
private onlyofMapper onlyofMapper;
|
||||
|
||||
@Override
|
||||
public Integer createonlyof(onlyofSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
onlyofDO onlyof = BeanUtils.toBean(createReqVO, onlyofDO.class);
|
||||
onlyofMapper.insert(onlyof);
|
||||
// 返回
|
||||
return onlyof.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateonlyof(onlyofSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateonlyofExists(updateReqVO.getId());
|
||||
// 更新
|
||||
onlyofDO updateObj = BeanUtils.toBean(updateReqVO, onlyofDO.class);
|
||||
onlyofMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteonlyof(Integer id) {
|
||||
// 校验存在
|
||||
validateonlyofExists(id);
|
||||
// 删除
|
||||
onlyofMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateonlyofExists(Integer id) {
|
||||
if (onlyofMapper.selectById(id) == null) {
|
||||
throw exception(ONLYOF_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public onlyofDO getonlyof(Integer id) {
|
||||
return onlyofMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<onlyofDO> getonlyofPage(onlyofPageReqVO pageReqVO) {
|
||||
return onlyofMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.only.dal.mysql.only.onlyofMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.star2.Star2Mapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.bpm.dal.mysql.tbup.TbupMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,26 @@
|
||||
html {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
color: #333;
|
||||
font-family: Arial, Tahoma, sans-serif;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow-y: hidden;
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.form {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
div {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
var Editor = function () {
|
||||
var docEditor;
|
||||
|
||||
var innerAlert = function (message) {
|
||||
if (console && console.log)
|
||||
console.log(message);
|
||||
};
|
||||
|
||||
var onAppReady = function () {
|
||||
innerAlert("文档编辑已就绪~");
|
||||
};
|
||||
|
||||
var onDocumentStateChange = function (event) {
|
||||
var title = document.title.replace(/\*$/g, "");
|
||||
document.title = title + (event.data ? "*" : "");
|
||||
};
|
||||
|
||||
var onError = function (event) {
|
||||
if (event) {
|
||||
innerAlert(event.data);
|
||||
}
|
||||
};
|
||||
|
||||
var onOutdatedVersion = function (event) {
|
||||
//TODO
|
||||
location.reload(true);
|
||||
};
|
||||
var onAppReady = function() {
|
||||
console.log("ONLYOFFICE Document Editor is ready");
|
||||
};
|
||||
var onCollaborativeChanges = function () {
|
||||
console.log("The document changed by collaborative user");
|
||||
};
|
||||
var onDocumentReady = function() {
|
||||
console.log("Document is loaded");
|
||||
};
|
||||
var onDocumentStateChange = function (event) {
|
||||
if (event.data) {
|
||||
console.log("The document changed");
|
||||
// docEditor.downloadAs();
|
||||
} else {
|
||||
console.log("Changes are collected on document editing service");
|
||||
//
|
||||
}
|
||||
};
|
||||
var onDownloadAs = function (event) {
|
||||
console.log("ONLYOFFICE Document Editor create file: " + event.data);
|
||||
window.top.postMessage(event.data);
|
||||
createAndDownloadFile("test.docx",event.data)
|
||||
};
|
||||
window.addEventListener('message',function(e){
|
||||
console.log(e.data)
|
||||
if (e.data=="downloadAs") {
|
||||
docEditor.downloadAs();
|
||||
}
|
||||
},false)
|
||||
|
||||
$("#insertImage").click(function(event) {
|
||||
console.log("ONLYOFFICE Document Editor insertImage: "+ event.data);
|
||||
docEditor.insertImage({
|
||||
"fileType": "png",
|
||||
"url": "http://192.168.0.58:20056/attachment/20190728测试上传文件名修改/2020January/1580363537940306800_small.png"
|
||||
});
|
||||
})
|
||||
|
||||
var onRequestInsertImage = function(event) {
|
||||
console.log("ONLYOFFICE Document Editor insertImage" + event.data);
|
||||
docEditor.insertImage({
|
||||
"fileType": "png",
|
||||
"url": "http://192.168.0.58:20056/attachment/20190728测试上传文件名修改/2020January/1580363537940306800_small.png"
|
||||
});
|
||||
};
|
||||
|
||||
var onError = function (event) {
|
||||
console.log("ONLYOFFICE Document Editor reports an error: code " + event.data.errorCode + ", description " + event.data.errorDescription);
|
||||
};
|
||||
var onOutdatedVersion = function () {
|
||||
location.reload(true);
|
||||
};
|
||||
var onRequestEditRights = function () {
|
||||
console.log("ONLYOFFICE Document Editor requests editing rights");
|
||||
// document.location.reload();
|
||||
var he=location.href.replace("view","edit");
|
||||
location.href=he;
|
||||
};
|
||||
|
||||
//历史版本保留1个月。比如Unix时间戳(Unix timestamp)expires=1524547423
|
||||
var onRequestHistory = function() {
|
||||
};
|
||||
|
||||
var onRequestHistoryClose = function() {
|
||||
document.location.reload();
|
||||
};
|
||||
var getUrlParam = function (name) {
|
||||
//构造一个含有目标参数的正则表达式对象
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||||
//匹配目标参数
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
//返回参数值
|
||||
if (r != null) {
|
||||
return decodeURI(r[2]);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
var getDocumentConfig = function (document) {
|
||||
if (document) {
|
||||
return {
|
||||
"document": document
|
||||
};
|
||||
}
|
||||
innerAlert("文档未指定!");
|
||||
return null;
|
||||
};
|
||||
var onRequestHistoryData = function() {}
|
||||
var сonnectEditor = function (document, documentEditParam) {
|
||||
|
||||
var config = getDocumentConfig(document);
|
||||
console.log(document)
|
||||
console.log(documentEditParam)
|
||||
config.width = "100%";
|
||||
config.height = "100%";
|
||||
config.events = {
|
||||
"onAppReady": onAppReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
"onError": onError,
|
||||
"onOutdatedVersion": onOutdatedVersion
|
||||
};
|
||||
//config.documentType = ""+document.fileType
|
||||
config.editorConfig = {
|
||||
"lang": "zh-CN",
|
||||
"mode": "edit",
|
||||
"recent": [],
|
||||
// 自定义一些配置
|
||||
"customization": {
|
||||
"chat": true, // 禁用聊天菜单按钮
|
||||
"commentAuthorOnly": false, // 仅能编辑和删除其注释
|
||||
"comments": false, // 隐藏文档注释菜单按钮
|
||||
"compactHeader": false, // 隐藏附加操作按钮
|
||||
"compactToolbar": false, // 完整工具栏(true代表紧凑工具栏)
|
||||
"feedback": {
|
||||
"visible": true // 隐藏反馈按钮
|
||||
},
|
||||
"forcesave": false, // true 表示强制文件保存请求添加到回调处理程序
|
||||
"goback": false,/*{
|
||||
"blank": true, // 转到文档时,在新窗口打开网站(false表示当前窗口打开)
|
||||
"text": "转到文档位置(可以考虑放文档打开源页面)",
|
||||
// 文档打开失败时的跳转也是该地址
|
||||
"url": "http://www.lezhixing.com.cn"
|
||||
},*/
|
||||
"help": false, // 隐藏帮助按钮
|
||||
"hideRightMenu": false, // 首次加载时隐藏右侧菜单(true 为显示)
|
||||
"showReviewChanges": false, // 加载编辑器时自动显示/隐藏审阅更改面板(true显示 false隐藏)
|
||||
"toolbarNoTabs": false, // 清楚地显示顶部工具栏选项卡(true 代表仅突出显示以查看选择了哪一个)
|
||||
"zoom": 100 // 定义文档显示缩放百分比值
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
$.extend(config.editorConfig, documentEditParam);
|
||||
console.log(config)
|
||||
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor",config);
|
||||
};
|
||||
|
||||
return {
|
||||
init: function (document, documentEditParam) {
|
||||
console.log("-----сonnectEditor-----")
|
||||
сonnectEditor(document, documentEditParam);
|
||||
}
|
||||
}
|
||||
}();
|
9440
yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/static/js/jquery-1.8.2.js
vendored
Normal file
9440
yudao-module-bpm/yudao-module-bpm-biz/src/main/resources/static/js/jquery-1.8.2.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">
|
||||
<head>
|
||||
<title th:text="${document.title}"></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/css/viewer.css}">
|
||||
</head>
|
||||
<!--//整个文件就是前端打开的编辑窗口的配置-->
|
||||
<body>
|
||||
<div class="form">
|
||||
<div id="iframeEditor"></div>
|
||||
<h1 th:text="${document.title}">Document Title</h1>
|
||||
<pre th:text="${documentEditParam}">Document Edit Param</pre>
|
||||
</div>
|
||||
<script type="text/javascript" th:src="@{/js/jquery-1.8.2.js}"></script>
|
||||
<script type="text/javascript" th:src="@{${documentServerApiJs}}"></script>
|
||||
<script type="text/javascript" th:src="@{/js/editor.js}"></script>
|
||||
<!-- 先通过 th:inline=“javascript” 添加到标签,这样js代码即可访问model中的属性 -->
|
||||
<script th:inline="javascript">
|
||||
// js 中可以通过“[[${xxx}]]” 格式获得实际的值
|
||||
Editor.init([[${document}]], [[${documentEditParam}]]);
|
||||
</script>
|
||||
<!-- <script type="text/javascript" src="http://192.168.1.15:7878/web-apps/apps/api/documents/api.js"></script>-->
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user