You've already forked FrameTour-BE
feat(printer):优化用户照片添加逻辑并返回结果ID
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 修改 addUserPhoto 方法参数,使用 MemberPrintEntity 实体传参- 在 PrinterMapper.xml 中配置 insert 语句返回主键 ID- 更新 addUserPhotoFromSource 方法返回值为 List<Integer> - 添加异常处理和日志记录 - 调整 AppPrinterController 接口返回照片 ID 列表
This commit is contained in:
@@ -75,8 +75,8 @@ public class AppPrinterController {
|
|||||||
}
|
}
|
||||||
@PostMapping("/uploadTo/{scenicId}/formSource")
|
@PostMapping("/uploadTo/{scenicId}/formSource")
|
||||||
public ApiResponse<?> uploadFromSource(@PathVariable("scenicId") Long scenicId, @RequestBody FromSourceReq req) throws IOException {
|
public ApiResponse<?> uploadFromSource(@PathVariable("scenicId") Long scenicId, @RequestBody FromSourceReq req) throws IOException {
|
||||||
printerService.addUserPhotoFromSource(JwtTokenUtil.getWorker().getUserId(), scenicId, req);
|
List<Integer> list = printerService.addUserPhotoFromSource(JwtTokenUtil.getWorker().getUserId(), scenicId, req);
|
||||||
return ApiResponse.success(null);
|
return ApiResponse.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/setQuantity/{scenicId}/{id}")
|
@PostMapping("/setQuantity/{scenicId}/{id}")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ycwl.basic.mapper;
|
package com.ycwl.basic.mapper;
|
||||||
|
|
||||||
|
import com.ycwl.basic.model.pc.printer.entity.MemberPrintEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
|
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
|
||||||
@@ -35,7 +36,7 @@ public interface PrinterMapper {
|
|||||||
|
|
||||||
int deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
int deleteUserPhoto(Long memberId, Long scenicId, Long relationId);
|
||||||
|
|
||||||
int addUserPhoto(Long memberId, Long scenicId, String url);
|
int addUserPhoto(MemberPrintEntity entity);
|
||||||
|
|
||||||
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
|
MemberPrintResp getUserPhoto(Long memberId, Long scenicId, Long id);
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public interface PrinterService {
|
|||||||
|
|
||||||
PriceObj queryPrice(Long memberId, Long scenicId);
|
PriceObj queryPrice(Long memberId, Long scenicId);
|
||||||
|
|
||||||
boolean addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req);
|
List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req);
|
||||||
|
|
||||||
Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId);
|
Map<String, Object> createOrder(Long memberId, Long scenicId, Integer printerId);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import com.ycwl.basic.pricing.dto.PriceCalculationResult;
|
|||||||
import com.ycwl.basic.pricing.dto.ProductItem;
|
import com.ycwl.basic.pricing.dto.ProductItem;
|
||||||
import com.ycwl.basic.pricing.enums.ProductType;
|
import com.ycwl.basic.pricing.enums.ProductType;
|
||||||
import com.ycwl.basic.pricing.service.IPriceCalculationService;
|
import com.ycwl.basic.pricing.service.IPriceCalculationService;
|
||||||
|
import com.ycwl.basic.model.pc.printer.entity.MemberPrintEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
import com.ycwl.basic.model.pc.printer.entity.PrintTaskEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
import com.ycwl.basic.model.pc.printer.entity.PrinterEntity;
|
||||||
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
|
import com.ycwl.basic.model.pc.printer.resp.MemberPrintResp;
|
||||||
@@ -44,6 +45,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -190,7 +192,13 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addUserPhoto(Long memberId, Long scenicId, String url) {
|
public boolean addUserPhoto(Long memberId, Long scenicId, String url) {
|
||||||
printerMapper.addUserPhoto(memberId, scenicId, url);
|
MemberPrintEntity entity = new MemberPrintEntity();
|
||||||
|
entity.setMemberId(memberId);
|
||||||
|
entity.setScenicId(scenicId);
|
||||||
|
entity.setOrigUrl(url);
|
||||||
|
entity.setCropUrl(url);
|
||||||
|
entity.setStatus(0);
|
||||||
|
printerMapper.addUserPhoto(entity);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,15 +267,34 @@ public class PrinterServiceImpl implements PrinterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req) {
|
public List<Integer> addUserPhotoFromSource(Long memberId, Long scenicId, FromSourceReq req) {
|
||||||
|
List<Integer> resultIds = new ArrayList<>();
|
||||||
req.getIds().forEach(id -> {
|
req.getIds().forEach(id -> {
|
||||||
SourceRespVO byId = sourceMapper.getById(id);
|
SourceRespVO byId = sourceMapper.getById(id);
|
||||||
if (byId == null) {
|
if (byId == null) {
|
||||||
|
resultIds.add(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printerMapper.addUserPhoto(memberId, scenicId, byId.getUrl());
|
MemberPrintEntity entity = new MemberPrintEntity();
|
||||||
|
entity.setMemberId(memberId);
|
||||||
|
entity.setScenicId(scenicId);
|
||||||
|
entity.setOrigUrl(byId.getUrl());
|
||||||
|
entity.setCropUrl(byId.getUrl());
|
||||||
|
entity.setStatus(0);
|
||||||
|
|
||||||
|
try {
|
||||||
|
int rows = printerMapper.addUserPhoto(entity);
|
||||||
|
if (rows > 0 && entity.getId() != null) {
|
||||||
|
resultIds.add(entity.getId());
|
||||||
|
} else {
|
||||||
|
resultIds.add(null);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("添加用户照片失败, memberId={}, scenicId={}, sourceId={}", memberId, scenicId, id, e);
|
||||||
|
resultIds.add(null);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return resultIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
NOW()
|
NOW()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="addUserPhoto">
|
<insert id="addUserPhoto" useGeneratedKeys="true" keyProperty="id">
|
||||||
INSERT INTO member_print (
|
INSERT INTO member_print (
|
||||||
member_id,
|
member_id,
|
||||||
scenic_id,
|
scenic_id,
|
||||||
@@ -108,8 +108,8 @@
|
|||||||
) VALUES (
|
) VALUES (
|
||||||
#{memberId},
|
#{memberId},
|
||||||
#{scenicId},
|
#{scenicId},
|
||||||
#{url},
|
#{origUrl},
|
||||||
#{url},
|
#{cropUrl},
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
NOW(),
|
NOW(),
|
||||||
|
|||||||
Reference in New Issue
Block a user