From f07d808f3d4d7a5e8515deca6751c503a0853f93 Mon Sep 17 00:00:00 2001
From: Jerry Yan <792602257@qq.com>
Date: Mon, 27 Oct 2025 16:59:31 +0800
Subject: [PATCH] =?UTF-8?q?feat(printer):=20=E6=94=AF=E6=8C=81=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E8=A3=81=E5=89=AA=E5=8F=82=E6=95=B0=E5=B9=B6=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E7=85=A7=E7=89=87=E8=A3=81=E5=89=AA=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在 AppPrinterController 中新增 crop 参数用于接收裁剪数据
- 修改 PrinterMapper 和 PrinterService 接口及实现,支持保存 crop 字段
- 更新 MemberPrintResp 模型以包含 crop 属性
-优化 Mapper XML 查询语句,统一使用 SELECT p.* 提高可读性
- 数据库更新语句中添加 crop 字段的赋值操作
---
.../mobile/AppPrinterController.java | 10 +++++++---
.../com/ycwl/basic/mapper/PrinterMapper.java | 2 +-
.../model/pc/printer/resp/MemberPrintResp.java | 1 +
.../basic/service/printer/PrinterService.java | 2 +-
.../printer/impl/PrinterServiceImpl.java | 4 ++--
src/main/resources/mapper/PrinterMapper.xml | 18 +++++-------------
6 files changed, 17 insertions(+), 20 deletions(-)
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}