attachment修复
This commit is contained in:
parent
f1477eb60d
commit
eda0e41b53
@ -7,17 +7,17 @@ import com.lovenav.service.ConfigService;
|
|||||||
import org.apache.catalina.core.ApplicationContext;
|
import org.apache.catalina.core.ApplicationContext;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.context.support.ServletContextResource;
|
import org.springframework.web.context.support.ServletContextResource;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -30,20 +30,30 @@ public class AttachmentController {
|
|||||||
AttachmentService attachmentService;
|
AttachmentService attachmentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
ConfigService configService;
|
ConfigService configService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//上传附件
|
//上传附件
|
||||||
@RequestMapping("/uploadfile")
|
@RequestMapping(value = "/uploadfile",method = RequestMethod.POST)
|
||||||
public HashMap<String, String> uploadFile(MultipartFile multipartFile,String cate,Config config) throws IOException {//@RequestPart("photos") MultipartFile multipartFile
|
public HashMap<String, String> uploadFile(MultipartFile multipartFile, String cate, Config config) throws IOException {//@RequestPart("photos") MultipartFile multipartFile
|
||||||
HashMap<String,String> map=new HashMap<>();
|
HashMap<String,String> map=new HashMap<>();
|
||||||
Long id=null;
|
|
||||||
if (multipartFile==null){
|
if (multipartFile==null){
|
||||||
map.put("msg","文件不能为空!");
|
map.put("msg","文件不能为空!");
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
out.println(multipartFile.getOriginalFilename());
|
Config config1=configService.selectAlreadyExist(config);
|
||||||
map=attachmentService.upload(multipartFile,cate,id);
|
if (config1==null){
|
||||||
config.setValue(map.get("id"));
|
map=attachmentService.upload(multipartFile,cate);
|
||||||
config.setType("image");
|
// out.println(map.get("id"));
|
||||||
map.put("msg",configService.addConfig(config));
|
config.setValue(map.get("id"));
|
||||||
|
config.setType("image");
|
||||||
|
map.put("msg",configService.addConfig(config));
|
||||||
|
}else {
|
||||||
|
out.println(config1.getValue());
|
||||||
|
configService.updateConfig(config1);
|
||||||
|
map=attachmentService.updateFile(multipartFile,cate,config1);
|
||||||
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user