公用
This commit is contained in:
@@ -4,14 +4,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
|
||||
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
|
||||
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.config.RuoYiConfig;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
@@ -34,6 +36,8 @@ public class CommonController
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
@Autowired
|
||||
private CaseAttachMapper caseAttachMapper;
|
||||
|
||||
private static final String FILE_DELIMETER = ",";
|
||||
|
||||
@@ -73,7 +77,7 @@ public class CommonController
|
||||
* 通用上传请求(单个)
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult uploadFile(MultipartFile file) throws Exception
|
||||
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("annexType") Integer annexType, @RequestParam("id") Long id) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -82,6 +86,7 @@ public class CommonController
|
||||
// 上传并返回新文件名称
|
||||
String fileName = FileUploadUtils.upload(filePath, file);
|
||||
String url = serverConfig.getUrl() + fileName;
|
||||
saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("url", url);
|
||||
ajax.put("fileName", fileName);
|
||||
@@ -95,11 +100,47 @@ public class CommonController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存到案件附件表
|
||||
* @param id
|
||||
* @param annexType
|
||||
* @param fileName
|
||||
* @param originalFilename
|
||||
*/
|
||||
private void saveCaseAttach(Long id, Integer annexType, String fileName, String originalFilename) {
|
||||
CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id)
|
||||
.annexName(originalFilename)
|
||||
.annexPath(fileName)
|
||||
.annexType(annexType)
|
||||
.userId(SecurityUtils.getUserId())
|
||||
.userName(SecurityUtils.getUsername())
|
||||
.build();
|
||||
caseAttachMapper.save(caseAttach);
|
||||
}
|
||||
/**
|
||||
* 根据案件id获取附件
|
||||
* @param caseAppliId
|
||||
* @param annexTypeList
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/fileList")
|
||||
public AjaxResult fileList(@RequestParam("caseAppliId")Long caseAppliId, @RequestParam(value = "annexTypeList",required = false) List<Integer> annexTypeList){
|
||||
if(caseAppliId==null){
|
||||
return AjaxResult.error("案件id不能为空");
|
||||
}
|
||||
CaseApplication caseApplication = new CaseApplication();
|
||||
caseApplication.setId(caseAppliId);
|
||||
caseApplication.setAnnexTypeList(annexTypeList);
|
||||
List<CaseAttach> caseAttachList = caseAttachMapper.queryCaseAttachList(caseApplication);
|
||||
return AjaxResult.success(caseAttachList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用上传请求(多个)
|
||||
*/
|
||||
@PostMapping("/uploads")
|
||||
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
|
||||
public AjaxResult uploadFiles(@RequestParam("files") MultipartFile[] files, @RequestParam("annexType")Integer annexType, @RequestParam("id")Long id ) throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -118,6 +159,7 @@ public class CommonController
|
||||
fileNames.add(fileName);
|
||||
newFileNames.add(FileUtils.getName(fileName));
|
||||
originalFilenames.add(file.getOriginalFilename());
|
||||
saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
|
||||
}
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.ruoyi.web.controller.wisdomarbitrate;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
|
||||
import com.ruoyi.wisdomarbitrate.domain.TemplateManual;
|
||||
import com.ruoyi.wisdomarbitrate.service.ITemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/template")
|
||||
public class TemplateController extends BaseController {
|
||||
@Autowired
|
||||
private ITemplateService templateService;
|
||||
/**
|
||||
* 新增模板
|
||||
* @param templateManual
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/insert")
|
||||
public AjaxResult insertTemplate(@RequestBody TemplateManual templateManual){
|
||||
return templateService.insertTemplate(templateManual);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模板
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/delete")
|
||||
public AjaxResult deleteTemplate(Long id){
|
||||
return templateService.deleteTemplate(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模板
|
||||
* @param templateManual
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult updateTemplate(@RequestBody TemplateManual templateManual){
|
||||
return templateService.updateTemplate(templateManual);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模板
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list( TemplateManual templateManual) {
|
||||
startPage();
|
||||
List<TemplateManual> list = templateService.selectTemplate(templateManual);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user