You've already forked FrameTour-BE
feat(printer): 支持上传裁剪参数并更新照片裁剪信息
- 在 AppPrinterController 中新增 crop 参数用于接收裁剪数据 - 修改 PrinterMapper 和 PrinterService 接口及实现,支持保存 crop 字段 - 更新 MemberPrintResp 模型以包含 crop 属性 -优化 Mapper XML 查询语句,统一使用 SELECT p.* 提高可读性 - 数据库更新语句中添加 crop 字段的赋值操作
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -17,4 +17,5 @@ public class MemberPrintResp {
|
||||
private Long orderId;
|
||||
private Integer status;
|
||||
private Date createTime;
|
||||
private String crop;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,23 +38,17 @@
|
||||
WHERE p.scenic_id = #{scenicId} and p.status = 1
|
||||
</select>
|
||||
<select id="listRelation" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||
SELECT p.id, p.scenic_id as scenicId, p.member_id as memberId,
|
||||
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
|
||||
p.status, p.create_time as createTime, p.printer_id
|
||||
SELECT p.*
|
||||
FROM member_print p
|
||||
WHERE p.member_id = #{memberId} AND p.scenic_id = #{scenicId} AND p.status = 0
|
||||
</select>
|
||||
<select id="getUserPhoto" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||
SELECT p.id, p.scenic_id, p.member_id as memberId,
|
||||
p.member_id, p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
|
||||
p.status, p.create_time as createTime, p.printer_id
|
||||
SELECT p.*
|
||||
FROM member_print p
|
||||
WHERE p.id = #{id} AND p.member_id = #{memberId} AND p.scenic_id = #{scenicId}
|
||||
</select>
|
||||
<select id="getUserPhotoByIds" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||
SELECT p.id, p.scenic_id, p.member_id as memberId,
|
||||
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
|
||||
p.status, p.create_time as createTime, p.printer_id
|
||||
SELECT p.*
|
||||
FROM member_print p
|
||||
WHERE p.id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
@@ -62,9 +56,7 @@
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="listRelationByOrderId" resultType="com.ycwl.basic.model.pc.printer.resp.MemberPrintResp">
|
||||
SELECT p.id, p.scenic_id as scenicId, p.member_id as memberId,
|
||||
p.orig_url as origUrl, p.crop_url as cropUrl, p.order_id as orderId, p.quantity,
|
||||
p.status, p.create_time as createTime, p.printer_id
|
||||
SELECT p.*
|
||||
FROM member_print p
|
||||
WHERE p.id in (select order_item.goods_id from order_item where order_item.order_id = #{orderId} and order_item.goods_type = 3)
|
||||
</select>
|
||||
@@ -166,7 +158,7 @@
|
||||
WHERE id = #{id} AND status = #{expectStatus}
|
||||
</update>
|
||||
<update id="setPhotoCropped">
|
||||
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>
|
||||
<update id="setPhotoQuantity">
|
||||
UPDATE member_print SET quantity = #{quantity}, update_time = NOW() WHERE id = #{id}
|
||||
|
||||
Reference in New Issue
Block a user