单文件上传接口

master
382696293@qq.com 2 years ago
parent 3a913e2c72
commit 16b6e68044

@ -64,54 +64,22 @@ public class WxClockLogController extends BaseController {
return getDataTable(list);
}
/**
*
*/
@PostMapping("/upload")
public R insertClockLog(@RequestParam(value = "clockImg") MultipartFile clockImg) {
return remoteFileService.upload(clockImg);
}
/**
*
* 使
* firstClockImg
*/
@PostMapping("/insertClockLog")
public R insertClockLog(@RequestParam(value = "firstClockImg") MultipartFile firstClockImg,
@RequestParam(value = "secondClockImg") MultipartFile secondClockImg,
@RequestParam(value = "thirdClockImg") MultipartFile thirdClockImg,
@Validated WxClockLogReq wxClockLogReq) {
if (firstClockImg != null && StringUtils.isNotBlank(firstClockImg.getOriginalFilename())) {
R<SysFile> result = remoteFileService.upload(firstClockImg);
if (result.getCode() != Constants.SUCCESS) {
logger.error("上传打卡图片失败");
throw new ServiceException("上传打卡图片失败");
}
if (wxClockLogReq.getClockImageList() != null && wxClockLogReq.getClockImageList().size() > 0) {
wxClockLogReq.getClockImageList().set(0, result.getData().getUrl());
} else {
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
}
}
if (secondClockImg != null && StringUtils.isNotBlank(secondClockImg.getOriginalFilename())) {
R<SysFile> result = remoteFileService.upload(secondClockImg);
if (result.getCode() != Constants.SUCCESS) {
logger.error("上传打卡图片失败");
throw new ServiceException("上传打卡图片失败");
}
if (wxClockLogReq.getClockImageList() != null && wxClockLogReq.getClockImageList().size() > 1) {
wxClockLogReq.getClockImageList().set(1, result.getData().getUrl());
} else {
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
}
}
if (thirdClockImg != null && StringUtils.isNotBlank(thirdClockImg.getOriginalFilename())) {
R<SysFile> result = remoteFileService.upload(thirdClockImg);
if (result.getCode() != Constants.SUCCESS) {
logger.error("上传打卡图片失败");
throw new ServiceException("上传打卡图片失败");
}
if (wxClockLogReq.getClockImageList() != null && wxClockLogReq.getClockImageList().size() > 2
&& StringUtils.isNotBlank(wxClockLogReq.getClockImageList().get(2))) {
wxClockLogReq.getClockImageList().set(2, result.getData().getUrl());
} else {
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
}
}
public R insertClockLog(@Validated WxClockLogReq wxClockLogReq) {
if (wxClockLogReq.getClockImageList() == null || wxClockLogReq.getClockImageList().size() == 0) {
logger.error("请上传打卡图片");
throw new ServiceException("请上传打卡图片");

Loading…
Cancel
Save