diff --git a/src/main/java/com/ycwl/basic/controller/mobile/AppPrinterController.java b/src/main/java/com/ycwl/basic/controller/mobile/AppPrinterController.java index 0c077f8c..e0962dc2 100644 --- a/src/main/java/com/ycwl/basic/controller/mobile/AppPrinterController.java +++ b/src/main/java/com/ycwl/basic/controller/mobile/AppPrinterController.java @@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -65,12 +66,15 @@ public class AppPrinterController { Integer id = printerService.addUserPhoto(JwtTokenUtil.getWorker().getUserId(), scenicId, url); return ApiResponse.success(id); } - @PostMapping("/uploadTo/{scenicId}/cropped/{id}") - public ApiResponse uploadReplace(@PathVariable("scenicId") Long scenicId, @PathVariable("id") Long id, @RequestParam(value = "file") MultipartFile file) throws IOException { + @PostMapping(value = "/uploadTo/{scenicId}/cropped/{id}", consumes = "multipart/form-data") + public ApiResponse uploadReplace(@PathVariable("scenicId") Long scenicId, + @PathVariable("id") Long id, + @RequestPart(value = "crop", required = false) String crop, + @RequestPart(value = "file") MultipartFile file) throws IOException { String[] split = file.getOriginalFilename().split("\\."); String ext = split[split.length - 1]; String url = StorageFactory.use().uploadFile(file, "printer", UUID.randomUUID() + "." + ext); - printerService.setPhotoCropped(JwtTokenUtil.getWorker().getUserId(), scenicId, id, url); + printerService.setPhotoCropped(JwtTokenUtil.getWorker().getUserId(), scenicId, id, url, crop); return ApiResponse.success(url); } @PostMapping("/uploadTo/{scenicId}/formSource") diff --git a/src/main/java/com/ycwl/basic/mapper/PrinterMapper.java b/src/main/java/com/ycwl/basic/mapper/PrinterMapper.java index 1257a999..68d10c6f 100644 --- a/src/main/java/com/ycwl/basic/mapper/PrinterMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/PrinterMapper.java @@ -44,7 +44,7 @@ public interface PrinterMapper { MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id); - int setPhotoCropped(Long memberId, Long scenicId, Long id, String url); + int setPhotoCropped(Long memberId, Long scenicId, Long id, String url, String crop); int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity); diff --git a/src/main/java/com/ycwl/basic/model/pc/printer/resp/MemberPrintResp.java b/src/main/java/com/ycwl/basic/model/pc/printer/resp/MemberPrintResp.java index 25f10702..6396b4c5 100644 --- a/src/main/java/com/ycwl/basic/model/pc/printer/resp/MemberPrintResp.java +++ b/src/main/java/com/ycwl/basic/model/pc/printer/resp/MemberPrintResp.java @@ -17,4 +17,5 @@ public class MemberPrintResp { private Long orderId; private Integer status; private Date createTime; + private String crop; } diff --git a/src/main/java/com/ycwl/basic/service/printer/PrinterService.java b/src/main/java/com/ycwl/basic/service/printer/PrinterService.java index 8ecc7c25..fcb3b25a 100644 --- a/src/main/java/com/ycwl/basic/service/printer/PrinterService.java +++ b/src/main/java/com/ycwl/basic/service/printer/PrinterService.java @@ -42,7 +42,7 @@ public interface PrinterService { MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id); - int setPhotoCropped(Long memberId, Long scenicId, Long id, String url); + int setPhotoCropped(Long memberId, Long scenicId, Long id, String url, String crop); int setPhotoQuantity(Long memberId, Long scenicId, Long id, Integer quantity); diff --git a/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java b/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java index b7b32292..4b58f875 100644 --- a/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/printer/impl/PrinterServiceImpl.java @@ -243,8 +243,8 @@ public class PrinterServiceImpl implements PrinterService { } @Override - public int setPhotoCropped(Long memberId, Long scenicId, Long id, String url) { - return printerMapper.setPhotoCropped(memberId, scenicId, id, url); + public int setPhotoCropped(Long memberId, Long scenicId, Long id, String url, String crop) { + return printerMapper.setPhotoCropped(memberId, scenicId, id, url, crop); } @Override diff --git a/src/main/resources/mapper/PrinterMapper.xml b/src/main/resources/mapper/PrinterMapper.xml index 055f6e87..99db5e0b 100644 --- a/src/main/resources/mapper/PrinterMapper.xml +++ b/src/main/resources/mapper/PrinterMapper.xml @@ -38,23 +38,17 @@ WHERE p.scenic_id = #{scenicId} and p.status = 1 @@ -166,7 +158,7 @@ WHERE id = #{id} AND status = #{expectStatus} - UPDATE member_print SET crop_url = #{url}, update_time = NOW(), print_url = null WHERE id = #{id} + UPDATE member_print SET crop_url = #{url}, crop = #{crop}, update_time = NOW(), print_url = null WHERE id = #{id} UPDATE member_print SET quantity = #{quantity}, update_time = NOW() WHERE id = #{id}