微信打卡

master
382696293@qq.com 2 years ago
parent 75b611e724
commit b703a9c6b5

@ -3,6 +3,7 @@ package com.flossom.common.core.domain.req;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
/**
@ -23,8 +24,6 @@ public class WxClockLogReq {
/**
*
*/
@NotNull(message = "请上传打卡图片")
@Size(min = 1, max = 3, message = "打卡图片数限制在3张以内")
List<String> clockImageList;
public String getClockContent() {

@ -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();
}
}

Loading…
Cancel
Save