|
|
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
+import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.onlyoffice.integration.documentserver.callbacks.CallbackHandler;
|
|
|
import com.onlyoffice.integration.documentserver.managers.callback.CallbackManager;
|
|
|
@@ -114,6 +115,9 @@ public class FileController {
|
|
|
@Autowired
|
|
|
private FileConfigurer<DefaultFileWrapper> fileConfigurer;
|
|
|
|
|
|
+ @javax.annotation.Resource
|
|
|
+ private ICommonDao<?> commonDao;
|
|
|
+
|
|
|
// create user metadata
|
|
|
private String createUserMetadata(final User user, final String fullFileName) {
|
|
|
String documentType = fileUtility.getDocumentType(fullFileName).toString().toLowerCase(); // get document type
|
|
|
@@ -327,12 +331,24 @@ public class FileController {
|
|
|
@GetMapping(path = "${url.editor}")
|
|
|
@ResponseBody
|
|
|
// process request to open the editor page
|
|
|
- public String editor(@RequestParam("fileName") final String fileName,
|
|
|
+ public String editor(@RequestParam(value = "fileName", required = false) String fileName,
|
|
|
@RequestParam(value = "action", required = false) final String actionParam,
|
|
|
@RequestParam(value = "type", required = false) final String typeParam,
|
|
|
@RequestParam(value = "actionLink", required = false) final String actionLink,
|
|
|
- @RequestParam(value = "directUrl", required = false,
|
|
|
- defaultValue = "false") final Boolean directUrl) throws JsonProcessingException {
|
|
|
+ @RequestParam(value = "directUrl", required = false, defaultValue = "false") final Boolean directUrl,
|
|
|
+ @RequestParam(value = "fileId", required = false) final String fileId) throws JsonProcessingException {
|
|
|
+ String title = fileName;
|
|
|
+ if(StringUtils.isNotBlank(fileId)){
|
|
|
+ String sql ="SELECT cun_fang_lu_jing_,biao_dan_ming_che FROM t_bdmbtxjl WHERE id_='%s'";
|
|
|
+ Map<String, Object> objectMap = commonDao.queryOne(String.format(sql, fileId));
|
|
|
+ fileName = (String)objectMap.get("cun_fang_lu_jing_");
|
|
|
+ if(StringUtils.isEmpty(fileName)) return "{\"error\":\"Template ID is incorrect\"}";
|
|
|
+ title = (String)objectMap.get("biao_dan_ming_che");
|
|
|
+ }else if (StringUtils.isBlank(fileName)){
|
|
|
+ return "{\"error\":\"File Name is incorrect\"}";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
com.onlyoffice.integration.documentserver.models.enums.Action action = com.onlyoffice.integration.documentserver.models.enums.Action.edit;
|
|
|
Type type = Type.desktop;
|
|
|
Locale locale = Locale.CHINA;
|
|
|
@@ -355,6 +371,7 @@ public class FileController {
|
|
|
.user(userService.getUser())
|
|
|
.actionData(actionLink)
|
|
|
.isEnableDirectUrl(directUrl)
|
|
|
+ .title(title)
|
|
|
.build()
|
|
|
);
|
|
|
|
|
|
@@ -362,8 +379,23 @@ public class FileController {
|
|
|
}
|
|
|
@GetMapping("/create")
|
|
|
@ResponseBody
|
|
|
- public String create(@RequestParam("templateName") final String templateName,
|
|
|
- @RequestParam("fileName") final String fileName) throws JsonProcessingException {
|
|
|
+ public String create(@RequestParam(value = "templateName", required = false) String templateName,
|
|
|
+ @RequestParam(value = "fileName", required = false) String fileName,
|
|
|
+ @RequestParam(value = "templateId", required = false) final String templateId) throws JsonProcessingException {
|
|
|
+ String title = fileName;
|
|
|
+ if(StringUtils.isNotBlank(templateId)){
|
|
|
+ String sql ="SELECT cun_fang_lu_jing_,biao_dan_ming_che FROM t_bdmbpzb WHERE id_='%s'";
|
|
|
+ Map<String, Object> objectMap = commonDao.queryOne(String.format(sql, templateId));
|
|
|
+ templateName = (String)objectMap.get("cun_fang_lu_jing_");
|
|
|
+ if(StringUtils.isEmpty(templateName)) return "{\"error\":\"Template ID is incorrect\"}";
|
|
|
+ String fileExtension = fileUtility.getFileExtension(templateName).toString().toLowerCase();
|
|
|
+ SimpleDateFormat df = new SimpleDateFormat("/yyyy/MMddHHmmss");//设置日期格式
|
|
|
+ String date = df.format(new Date());
|
|
|
+ title = (String)objectMap.get("biao_dan_ming_che");
|
|
|
+ fileName = "/records/"+templateId+date+"."+fileExtension;
|
|
|
+ }else if (StringUtils.isBlank(templateName) || StringUtils.isBlank(fileName)){
|
|
|
+ return "{\"error\":\"Template Name or File Name is incorrect\"}";
|
|
|
+ }
|
|
|
|
|
|
User user = userService.getUser();
|
|
|
try {
|
|
|
@@ -393,6 +425,7 @@ public class FileController {
|
|
|
.action(action)
|
|
|
.user(user)
|
|
|
.isEnableDirectUrl(false)
|
|
|
+ .title(title)
|
|
|
.build()
|
|
|
);
|
|
|
|