有商品不能删除超市

This commit is contained in:
sxu 2025-06-11 09:19:29 +08:00
parent f073dbfee7
commit a466bab26d
1 changed files with 16 additions and 0 deletions

View File

@ -2,6 +2,11 @@ package com.bonus.canteen.core.supermarket.service.impl;
import java.util.List;
import java.util.Objects;
import com.bonus.canteen.core.supermarket.domain.SupermarketMaterial;
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
import com.bonus.canteen.core.supermarket.mapper.SupermarketMaterialMapper;
import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
@ -10,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.bonus.canteen.core.supermarket.mapper.SupermarketInfoMapper;
import com.bonus.canteen.core.supermarket.domain.SupermarketInfo;
import com.bonus.canteen.core.supermarket.service.ISupermarketInfoService;
import org.springframework.util.CollectionUtils;
/**
* 超市Service业务层处理
@ -21,6 +27,8 @@ import com.bonus.canteen.core.supermarket.service.ISupermarketInfoService;
public class SupermarketInfoServiceImpl implements ISupermarketInfoService {
@Autowired
private SupermarketInfoMapper supermarketInfoMapper;
@Autowired
private SupermarketProductMapper supermarketProductMapper;
/**
* 查询超市
@ -95,6 +103,14 @@ public class SupermarketInfoServiceImpl implements ISupermarketInfoService {
*/
@Override
public int deleteSupermarketInfoBySupermarketIds(Long[] supermarketIds) {
for (int i = 0; i < supermarketIds.length; i++) {
SupermarketProduct supermarketProduct = new SupermarketProduct();
supermarketProduct.setSupermarketId(supermarketIds[i]);
List<SupermarketProduct> list = supermarketProductMapper.selectSupermarketProductList(supermarketProduct);
if (!CollectionUtils.isEmpty(list)) {
throw new ServiceException("该超市含有商品,不能删除");
}
}
return supermarketInfoMapper.deleteSupermarketInfoBySupermarketIds(supermarketIds);
}