From f2c739160ac06b7c3a9a1b1dd92c4002e7f99cc7 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sat, 17 Jan 2026 02:45:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(printer):=20=E6=B7=BB=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E6=9D=A5=E6=BA=90=E5=9B=BE=E7=89=87=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 MemberPrintEntity 和 MemberPrintResp 中新增 imageType 字段 - 根据 sourceId 自动设置图片类型为移动上传或普通照片 - 拼图类型图片明确标记为 PUZZLE 类型 - 修改图片来源判断逻辑从 sourceId 改为 imageType 字段 - 更新数据库映射文件添加 image_type 字段映射 --- .../pc/printer/entity/MemberPrintEntity.java | 1 + .../pc/printer/resp/MemberPrintResp.java | 1 + .../printer/impl/PrinterServiceImpl.java | 23 +++++++++++-------- src/main/resources/mapper/PrinterMapper.xml | 2 ++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/ycwl/basic/model/pc/printer/entity/MemberPrintEntity.java b/src/main/java/com/ycwl/basic/model/pc/printer/entity/MemberPrintEntity.java index 62429180..f30d8f54 100644 --- a/src/main/java/com/ycwl/basic/model/pc/printer/entity/MemberPrintEntity.java +++ b/src/main/java/com/ycwl/basic/model/pc/printer/entity/MemberPrintEntity.java @@ -16,6 +16,7 @@ public class MemberPrintEntity { private Long memberId; private Long faceId; private Long sourceId; + private String imageType; private String origUrl; private String cropUrl; private String printUrl; 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 cd6cc204..07c52ff7 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 @@ -9,6 +9,7 @@ public class MemberPrintResp { private Integer id; private Long scenicId; private Long sourceId; + private String imageType; private String scenicName; private Long faceId; private Long memberId; 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 8ca9b63d..5ff4f70a 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 @@ -313,6 +313,8 @@ public class PrinterServiceImpl implements PrinterService { entity.setScenicId(scenicId); entity.setFaceId(faceId); entity.setSourceId(sourceId); + // 根据 sourceId 判断图片类型 + entity.setImageType(sourceId == null ? ImageType.MOBILE_UPLOAD.getCode() : ImageType.NORMAL_PHOTO.getCode()); entity.setOrigUrl(url); // 获取打印尺寸 @@ -596,6 +598,7 @@ public class PrinterServiceImpl implements PrinterService { entity.setScenicId(scenicId); entity.setFaceId(faceId); entity.setSourceId(id); + entity.setImageType(ImageType.NORMAL_PHOTO.getCode()); entity.setOrigUrl(url); // 获取打印尺寸并裁剪图片 @@ -945,19 +948,18 @@ public class PrinterServiceImpl implements PrinterService { context.setStageState("image_enhance", true); } - // 根据sourceId判断图片来源和source类型 + // 根据 imageType 字段判断图片类型 SourceEntity source = null; - if (item.getSourceId() != null && item.getSourceId() > 0) { - source = sourceMapper.getEntity(item.getSourceId()); - if (source == null) { - context.setImageType(ImageType.PUZZLE); // 特殊 - } else { - context.setSource(ImageSource.IPC); - } - } else if (item.getSourceId() == null) { + if (ImageType.PUZZLE.getCode().equals(item.getImageType())) { + context.setImageType(ImageType.PUZZLE); + } else if (ImageType.MOBILE_UPLOAD.getCode().equals(item.getImageType())) { context.setSource(ImageSource.PHONE); } else { - context.setSource(ImageSource.UNKNOWN); + // 普通照片,查询 source 获取设备类型信息 + context.setSource(ImageSource.IPC); + if (item.getSourceId() != null && item.getSourceId() > 0) { + source = sourceMapper.getEntity(item.getSourceId()); + } } Pipeline pipeline; @@ -1545,6 +1547,7 @@ public class PrinterServiceImpl implements PrinterService { entity.setScenicId(scenicId); entity.setFaceId(faceId); entity.setSourceId(puzzleRecordId); // 使用拼图记录ID作为sourceId + entity.setImageType(ImageType.PUZZLE.getCode()); // 明确标记为拼图类型 entity.setOrigUrl(resultImageUrl); // 获取打印尺寸并裁剪图片 diff --git a/src/main/resources/mapper/PrinterMapper.xml b/src/main/resources/mapper/PrinterMapper.xml index 319bfd58..9a023ac9 100644 --- a/src/main/resources/mapper/PrinterMapper.xml +++ b/src/main/resources/mapper/PrinterMapper.xml @@ -114,6 +114,7 @@ scenic_id, face_id, source_id, + image_type, orig_url, crop_url, crop, @@ -126,6 +127,7 @@ #{scenicId}, #{faceId}, #{sourceId}, + #{imageType}, #{origUrl}, #{cropUrl}, #{crop},