diff --git a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java index d0132e3..b3b5b4a 100644 --- a/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java +++ b/flossom-modules/flossom-mini-program/src/main/java/com/flossom/miniProgram/controller/WxClockLogController.java @@ -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 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 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 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("请上传打卡图片");