Kaynağa Gözat

[task-2605] 子 表单模板优化 / 【后端】修改相应接口参数

Li Yuan 1 yıl önce
ebeveyn
işleme
35e89a6cfd

+ 38 - 5
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/controllers/FileController.java

@@ -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()
         );
 

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultDocumentConfigurer.java

@@ -56,7 +56,7 @@ public class DefaultDocumentConfigurer implements DocumentConfigurer<DefaultDocu
         String fileName = wrapper.getFileName();  // get the fileName parameter from the document wrapper
         Permission permission = wrapper.getPermission();  // get the permission parameter from the document wrapper
 
-        document.setTitle(fileName);  // set the title to the document config
+        document.setTitle(wrapper.getTitle());  // set the title to the document config
 
         // set the URL to download a file to the document config
         document.setUrl(documentManager.getDownloadUrl(fileName, true));

+ 1 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultFileConfigurer.java

@@ -85,6 +85,7 @@ public class DefaultFileConfigurer implements FileConfigurer<DefaultFileWrapper>
 //                    .permission(updatePermissions(userPermissions, action, canEdit))
                     .favorite(wrapper.getUser().getFavorite())
                     .isEnableDirectUrl(wrapper.getIsEnableDirectUrl())
+                    .title(wrapper.getTitle())
                     .build();
 
             defaultDocumentConfigurer

+ 1 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultDocumentWrapper.java

@@ -31,4 +31,5 @@ public class DefaultDocumentWrapper {
     private Boolean favorite;
     private Boolean isEnableDirectUrl;
     private ReferenceData referenceData;
+    private String title;
 }

+ 1 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/onlyoffice/integration/services/configurers/wrappers/DefaultFileWrapper.java

@@ -37,4 +37,5 @@ public class DefaultFileWrapper {
     private String actionData;
     private Boolean canEdit;
     private Boolean isEnableDirectUrl;
+    private String title;
 }