edit
This commit is contained in:
@@ -28,78 +28,85 @@ import lingtao.net.service.BugService;
|
||||
@RestController
|
||||
public class BugController {
|
||||
|
||||
@Autowired
|
||||
private BugService bugService;
|
||||
@Autowired
|
||||
private BugService bugService;
|
||||
|
||||
private String localPrefix = "abc\\bug";
|
||||
private String localPrefix = "abc\\bug";
|
||||
|
||||
private String localPath = "C:\\lingtao\\quote_price\\upload";
|
||||
private String localPath = "C:\\lingtao\\quote_price\\upload";
|
||||
|
||||
//private String localDomain = "http://47.114.150.226:8080/erp";
|
||||
//private String localDomain = "http://47.114.150.226:8080/erp";
|
||||
|
||||
/**
|
||||
* bug列表
|
||||
*
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBugs")
|
||||
public PageInfo<Bug> getBugs(@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Bug bug) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Bug> bugList = bugService.getBugs(bug);
|
||||
PageInfo<Bug> pageInfo = new PageInfo<Bug>(bugList);
|
||||
return pageInfo;
|
||||
}
|
||||
/**
|
||||
* bug列表
|
||||
*
|
||||
* @param page
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/getBugs")
|
||||
public PageInfo<Bug> getBugs(@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") Integer limit, Bug bug) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Bug> bugList = bugService.getBugs(bug);
|
||||
PageInfo<Bug> pageInfo = new PageInfo<Bug>(bugList);
|
||||
return pageInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加角色
|
||||
*/
|
||||
@RequestMapping("/addBug")
|
||||
public Msg addBug(Bug bug, HttpSession session) {
|
||||
return bugService.addBug(bug, session);
|
||||
}
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
@RequestMapping("/addBug")
|
||||
public Msg addBug(Bug bug, HttpSession session) {
|
||||
return bugService.addBug(bug, session);
|
||||
}
|
||||
|
||||
// 图片上传及新增
|
||||
@RequestMapping("/bugUpload")
|
||||
public Msg upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
return Msg.fail("文件不能为空");
|
||||
}
|
||||
// 获取文件名后缀
|
||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
// 获取path
|
||||
String path = getPath(extension, FilenameUtils.getBaseName(file.getOriginalFilename()));
|
||||
// 保存文件信息
|
||||
File newFile = new File(localPath + File.separator + path);
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(new ByteArrayInputStream(file.getBytes()), newFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeErrorException(null, "");
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
@RequestMapping("/updateBug")
|
||||
public Msg updateBug(Bug bug, HttpSession session) {
|
||||
return bugService.updateBug(bug);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param prefixSelf 根据上传的接口存入自己的文件夹
|
||||
* @param suffix 文件的后缀
|
||||
* @param fileName 文件名
|
||||
* @return
|
||||
*/
|
||||
public String getPath(String suffix, String fileName) {
|
||||
// 图片上传及新增
|
||||
@RequestMapping("/bugUpload")
|
||||
public Msg upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
if (file.isEmpty()) {
|
||||
return Msg.fail("文件不能为空");
|
||||
}
|
||||
// 获取文件名后缀
|
||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||
// 获取path
|
||||
String path = getPath(extension, FilenameUtils.getBaseName(file.getOriginalFilename()));
|
||||
// 保存文件信息
|
||||
File newFile = new File(localPath + File.separator + path);
|
||||
try {
|
||||
FileUtils.copyInputStreamToFile(new ByteArrayInputStream(file.getBytes()), newFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeErrorException(null, "");
|
||||
}
|
||||
return Msg.success();
|
||||
}
|
||||
|
||||
// 生成uuid
|
||||
// String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
String path = null;
|
||||
/**
|
||||
* @param prefixSelf 根据上传的接口存入自己的文件夹
|
||||
* @param suffix 文件的后缀
|
||||
* @param fileName 文件名
|
||||
* @return
|
||||
*/
|
||||
public String getPath(String suffix, String fileName) {
|
||||
|
||||
// 文件路径
|
||||
path = DateUtils.formatDate(new Date(), "yyyyMMdd") + File.separator + fileName;
|
||||
// 生成uuid
|
||||
// String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
String path = null;
|
||||
|
||||
path = localPrefix + File.separator + File.separator + path;
|
||||
// 文件路径
|
||||
path = DateUtils.formatDate(new Date(), "yyyyMMdd") + File.separator + fileName;
|
||||
|
||||
return path + "." + suffix;
|
||||
}
|
||||
path = localPrefix + File.separator + File.separator + path;
|
||||
|
||||
return path + "." + suffix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user