update onlyoffice部署修改配置
This commit is contained in:
@@ -73,7 +73,7 @@ public class CorsFilter implements Filter {
|
||||
|
||||
private void responseInfo(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", originIp);
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST,GET");
|
||||
httpServletResponse.setHeader("Access-Control-Max-Age", "3600");
|
||||
|
||||
+83
-8
@@ -1,15 +1,22 @@
|
||||
package com.jero.modules.onlyoffice.controller;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.util.CommonUtils;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.onlyoffice.entity.BusProcessModelHis;
|
||||
import com.jero.modules.onlyoffice.entity.OnlineFileLog;
|
||||
import com.jero.modules.onlyoffice.mapper.BusProcessModelHisMapper;
|
||||
import com.jero.modules.onlyoffice.service.IBusProcessModelHisService;
|
||||
import com.jero.modules.onlyoffice.service.LawsUserInfoService;
|
||||
import com.jero.modules.oss.entity.OSSFile;
|
||||
import com.jero.modules.oss.service.IOSSFileService;
|
||||
import com.jero.modules.system.entity.SysLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -20,7 +27,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
@@ -55,9 +65,15 @@ public class BusProcessModelHisController {
|
||||
@Autowired
|
||||
private LawsUserInfoService lawsUserInfoService;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
private BusProcessModelHisMapper busProcessModelHisMapper;
|
||||
|
||||
@Resource
|
||||
private IOSSFileService ossFileService;
|
||||
/**
|
||||
* 文件后缀黑名单
|
||||
*/
|
||||
@Value(value="${jero.fileSuffixLimits}")
|
||||
private String[] fileSuffixLimits;
|
||||
@ApiOperation(value = "分页查询")
|
||||
@GetMapping("/pageList")
|
||||
public Result<IPage<BusProcessModelHis>> pageList(HttpServletRequest req, BusProcessModelHis processModelHis,
|
||||
@@ -104,7 +120,7 @@ public class BusProcessModelHisController {
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFile")
|
||||
public void recieveFile(HttpServletRequest request, HttpServletResponse response, String fileNm, String standNo, String fileId,String standName,String key){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
logger.info("**********进入recieveFile接收文档接口************");
|
||||
logger.info("**********fileNm************"+fileNm+"=======");
|
||||
logger.info("**********standNo************"+standNo+"=======");
|
||||
logger.info("**********fileId************"+fileId+"=======");
|
||||
@@ -140,13 +156,19 @@ public class BusProcessModelHisController {
|
||||
try {
|
||||
logger.info("**********onlyoffice接收文档接口获得downloadUri************" + downloadUri);
|
||||
if (StringUtils.isNotEmpty(downloadUri)) {
|
||||
downloadUri = downloadUri.replace("laws.sinotruk.com","onlyoffice-sa2of.yf-grp:8080");
|
||||
downloadUri = downloadUri.replace("onlyoffice.sinotruk.com","onlyoffice-sa2of.yf-grp:8080");
|
||||
BusProcessModelHis modelHis = busProcessModelHisService.getById(fileId);
|
||||
String editFilePath = modelHis.getEditFilePath();
|
||||
StringBuilder builder=new StringBuilder();
|
||||
builder.append(standEditFilePath);
|
||||
builder.append(standNo).append("/");
|
||||
builder.append(fileNm);
|
||||
builder.append(editFilePath);
|
||||
String saveFileUrl = builder.toString();
|
||||
File file = new File(saveFileUrl);
|
||||
downloadNetFile(downloadUri, file);
|
||||
logger.info("**********onlyoffice文档下载路径************" + downloadUri);
|
||||
logger.info("**********onlyoffice文档保存本地路径************" + saveFileUrl);
|
||||
HttpUtil.downloadFileFromUrl(downloadUri,saveFileUrl);
|
||||
//File file = new File(saveFileUrl);
|
||||
//downloadNetFile(downloadUri, file);
|
||||
// 更新在线编辑当前节点编辑状态
|
||||
busProcessModelHisService.modelHisOneUpdStatusById(fileId);
|
||||
Object keyObj = jsonObj.get("key");
|
||||
@@ -179,7 +201,7 @@ public class BusProcessModelHisController {
|
||||
@ApiOperation(value = "|onlyOffice接收文件")
|
||||
@PostMapping("/recieveFileBefore")
|
||||
public void recieveFileBefore(HttpServletRequest request, HttpServletResponse response,String key, String fileNm, String standNo, String pid, String taskId ,String standName){
|
||||
logger.info("**********进入onlyoffice接收文档接口************");
|
||||
logger.info("**********进入recieveFileBefore接收文档接口************");
|
||||
logger.info("**********fileNm************"+fileNm+"=======");
|
||||
logger.info("**********standNo************"+standNo+"=======");
|
||||
logger.info("**********pid************"+pid+"=======");
|
||||
@@ -325,7 +347,60 @@ public class BusProcessModelHisController {
|
||||
return busProcessModelHisService.selectOnlineFile(onlineFileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传统一方法
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/upload")
|
||||
@CrossOrigin(origins = "*", maxAge = 3600)
|
||||
public Result<OSSFile> upload(HttpServletRequest request, HttpServletResponse response) {
|
||||
Result<OSSFile> result = new Result<>();
|
||||
String savePath = "";
|
||||
String bizPath = request.getParameter("biz");
|
||||
|
||||
//sys/common/upload接口存在任意文件上传漏洞
|
||||
if (oConvertUtils.isNotEmpty(bizPath) && (bizPath.contains("../") || bizPath.contains("..\\"))) {
|
||||
throw new JeroBootException("上传目录bizPath,格式非法!");
|
||||
}
|
||||
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
// 获取上传文件对象
|
||||
MultipartFile file = multipartRequest.getFile("file");
|
||||
if(file==null) {
|
||||
return result;
|
||||
}
|
||||
// 文件类型是否处于黑名单
|
||||
if(CommonUtils.limitFileSuffix(file.getOriginalFilename(),fileSuffixLimits)){
|
||||
result.setMessage("该文件类型不允许上传");
|
||||
result.setSuccess(false);
|
||||
result.setCode(0);
|
||||
return result;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(bizPath)){
|
||||
bizPath = "";
|
||||
}
|
||||
// 本地上传
|
||||
savePath = CommonUtils.uploadLocal(file,bizPath,standEditFilePath);
|
||||
if(oConvertUtils.isNotEmpty(savePath)){
|
||||
//上传成功 进行数据库存储
|
||||
OSSFile ossFile = new OSSFile();
|
||||
// 文件名
|
||||
String fileName = file.getOriginalFilename();
|
||||
fileName = CommonUtils.getFileName(fileName);
|
||||
ossFile.setFileName(fileName);
|
||||
ossFile.setUrl(savePath);
|
||||
ossFileService.save(ossFile);
|
||||
result.setMessage(savePath);
|
||||
result.setResult(ossFile);
|
||||
result.setSuccess(true);
|
||||
}else {
|
||||
result.setMessage("上传失败!");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -62,11 +62,14 @@ public class LawsUserInfoService {
|
||||
try {
|
||||
file = new File(path+onlineFileLog.getOldFileName());
|
||||
boolean directory = file.isDirectory();
|
||||
log.info("**********path+onlineFileLog.getOldFileName()本地路径************" + path+onlineFileLog.getOldFileName());
|
||||
//目录是否存在
|
||||
if(!directory){
|
||||
file.mkdirs();
|
||||
}
|
||||
file = new File(path+"/"+onlineFileLog.getOldFileName(),onlineFileLog.getOldFileName()+"."+onlineFileLog.getFileSuffix());
|
||||
log.info("**********parent路径************" + path+"/"+onlineFileLog.getOldFileName());
|
||||
log.info("**********child路径************" + onlineFileLog.getOldFileName()+"."+onlineFileLog.getFileSuffix());
|
||||
fileOutputStream = new FileOutputStream(file);
|
||||
bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
|
||||
fileOutputStream.write(onlineFileLog.getBytes());
|
||||
@@ -99,7 +102,7 @@ public class LawsUserInfoService {
|
||||
onlineFileLog.setValidFlag("0");
|
||||
onlineFileLog.setFileKey(key);
|
||||
onlineFileLogDao.insert(onlineFileLog);
|
||||
log.info("======================日志存入成功==============================="+onlineFileLog.toString());
|
||||
log.info("======================日志存入成功===============================");
|
||||
if(StringUtils.isNotBlank(standName)) {
|
||||
AttFileEO attFileEO = new AttFileEO();
|
||||
attFileEO.setId(attFileVo.getId());
|
||||
@@ -114,7 +117,7 @@ public class LawsUserInfoService {
|
||||
if(fileTOW.delete()){
|
||||
File fileInfo = new File(path);
|
||||
if(fileInfo.delete()){
|
||||
log.info("======================桥梁文件删除成功===============================");
|
||||
log.info("======================桥梁文件删除成功==============================="+path+onlineFileLog.getOldFileName());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
|
||||
@@ -189,11 +189,11 @@ mybatis-plus:
|
||||
id-type: ASSIGN_ID
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
configuration:
|
||||
# configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 返回类型为Map,显示null对应的字段
|
||||
call-setters-on-nulls: true
|
||||
# call-setters-on-nulls: true
|
||||
#jero专用配置
|
||||
jero:
|
||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
|
||||
Reference in New Issue
Block a user