1. update order submit
This commit is contained in:
2025-10-12 12:39:47 +08:00
parent 200552b261
commit 0dd34acc4c
12 changed files with 140 additions and 51 deletions

View File

@@ -142,6 +142,7 @@ CREATE TABLE `kiosk_order_detail_photo_attachment_r`
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID', `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`detail_id` bigint NOT NULL COMMENT 'did', `detail_id` bigint NOT NULL COMMENT 'did',
`photo_id` bigint NOT NULL COMMENT 'pid', `photo_id` bigint NOT NULL COMMENT 'pid',
`snapshot` bigint NULL DEFAULT NULL COMMENT '快照id',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人', `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门', `create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间',
@@ -159,7 +160,7 @@ CREATE TABLE `kiosk_text_attachment_r`
( (
`id` bigint NOT NULL COMMENT '主键', `id` bigint NOT NULL COMMENT '主键',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID', `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`detail_id` bigint NOT NULL COMMENT 'did', `photo_id` bigint NOT NULL COMMENT 'pid',
`font_name` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字体名称', `font_name` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '字体名称',
`font_size` int NOT NULL DEFAULT 16 COMMENT '字体大小', `font_size` int NOT NULL DEFAULT 16 COMMENT '字体大小',
`text_content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文字内容', `text_content` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文字内容',
@@ -180,7 +181,7 @@ CREATE TABLE `kiosk_stickers_attachment_r`
( (
`id` bigint NOT NULL COMMENT '主键', `id` bigint NOT NULL COMMENT '主键',
`tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID', `tenant_id` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '000000' COMMENT '租户ID',
`detail_id` bigint NOT NULL COMMENT 'did', `photo_id` bigint NOT NULL COMMENT 'pid',
`stickers_id` bigint NOT NULL COMMENT 'sid', `stickers_id` bigint NOT NULL COMMENT 'sid',
`create_user` bigint NULL DEFAULT NULL COMMENT '创建人', `create_user` bigint NULL DEFAULT NULL COMMENT '创建人',
`create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门', `create_dept` bigint NULL DEFAULT NULL COMMENT '创建部门',

View File

@@ -3,6 +3,7 @@ package org.springblade.modules.kiosk.controller;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest; import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
@@ -13,6 +14,7 @@ import org.springblade.modules.kiosk.pojo.vo.StickersApiVO;
import org.springblade.modules.kiosk.service.IKioskApiService; import org.springblade.modules.kiosk.service.IKioskApiService;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@@ -45,13 +47,11 @@ public class KioskApiController {
*/ */
@GetMapping("/stickers-list") @GetMapping("/stickers-list")
@Operation(summary = "贴纸列表查询") @Operation(summary = "贴纸列表查询")
@Cacheable(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
public R<List<StickersApiVO>> stickersList() { public R<List<StickersApiVO>> stickersList() {
List<StickersApiVO> list = kioskApiService.stickersList(); List<StickersApiVO> list = kioskApiService.stickersList();
return R.data(list); return R.data(list);
} }
/** /**
* 材质目录查询 * 材质目录查询
* *
@@ -88,7 +88,6 @@ public class KioskApiController {
return R.data(list); return R.data(list);
} }
/** /**
* 生成上传地址 * 生成上传地址
* *
@@ -124,4 +123,15 @@ public class KioskApiController {
return R.data(kioskApiService.submitOrder(request)); return R.data(kioskApiService.submitOrder(request));
} }
/**
* 上传文件
*
* @param file 文件
* @return ObjectStat
*/
@SneakyThrows
@PostMapping("/upload")
public R<Long> upload(@RequestParam MultipartFile file) {
return R.data(kioskApiService.upload(file.getOriginalFilename(), file.getInputStream()));
}
} }

View File

@@ -36,8 +36,6 @@ import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.kiosk.pojo.entity.StickersEntity; import org.springblade.modules.kiosk.pojo.entity.StickersEntity;
@@ -99,7 +97,6 @@ public class StickersController extends BladeController {
@PostMapping("/save") @PostMapping("/save")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入stickers") @Operation(summary = "新增", description = "传入stickers")
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
public R save(@Valid @RequestBody StickersEntity stickers) { public R save(@Valid @RequestBody StickersEntity stickers) {
return R.status(stickersService.save(stickers)); return R.status(stickersService.save(stickers));
} }
@@ -110,7 +107,6 @@ public class StickersController extends BladeController {
@PostMapping("/update") @PostMapping("/update")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入stickers") @Operation(summary = "修改", description = "传入stickers")
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
public R update(@Valid @RequestBody StickersEntity stickers) { public R update(@Valid @RequestBody StickersEntity stickers) {
return R.status(stickersService.updateById(stickers)); return R.status(stickersService.updateById(stickers));
} }
@@ -121,7 +117,6 @@ public class StickersController extends BladeController {
@PostMapping("/submit") @PostMapping("/submit")
@ApiOperationSupport(order = 6) @ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入stickers") @Operation(summary = "新增或修改", description = "传入stickers")
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
public R submit(@Valid @RequestBody StickersEntity stickers) { public R submit(@Valid @RequestBody StickersEntity stickers) {
return R.status(stickersService.saveOrUpdate(stickers)); return R.status(stickersService.saveOrUpdate(stickers));
} }
@@ -132,7 +127,6 @@ public class StickersController extends BladeController {
@PostMapping("/remove") @PostMapping("/remove")
@ApiOperationSupport(order = 7) @ApiOperationSupport(order = 7)
@Operation(summary = "删除", description = "传入ids") @Operation(summary = "删除", description = "传入ids")
@CacheEvict(cacheNames = "kiosk:stickers:list", key = "'all-stickers'")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(stickersService.removeByIds(Func.toLongList(ids))); return R.status(stickersService.removeByIds(Func.toLongList(ids)));
} }

View File

@@ -20,27 +20,47 @@ public class OrderApiRequest implements Serializable {
@Data @Data
public static class Item { public static class Item {
@NotNull(message = "category is missing") @NotNull(message = "category is missing")
private Long category; private Long category;
@NotNull(message = "snapshot is missing")
private Long snapshot; @NotEmpty(message = "snapshot is missing")
private String snapshot;
@NotEmpty(message = "photos is missing") @NotEmpty(message = "photos is missing")
private List<Long> photos = List.of(); private List<Photo> photos = List.of();
@NotNull(message = "size is missing") @NotNull(message = "size is missing")
private Integer size; private Integer size;
@NotNull(message = "material is missing") @NotNull(message = "material is missing")
private Integer material; private Integer material;
private Integer shape; private Integer shape;
private List<Text> text = List.of();
private List<Long> stickers = List.of();
private List<Long> accessories = List.of(); private List<Long> accessories = List.of();
} }
@Data @Data
public static class Text { public static class Text {
private Integer size;
private String content; private String content;
private String font; private String font;
} }
@Data
public static class Photo {
@NotNull(message = "photo is missing")
private Long photo;
@NotNull(message = "snapshot is missing")
private Long snapshot;
private List<Text> text = List.of();
private List<Long> stickers = List.of();
}
} }

View File

@@ -66,5 +66,10 @@ public class OrderDetailPhotoAttachmentREntity extends TenantEntity {
*/ */
@Schema(description = "pid") @Schema(description = "pid")
private Long photoId; private Long photoId;
/**
* snapshot_id
*/
@Schema(description = "snapshot")
private Long snapshot;
} }

View File

@@ -57,8 +57,8 @@ public class StickersAttachmentREntity extends TenantEntity {
/** /**
* did * did
*/ */
@Schema(description = "did") @Schema(description = "pid")
private Long detailId; private Long photoId;
/** /**
* sid * sid
*/ */

View File

@@ -59,8 +59,8 @@ public class TextAttachmentREntity extends TenantEntity {
/** /**
* did * did
*/ */
@Schema(description = "did") @Schema(description = "pid")
private Long detailId; private Long photoId;
/** /**
* 字体名称 * 字体名称
*/ */

View File

@@ -29,4 +29,7 @@ public interface IKioskApiService {
List<DictBizApiVO> sizeList(); List<DictBizApiVO> sizeList();
List<DictBizApiVO> shapeList(); List<DictBizApiVO> shapeList();
Long upload(String fileName, InputStream stream);
} }

View File

@@ -25,6 +25,7 @@
*/ */
package org.springblade.modules.kiosk.service; package org.springblade.modules.kiosk.service;
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity; import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity;
import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO; import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -49,4 +50,6 @@ public interface IPhotoAttachmentService extends IService<PhotoAttachmentEntity>
IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment); IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment);
List<PhotoAttachmentEntity> selectPhotoAttachmentListByOrderDetailId(Long orderDetailId); List<PhotoAttachmentEntity> selectPhotoAttachmentListByOrderDetailId(Long orderDetailId);
void createPhotoDetail(OrderApiRequest.Photo photo, Long orderDetailId);
} }

View File

@@ -148,15 +148,18 @@ public class KioskServiceImpl implements IKioskApiService {
public String submitOrder(OrderApiRequest request) { public String submitOrder(OrderApiRequest request) {
try { try {
photoAttachmentService.update(Wrappers.<PhotoAttachmentEntity>lambdaUpdate().eq(PhotoAttachmentEntity::getCreateUser, AuthUtil.getUserId()).set(PhotoAttachmentEntity::getStatus, 2)); photoAttachmentService.update(Wrappers.<PhotoAttachmentEntity>lambdaUpdate().eq(PhotoAttachmentEntity::getCreateUser, AuthUtil.getUserId()).set(PhotoAttachmentEntity::getStatus, 2));
OrderEntity order = new OrderEntity(); OrderEntity order = new OrderEntity();
order.setUserPhone(request.getPhone()); order.setUserPhone(request.getPhone());
order.setUserEmail(request.getEmail()); order.setUserEmail(request.getEmail());
order.setSerialNumber(StringUtil.random(8, RandomType.INT)); order.setSerialNumber(StringUtil.random(8, RandomType.INT));
orderService.save(order); orderService.save(order);
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
request.getData().forEach(item -> { request.getData().forEach(item -> {
OrderDetailEntity orderDetail = new OrderDetailEntity(); OrderDetailEntity orderDetail = new OrderDetailEntity();
orderDetail.setOrderId(order.getId()); orderDetail.setOrderId(order.getId());
CategoryEntity category = categoryService.getById(item.getCategory()); CategoryEntity category = categoryService.getById(item.getCategory());
if (category == null) { if (category == null) {
throw new ServiceException("Invalid category."); throw new ServiceException("Invalid category.");
@@ -167,22 +170,26 @@ public class KioskServiceImpl implements IKioskApiService {
orderDetail.setCategoryId(item.getCategory()); orderDetail.setCategoryId(item.getCategory());
orderDetail.setCategoryType(category.getType()); orderDetail.setCategoryType(category.getType());
orderDetail.setCategoryName(category.getName()); orderDetail.setCategoryName(category.getName());
String materialTypeValue = dictService.getValue(materialType, String.valueOf(item.getMaterial())); String materialTypeValue = dictService.getValue(materialType, String.valueOf(item.getMaterial()));
if (StringUtil.isBlank(materialTypeValue)) { if (StringUtil.isBlank(materialTypeValue)) {
throw new ServiceException("Invalid material."); throw new ServiceException("Invalid material.");
} }
orderDetail.setMaterial(materialTypeValue); orderDetail.setMaterial(materialTypeValue);
String sizeTypeValue = dictService.getValue(sizeType, String.valueOf(item.getSize())); String sizeTypeValue = dictService.getValue(sizeType, String.valueOf(item.getSize()));
if (StringUtil.isBlank(sizeTypeValue)) { if (StringUtil.isBlank(sizeTypeValue)) {
throw new ServiceException("Invalid size."); throw new ServiceException("Invalid size.");
} }
orderDetail.setSize(sizeTypeValue); orderDetail.setSize(sizeTypeValue);
String shapeTypeKey = category.getType() == 1 ? String.valueOf(item.getShape()) : category.getShape(); String shapeTypeKey = category.getType() == 1 ? String.valueOf(item.getShape()) : category.getShape();
String shapeTypeValue = dictService.getValue(shapeType, shapeTypeKey); String shapeTypeValue = dictService.getValue(shapeType, shapeTypeKey);
if (StringUtil.isBlank(shapeTypeValue)) { if (StringUtil.isBlank(shapeTypeValue)) {
throw new ServiceException("Invalid shape."); throw new ServiceException("Invalid shape.");
} }
orderDetail.setShape(shapeTypeValue); orderDetail.setShape(shapeTypeValue);
PhotoAttachmentEntity snapshotPhoto = photoAttachmentService.getById(item.getSnapshot()); PhotoAttachmentEntity snapshotPhoto = photoAttachmentService.getById(item.getSnapshot());
if (snapshotPhoto == null) { if (snapshotPhoto == null) {
throw new ServiceException("Invalid snapshot."); throw new ServiceException("Invalid snapshot.");
@@ -191,35 +198,7 @@ public class KioskServiceImpl implements IKioskApiService {
//todo: add amount! //todo: add amount!
orderDetailService.save(orderDetail); orderDetailService.save(orderDetail);
List<OrderDetailPhotoAttachmentREntity> photoRList = item.getPhotos().stream().map(p -> { item.getPhotos().forEach(photo -> photoAttachmentService.createPhotoDetail(photo, orderDetail.getId()));
OrderDetailPhotoAttachmentREntity r = new OrderDetailPhotoAttachmentREntity();
r.setPhotoId(p);
r.setDetailId(orderDetail.getId());
return r;
}).toList();
orderDetailPhotoAttachmentRService.saveBatch(photoRList);
if (CollectionUtil.isNotEmpty(item.getStickers())) {
List<StickersAttachmentREntity> stickerRList = item.getStickers().stream().map(s -> {
StickersAttachmentREntity r = new StickersAttachmentREntity();
r.setStickersId(s);
r.setDetailId(orderDetail.getId());
return r;
}).toList();
stickersAttachmentRService.saveBatch(stickerRList);
}
if (CollectionUtil.isNotEmpty(item.getText())) {
List<TextAttachmentREntity> textRList = item.getText().stream().map(t -> {
TextAttachmentREntity r = new TextAttachmentREntity();
r.setDetailId(orderDetail.getId());
r.setFontName(t.getFont());
r.setFontSize(t.getSize());
r.setTextContent(t.getContent());
return r;
}).toList();
textAttachmentRService.saveBatch(textRList);
}
}); });
order.setTotalAmount(totalAmount); order.setTotalAmount(totalAmount);
orderService.updateById(order); orderService.updateById(order);
@@ -261,4 +240,23 @@ public class KioskServiceImpl implements IKioskApiService {
return vo; return vo;
}).toList(); }).toList();
} }
@Override
public Long upload(String fileName, InputStream stream) {
BladeUser user = AuthUtil.getUser();
BladeFile bladeFile = ossTemplate.putFile(fileName, stream);
PhotoAttachmentEntity photoAttachmentEntity = new PhotoAttachmentEntity();
photoAttachmentEntity.setTenantId(user.getTenantId());
photoAttachmentEntity.setLink(bladeFile.getLink());
photoAttachmentEntity.setDomainUrl(bladeFile.getDomain());
photoAttachmentEntity.setName(bladeFile.getName());
photoAttachmentEntity.setOriginalName(bladeFile.getOriginalName());
photoAttachmentEntity.setCreateUser(user.getUserId());
photoAttachmentEntity.setCreateDept(Long.valueOf(user.getDeptId()));
photoAttachmentEntity.setCreateTime(DateUtil.now());
photoAttachmentService.save(photoAttachmentEntity);
return photoAttachmentEntity.getId();
}
} }

View File

@@ -64,7 +64,7 @@ public class OrderDetailServiceImpl extends BaseServiceImpl<OrderDetailMapper, O
List<StickersEntity> stickersList = stickersService.selectStickersListByOrderDetailId(vo.getId()); List<StickersEntity> stickersList = stickersService.selectStickersListByOrderDetailId(vo.getId());
vo.setStickers(stickersList.stream().map(StickersEntity::getLink).toList()); vo.setStickers(stickersList.stream().map(StickersEntity::getLink).toList());
List<TextAttachmentREntity> tList = textAttachmentRService.list(Wrappers.<TextAttachmentREntity>lambdaQuery().eq(TextAttachmentREntity::getDetailId, vo.getId())); List<TextAttachmentREntity> tList = textAttachmentRService.list(Wrappers.<TextAttachmentREntity>lambdaQuery().eq(TextAttachmentREntity::getPhotoId, vo.getId()));
vo.setTexts(tList.stream().map(t -> { vo.setTexts(tList.stream().map(t -> {
OrderDetailVO.Text tt = new OrderDetailVO.Text(); OrderDetailVO.Text tt = new OrderDetailVO.Text();
tt.setContent(t.getTextContent()); tt.setContent(t.getTextContent());

View File

@@ -26,15 +26,27 @@
package org.springblade.modules.kiosk.service.impl; package org.springblade.modules.kiosk.service.impl;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.modules.kiosk.pojo.dto.OrderApiRequest;
import org.springblade.modules.kiosk.pojo.entity.OrderDetailPhotoAttachmentREntity;
import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity; import org.springblade.modules.kiosk.pojo.entity.PhotoAttachmentEntity;
import org.springblade.modules.kiosk.pojo.entity.StickersAttachmentREntity;
import org.springblade.modules.kiosk.pojo.entity.TextAttachmentREntity;
import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO; import org.springblade.modules.kiosk.pojo.vo.PhotoAttachmentVO;
import org.springblade.modules.kiosk.mapper.PhotoAttachmentMapper; import org.springblade.modules.kiosk.mapper.PhotoAttachmentMapper;
import org.springblade.modules.kiosk.service.IOrderDetailPhotoAttachmentRService;
import org.springblade.modules.kiosk.service.IPhotoAttachmentService; import org.springblade.modules.kiosk.service.IPhotoAttachmentService;
import org.springblade.modules.kiosk.service.IStickersAttachmentRService;
import org.springblade.modules.kiosk.service.ITextAttachmentRService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/** /**
* 自助终端照片表 服务实现类 * 自助终端照片表 服务实现类
@@ -42,10 +54,16 @@ import java.util.List;
* @author Ray * @author Ray
* @since 2025-10-07 * @since 2025-10-07
*/ */
@Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor
public class PhotoAttachmentServiceImpl extends ServiceImpl<PhotoAttachmentMapper, PhotoAttachmentEntity> implements IPhotoAttachmentService { public class PhotoAttachmentServiceImpl extends ServiceImpl<PhotoAttachmentMapper, PhotoAttachmentEntity> implements IPhotoAttachmentService {
private final IOrderDetailPhotoAttachmentRService orderDetailPhotoAttachmentRService;
private final IStickersAttachmentRService stickersAttachmentRService;
private final ITextAttachmentRService textAttachmentRService;
@Override @Override
public IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment) { public IPage<PhotoAttachmentVO> selectPhotoAttachmentPage(IPage<PhotoAttachmentVO> page, PhotoAttachmentVO photoAttachment) {
@@ -57,4 +75,41 @@ public class PhotoAttachmentServiceImpl extends ServiceImpl<PhotoAttachmentMappe
return baseMapper.selectPhotoAttachmentListByOrderDetailId(orderDetailId); return baseMapper.selectPhotoAttachmentListByOrderDetailId(orderDetailId);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public void createPhotoDetail(OrderApiRequest.Photo photo, Long orderDetailId) {
try {
OrderDetailPhotoAttachmentREntity r = new OrderDetailPhotoAttachmentREntity();
r.setDetailId(orderDetailId);
r.setPhotoId(photo.getPhoto());
r.setSnapshot(photo.getSnapshot());
orderDetailPhotoAttachmentRService.save(r);
if (CollectionUtil.isNotEmpty(photo.getStickers())) {
List<StickersAttachmentREntity> stickerRList = photo.getStickers().stream().map(s -> {
StickersAttachmentREntity sar = new StickersAttachmentREntity();
sar.setStickersId(s);
sar.setPhotoId(photo.getPhoto());
return sar;
}).collect(Collectors.toList());
stickersAttachmentRService.saveBatch(stickerRList);
}
if (CollectionUtil.isNotEmpty(photo.getText())) {
List<TextAttachmentREntity> textRList = photo.getText().stream().map(t -> {
TextAttachmentREntity tar = new TextAttachmentREntity();
tar.setPhotoId(photo.getPhoto());
tar.setFontName(t.getFont());
tar.setTextContent(t.getContent());
return tar;
}).collect(Collectors.toList());
textAttachmentRService.saveBatch(textRList);
}
log.info("createPhotoDetail successfully");
}catch (Exception e){
log.error("createPhotoDetail error:", e);
throw e;
}
}
} }