店铺管理-店铺配置:打印机设置相关接口

This commit is contained in:
谭凯凯
2024-10-11 09:38:41 +08:00
committed by Tankaikai
parent 504fec5011
commit 8c8b49adb2
2 changed files with 38 additions and 1 deletions

View File

@@ -62,10 +62,15 @@ public class ShopPrinterDTO implements Serializable {
private String shopId;
/**
* 冗余/遗留字段
* 部分分类id 用逗号隔开部分打印时必传1,2,3
*/
private String categoryIds;
/**
* 部分分类列表 分类打印选择部分打印时必传JsonArray字符串数据 如:[{"id":125,"name":"意式咖啡"},{"id":127,"name":"饮品"}]
*/
private String categoryList;
/**
* 打印机品牌
* 云想印 = yxyPrinter

View File

@@ -6,7 +6,9 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import cn.ysk.cashier.dto.shop.ShopPrinterDTO;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.TbPrintMachineMapper;
import cn.ysk.cashier.pojo.shop.TbPrintMachineEntity;
import cn.ysk.cashier.service.shop.ShopPrinterService;
@@ -99,6 +101,21 @@ public class ShopPrinterServiceImpl extends ServiceImpl<TbPrintMachineMapper, Tb
public void save(ShopPrinterDTO dto) {
CopyOptions options = new CopyOptions();
options.setIgnoreProperties("createdAt", "updatedAt");
//分类打印选择部分打印时必传JsonArray字符串数据 如:[{"id":125,"name":"意式咖啡"},{"id":127,"name":"饮品"}]
if ("1".equals(dto.getClassifyPrint()) || "2".equals(dto.getClassifyPrint())) {
if (StrUtil.isBlank(dto.getCategoryList())) {
throw new BadRequestException("分类打印选择部分打印时,必须勾选需要部分打印的菜品");
}
if (JSONUtil.isTypeJSONArray(dto.getCategoryList())) {
throw new BadRequestException("传递的部分打印菜品数据不合法");
}
if (StrUtil.isBlank(dto.getCategoryIds())) {
throw new BadRequestException("分类打印选择部分打印时传递的部分打印菜品id数据不能为空");
}
} else {
dto.setCategoryIds(null);
dto.setCategoryList(null);
}
TbPrintMachineEntity entity = BeanUtil.toBean(dto, TbPrintMachineEntity.class, options);
entity.setCreatedAt(System.currentTimeMillis());
entity.setUpdatedAt(System.currentTimeMillis());
@@ -110,6 +127,21 @@ public class ShopPrinterServiceImpl extends ServiceImpl<TbPrintMachineMapper, Tb
TbPrintMachineEntity entity = baseMapper.selectById(dto.getId());
CopyOptions options = new CopyOptions();
options.setIgnoreProperties("createdAt", "updatedAt");
//分类打印选择部分打印时必传JsonArray字符串数据 如:[{"id":125,"name":"意式咖啡"},{"id":127,"name":"饮品"}]
if ("1".equals(dto.getClassifyPrint()) || "2".equals(dto.getClassifyPrint())) {
if (StrUtil.isBlank(dto.getCategoryList())) {
throw new BadRequestException("分类打印选择部分打印时,必须勾选需要部分打印的菜品");
}
if (JSONUtil.isTypeJSONArray(dto.getCategoryList())) {
throw new BadRequestException("传递的部分打印菜品数据不合法");
}
if (StrUtil.isBlank(dto.getCategoryIds())) {
throw new BadRequestException("分类打印选择部分打印时传递的部分打印菜品id数据不能为空");
}
} else {
dto.setCategoryIds(null);
dto.setCategoryList(null);
}
BeanUtil.copyProperties(dto, entity, options);
entity.setUpdatedAt(System.currentTimeMillis());
baseMapper.updateById(entity);