|
|
|
|
@ -2,24 +2,29 @@ package com.platform.controller;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
import com.base.BaseController;
|
|
|
|
|
import com.platform.entities.MyFilesEntity;
|
|
|
|
|
import com.platform.entities.PreDataInfo;
|
|
|
|
|
import com.platform.form.ScriptForm;
|
|
|
|
|
import com.platform.service.IScriptMakeService;
|
|
|
|
|
import com.platform.utils.Configs;
|
|
|
|
|
import com.platform.utils.ZipCompressUtils;
|
|
|
|
|
@ -28,12 +33,16 @@ import com.platform.utils.ZipCompressUtils;
|
|
|
|
|
@RequestMapping("/filePackage")
|
|
|
|
|
public class FilePackageController extends BaseController {
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("static-access")
|
|
|
|
|
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(FilePackageController.class);
|
|
|
|
|
|
|
|
|
|
@Resource(name = "scriptMakeService")
|
|
|
|
|
private IScriptMakeService scriptMakeService;
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/download")
|
|
|
|
|
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
|
|
|
|
HttpServletResponse response) throws Exception {
|
|
|
|
|
log.info("---------/download--- ");
|
|
|
|
|
scriptMakeService.makeCfg();
|
|
|
|
|
scriptMakeService.makeXml();
|
|
|
|
|
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
|
|
|
|
@ -61,10 +70,40 @@ public class FilePackageController extends BaseController {
|
|
|
|
|
@ResponseBody
|
|
|
|
|
@RequestMapping("/findAll")
|
|
|
|
|
public ModelMap findAll() throws Exception {
|
|
|
|
|
log.info("---------/findAll--- ");
|
|
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
|
|
List<MyFilesEntity> result = scriptMakeService.FindAllFiles();
|
|
|
|
|
modelMap.addAttribute("data", result);
|
|
|
|
|
modelMap.addAttribute("length", result.size());
|
|
|
|
|
return modelMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/readSqlFile", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public Object getSqlFile(/*@PathVariable*/@RequestParam("type") String type, @RequestBody MyFilesEntity data,
|
|
|
|
|
HttpServletRequest res, HttpServletResponse req) throws Exception {
|
|
|
|
|
log.info("---------/readSqlFile------------------");
|
|
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
|
|
Map<String, Object> result = scriptMakeService.readSql(type, data);
|
|
|
|
|
// StringBuilder sb = new StringBuilder();
|
|
|
|
|
// sb.append("查看相应日志").append("\n").append("看到了");
|
|
|
|
|
// modelMap.addAttribute("data1", result.get("data1").toString());
|
|
|
|
|
// modelMap.addAttribute("data2", result.get("data2").toString());
|
|
|
|
|
modelMap.addAllAttributes(result);
|
|
|
|
|
return modelMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/handleSqlFile", method = RequestMethod.POST)
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public ModelMap handleSqlFile(@RequestParam("type") String type, @RequestParam("opt") String opt, @RequestBody ScriptForm form,
|
|
|
|
|
HttpServletRequest req, HttpServletResponse res) throws Exception {
|
|
|
|
|
log.info("---------/handleSqlFile--- " + type +" "+ opt + " ");
|
|
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
|
|
Map<String, Object> result = scriptMakeService.handleSqlFile(type, opt, form.getContent(), form.getItem());
|
|
|
|
|
modelMap.addAllAttributes(result);
|
|
|
|
|
List<MyFilesEntity> results = scriptMakeService.FindAllFiles();
|
|
|
|
|
modelMap.addAttribute("data", results);
|
|
|
|
|
modelMap.addAttribute("length", results.size());
|
|
|
|
|
return modelMap;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|