You've already forked FrameTour-BE
feat(printer): 添加图片裁剪信息字段并实现裁剪功能
- 在 MemberPrintEntity 中新增 crop 字段用于存储裁剪信息 - 创建 Crop 类并添加 Lombok 注解以支持构造函数和 getter/setter - 在 PrinterServiceImpl 中调用 smartCropAndFill 方法进行图片裁剪 - 设置默认旋转角度为 270 并将裁剪信息序列化后保存到数据库 - 更新 PrinterMapper.xml 配置文件以支持新字段的插入和查询
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package com.ycwl.basic.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 裁剪信息
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Crop {
|
||||
private Integer rotation;
|
||||
}
|
||||
|
||||
@@ -24,4 +24,5 @@ public class MemberPrintEntity {
|
||||
private Integer status;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private String crop;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.ycwl.basic.mapper.OrderMapper;
|
||||
import com.ycwl.basic.mapper.PrintTaskMapper;
|
||||
import com.ycwl.basic.mapper.PrinterMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.model.Crop;
|
||||
import com.ycwl.basic.model.PrinterOrderItem;
|
||||
import com.ycwl.basic.model.mobile.face.FaceRecognizeResp;
|
||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||
@@ -540,6 +541,7 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
|
||||
// 使用smartCropAndFill裁剪图片
|
||||
File croppedFile = ImageUtils.smartCropAndFill(url, printWidth, printHeight);
|
||||
entity.setCrop(JacksonUtil.toJSONString(new Crop(270)));
|
||||
|
||||
try {
|
||||
// 上传裁剪后的图片
|
||||
|
||||
@@ -116,6 +116,7 @@
|
||||
source_id,
|
||||
orig_url,
|
||||
crop_url,
|
||||
crop,
|
||||
quantity,
|
||||
status,
|
||||
create_time,
|
||||
@@ -127,6 +128,7 @@
|
||||
#{sourceId},
|
||||
#{origUrl},
|
||||
#{cropUrl},
|
||||
#{crop},
|
||||
1,
|
||||
0,
|
||||
NOW(),
|
||||
|
||||
Reference in New Issue
Block a user