|
|
|
|
@ -1,14 +1,20 @@
|
|
|
|
|
package com.flossom.miniProgram.controller;
|
|
|
|
|
|
|
|
|
|
import com.flossom.common.core.constant.Constants;
|
|
|
|
|
import com.flossom.common.core.domain.R;
|
|
|
|
|
import com.flossom.common.core.domain.SysFile;
|
|
|
|
|
import com.flossom.common.core.domain.req.WxClockLogReq;
|
|
|
|
|
import com.flossom.common.core.exception.ServiceException;
|
|
|
|
|
import com.flossom.common.core.web.controller.BaseController;
|
|
|
|
|
import com.flossom.miniProgram.service.IWxClockLogService;
|
|
|
|
|
import com.flossom.system.api.RemoteFileService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户打卡Controller
|
|
|
|
|
@ -23,6 +29,9 @@ public class WxClockLogController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IWxClockLogService wxClockLogService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteFileService remoteFileService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加用户使用仪器记录表
|
|
|
|
|
*/
|
|
|
|
|
@ -35,14 +44,46 @@ public class WxClockLogController extends BaseController {
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户打卡
|
|
|
|
|
* 需要记录当天使用过的全部仪器(打卡前后的全部仪器)
|
|
|
|
|
* firstClockImg 第一张图片是必须的
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/insertClockLog")
|
|
|
|
|
public R insertClockLog(@Validated @RequestBody WxClockLogReq wxClockLogReq) {
|
|
|
|
|
public R insertClockLog(@RequestParam(value = "firstClockImg") MultipartFile firstClockImg,
|
|
|
|
|
@RequestParam(value = "secondClockImg", required = false) MultipartFile secondClockImg,
|
|
|
|
|
@RequestParam(value = "thirdClockImg", required = false) MultipartFile thirdClockImg,
|
|
|
|
|
@Validated WxClockLogReq wxClockLogReq) {
|
|
|
|
|
wxClockLogReq.setClockImageList(new ArrayList<>());
|
|
|
|
|
if (firstClockImg != null) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(firstClockImg);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传打卡图片失败");
|
|
|
|
|
throw new ServiceException("上传打卡图片失败");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
}
|
|
|
|
|
if (secondClockImg != null) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(secondClockImg);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传打卡图片失败");
|
|
|
|
|
throw new ServiceException("上传打卡图片失败");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
}
|
|
|
|
|
if (thirdClockImg != null) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(thirdClockImg);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传打卡图片失败");
|
|
|
|
|
throw new ServiceException("上传打卡图片失败");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wxClockLogReq.getClockImageList() == null || wxClockLogReq.getClockImageList().size() == 0) {
|
|
|
|
|
logger.error("请上传打卡图片");
|
|
|
|
|
throw new ServiceException("请上传打卡图片");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogService.insertWxClockLog(wxClockLogReq);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|