|
|
|
|
@ -8,6 +8,7 @@ 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.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@ -59,36 +60,52 @@ public class WxClockLogController extends BaseController {
|
|
|
|
|
@RequestParam(value = "secondClockImg") MultipartFile secondClockImg,
|
|
|
|
|
@RequestParam(value = "thirdClockImg") MultipartFile thirdClockImg,
|
|
|
|
|
@Validated WxClockLogReq wxClockLogReq) {
|
|
|
|
|
wxClockLogReq.setClockImageList(new ArrayList<>());
|
|
|
|
|
if (firstClockImg != null) {
|
|
|
|
|
if (firstClockImg != null && StringUtils.isNotBlank(firstClockImg.getOriginalFilename())) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(firstClockImg);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传打卡图片失败");
|
|
|
|
|
throw new ServiceException("上传打卡图片失败");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
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) {
|
|
|
|
|
if (secondClockImg != null && StringUtils.isNotBlank(secondClockImg.getOriginalFilename())) {
|
|
|
|
|
R<SysFile> result = remoteFileService.upload(secondClockImg);
|
|
|
|
|
if (result.getCode() != Constants.SUCCESS) {
|
|
|
|
|
logger.error("上传打卡图片失败");
|
|
|
|
|
throw new ServiceException("上传打卡图片失败");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
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) {
|
|
|
|
|
if (thirdClockImg != null && StringUtils.isNotBlank(thirdClockImg.getOriginalFilename())) {
|
|
|
|
|
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() > 2
|
|
|
|
|
&& StringUtils.isNotBlank(wxClockLogReq.getClockImageList().get(2))) {
|
|
|
|
|
wxClockLogReq.getClockImageList().set(2, result.getData().getUrl());
|
|
|
|
|
} else {
|
|
|
|
|
wxClockLogReq.getClockImageList().add(result.getData().getUrl());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wxClockLogReq.getClockImageList() == null || wxClockLogReq.getClockImageList().size() == 0) {
|
|
|
|
|
logger.error("请上传打卡图片");
|
|
|
|
|
throw new ServiceException("请上传打卡图片");
|
|
|
|
|
}
|
|
|
|
|
if (wxClockLogReq.getClockImageList().size() > 3) {
|
|
|
|
|
logger.error("打卡图片只能上传3张以下");
|
|
|
|
|
throw new ServiceException("打卡图片只能上传3张以下");
|
|
|
|
|
}
|
|
|
|
|
wxClockLogService.insertWxClockLog(wxClockLogReq);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|