pad点餐接口实现

This commit is contained in:
张松 2025-02-20 14:30:00 +08:00
parent d8935700f2
commit 5b587995ba
3 changed files with 43 additions and 14 deletions

View File

@ -39,13 +39,13 @@ public class PadProdController {
/**
* 获取点餐详情
* @param padProductCategory tb_pad_product_category Id
* @param id tb_pad_product_category Id
* @return 数据
*/
@SaAdminCheckPermission(value = "padProd:detail", name = "pad点餐详情")
@GetMapping("/detail")
public CzgResult<PadDetailDTO> detail(Long padProductCategory) {
return CzgResult.success(padProdService.detail(StpKit.USER.getShopId(), padProductCategory));
public CzgResult<PadDetailDTO> detail(Long id) {
return CzgResult.success(padProdService.detail(StpKit.USER.getShopId(), id));
}
/**
@ -69,7 +69,7 @@ public class PadProdController {
}
/**
* pad点餐修改
* pad点餐删除
* @return 是否成功
*/
@SaAdminCheckPermission(value = "padProd:del", name = "pad点餐删除")

View File

@ -61,6 +61,30 @@ public class JoinQueryWrapper extends QueryWrapper {
return this;
}
@Override
public <T> JoinQueryWrapper lt(LambdaGetter<T> column, Object value) {
lt(getColum(column), value);
return this;
}
@Override
public <T> QueryWrapper gt(LambdaGetter<T> column, Object value) {
gt(getColum(column), value);
return this;
}
@Override
public <T> QueryWrapper in(LambdaGetter<T> column, Object... values) {
in(getColum(column), values);
return this;
}
@Override
public <T> QueryWrapper notIn(LambdaGetter<T> column, Object... values) {
notIn(getColum(column), values);
return this;
}
@Override
public <T> JoinQueryWrapper orderBy(LambdaGetter<T> column, Boolean asc) {
orderBy(getColum(column), asc);

View File

@ -43,7 +43,7 @@ public class PadProdServiceImpl implements PadProdService {
public Page<PadProductCategoryDTO> pageInfo(Page<PadProductCategoryDTO> objectPage, Long productCategoryId, Long shopId) {
JoinQueryWrapper queryWrapper = new JoinQueryWrapper().eq(PadProductCategory::getShopId, shopId);
if (productCategoryId != null) {
queryWrapper.eq(PadProductCategory::getId, productCategoryId);
queryWrapper.eq(PadProductCategory::getProductCategoryId, productCategoryId);
}
queryWrapper.orderBy(PadProductCategory::getSort, true).orderBy(PadProductCategory::getId, false);
return padProductCategoryDetailMapper.xmlPaginate("selectPageByKeyAndShopId", objectPage, queryWrapper);
@ -98,16 +98,19 @@ public class PadProdServiceImpl implements PadProdService {
}
checkInfo(shopId, padDetailEditDTO.getPadLayoutId(), padDetailEditDTO.getProductIdList());
padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padDetailEditDTO.getId()));
category.setPadLayoutId(padDetailEditDTO.getPadLayoutId());
padProductCategoryService.updateById(category);
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailEditDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padDetailEditDTO.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
if (padDetailEditDTO.getProductIdList() != null && !padDetailEditDTO.getProductIdList().isEmpty()) {
padProductCategoryDetailService.remove(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padDetailEditDTO.getId()));
ArrayList<PadProductCategoryDetail> details = new ArrayList<>();
padDetailEditDTO.getProductIdList().forEach(item -> {
details.add(new PadProductCategoryDetail().setPadProductCategoryId(padDetailEditDTO.getId()).setProductId(item));
});
return padProductCategoryDetailService.saveBatch(details);
}
return true;
}
private void checkInfo(Long shopId, Long padLayoutId, List<Long> productIdList) {
@ -116,9 +119,11 @@ public class PadProdServiceImpl implements PadProdService {
throw new ApiNotPrintException("pad布局不存在");
}
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id");
if (productIdList != null && !productIdList.isEmpty()) {
long proCount = productService.count(new QueryWrapper().eq(Product::getShopId, shopId).in(Product::getId, productIdList));
if (proCount != productIdList.size()) {
throw new ApiNotPrintException("存在错误商品id");
}
}
}