This commit is contained in:
sxu 2025-05-15 10:10:37 +08:00
parent 2c43e80e1e
commit bb2d95709c
3 changed files with 17 additions and 0 deletions

View File

@ -57,4 +57,6 @@ public interface SupermarketProductMapper {
* @return 结果
*/
public int deleteSupermarketProductByProductIds(Long[] productIds);
public int getProductCountOfSupermarket(Long[] supermarketIds);
}

View File

@ -1,6 +1,8 @@
package com.bonus.canteen.core.supermarket.service.impl;
import java.util.List;
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;
@ -20,6 +22,8 @@ import com.bonus.canteen.core.supermarket.service.ISupermarketInfoService;
public class SupermarketInfoServiceImpl implements ISupermarketInfoService {
@Autowired
private SupermarketInfoMapper supermarketInfoMapper;
@Autowired
SupermarketProductMapper supermarketProductMapper;
/**
* 查询超市
@ -85,6 +89,10 @@ public class SupermarketInfoServiceImpl implements ISupermarketInfoService {
*/
@Override
public int deleteSupermarketInfoBySupermarketIds(Long[] supermarketIds) {
int count = supermarketProductMapper.getProductCountOfSupermarket(supermarketIds);
if (count > 0) {
throw new ServiceException("该超市含有商品,不能删除");
}
return supermarketInfoMapper.deleteSupermarketInfoBySupermarketIds(supermarketIds);
}

View File

@ -173,4 +173,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{productId}
</foreach>
</delete>
<select id="getProductCountOfSupermarket" parameterType="String">
select count(1) from supermarket_product where supermarket_id in
<foreach item="supermarketId" collection="array" open="(" separator="," close=")">
#{supermarketId}
</foreach>
</select>
</mapper>