Merge branch 'feature' of https://gitee.com/liuyingfang/cashier-admin into feature

This commit is contained in:
liuyingfang 2024-03-05 15:36:54 +08:00
commit 4bfdc5546a
8 changed files with 50 additions and 13 deletions

View File

@ -80,7 +80,6 @@ public class ListUtil {
for (String s : listString) {
integerList.add(Integer.parseInt(s));
}
System.out.println(integerList);
return integerList;
}

View File

@ -105,4 +105,6 @@ public class TbCashierCartDto implements Serializable {
private String isGift;
private Long pendingAt;
private String uuid;
}

View File

@ -157,4 +157,6 @@ public class TbOrderInfoDto implements Serializable {
private String remark;
private List<TbOrderDetail> detailList;
private String payRemark;
}

View File

@ -17,6 +17,7 @@ package cn.ysk.cashier.dto.product;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @website https://eladmin.vip
@ -54,7 +55,7 @@ public class TbProductGroupDto implements Serializable {
private Integer sort;
/** 商品列表 */
private String productIds;
private List<String> productIds;
private Long createdAt;

View File

@ -21,8 +21,14 @@ import cn.ysk.cashier.dto.product.TbProductGroupDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @website https://eladmin.vip
* @author lyf
@ -31,4 +37,29 @@ import org.mapstruct.ReportingPolicy;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface TbProductGroupMapper extends BaseMapper<TbProductGroupDto, TbProductGroup> {
@Mapping(target = "productIds", source = "productIds")
TbProductGroupDto toDto(TbProductGroup entity);
// 自定义的字符串到整数列表的转换方法
default List<Integer> map(String value) {
if (value == null || value.isEmpty()) {
return Collections.emptyList();
}
// 分割字符串然后将每个数字字符串转换为Integer收集到List中
return Arrays.stream(value.split(","))
.map(Integer::valueOf)
.collect(Collectors.toList());
}
// 如果需要从DTO转回实体也可能需要实现反向的映射方法
default String map(List<Integer> values) {
if (values == null || values.isEmpty()) {
return "";
}
// 将整数列表转换为由逗号分隔的字符串
return values.stream()
.map(String::valueOf)
.collect(Collectors.joining(","));
}
}

View File

@ -150,6 +150,10 @@ public class TbCashierCart implements Serializable {
@ApiModelProperty(value = "pendingAt")
private Long pendingAt;
@Column(name = "`uuid`")
@ApiModelProperty(value = "uuid")
private String uuid;
public void copy(TbCashierCart source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -145,7 +145,7 @@ public class TbOrderInfo implements Serializable {
private BigDecimal userCouponAmount;
@Column(name = "`master_id`")
@ApiModelProperty(value = "如果为退单时,主单号")
@ApiModelProperty(value = "取餐码")
private String masterId;
@Column(name = "`refund_able`")
@ -208,6 +208,10 @@ public class TbOrderInfo implements Serializable {
@ApiModelProperty(value = "remark")
private String remark;
@Column(name = "`pay_remark`")
@ApiModelProperty(value = "payRemark")
private String payRemark;
public void copy(TbOrderInfo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -34,6 +34,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.CollectionUtils;
import java.time.Instant;
import java.util.List;
@ -77,16 +78,9 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
@Override
public List<TbProduct> findByIdProduct(Integer productGroup) {
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(productGroup).orElseGet(TbProductGroup::new);
if (tbProductGroup.getProductIds() != null){
List<String> list = ListUtil.stringChangeStringList(tbProductGroup.getProductIds());
List<Integer> intList = new ArrayList<>();
for (String str : list) {
intList.add(Integer.parseInt(str));
}
System.out.println(intList);
return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(list));
TbProductGroupDto dto = tbProductGroupMapper.toDto(tbProductGroup);
if (!CollectionUtils.isEmpty(dto.getProductIds())){
return tbProductRepository.findByIds(ListUtil.stringChangeIntegerList(dto.getProductIds()));
}
return new ArrayList<>();
}