删除超市原料时加保护
This commit is contained in:
parent
70aa1c50fa
commit
cba0e5bc7b
|
|
@ -18,6 +18,8 @@ public interface SupermarketProductMapper {
|
|||
*/
|
||||
public SupermarketProduct selectSupermarketProductByProductId(Long productId);
|
||||
|
||||
public List<SupermarketProduct> selectSupermarketProductByMaterialIds(Long[] materialIds);
|
||||
|
||||
/**
|
||||
* 查询超市商城商品列表
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.bonus.canteen.core.supermarket.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.supermarket.domain.SupermarketProduct;
|
||||
import com.bonus.canteen.core.supermarket.mapper.SupermarketProductMapper;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -8,6 +11,7 @@ import org.springframework.stereotype.Service;
|
|||
import com.bonus.canteen.core.supermarket.mapper.SupermarketMaterialMapper;
|
||||
import com.bonus.canteen.core.supermarket.domain.SupermarketMaterial;
|
||||
import com.bonus.canteen.core.supermarket.service.ISupermarketMaterialService;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* 商品信息Service业务层处理
|
||||
|
|
@ -19,6 +23,8 @@ import com.bonus.canteen.core.supermarket.service.ISupermarketMaterialService;
|
|||
public class SupermarketMaterialServiceImpl implements ISupermarketMaterialService {
|
||||
@Autowired
|
||||
private SupermarketMaterialMapper supermarketMaterialMapper;
|
||||
@Autowired
|
||||
private SupermarketProductMapper supermarketProductMapper;
|
||||
|
||||
/**
|
||||
* 查询商品信息
|
||||
|
|
@ -82,6 +88,10 @@ public class SupermarketMaterialServiceImpl implements ISupermarketMaterialServi
|
|||
*/
|
||||
@Override
|
||||
public int deleteSupermarketMaterialByMaterialIds(Long[] materialIds) {
|
||||
List<SupermarketProduct> list = supermarketProductMapper.selectSupermarketProductByMaterialIds(materialIds);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
throw new ServiceException("该原料下含有商品,不能删除");
|
||||
}
|
||||
return supermarketMaterialMapper.deleteSupermarketMaterialByMaterialIds(materialIds);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectSupermarketProductVo">
|
||||
select product_id, supermarket_id, material_id, putaway_state, if_online, sale_price, pref_price, person_limit, one_day_limit, img_url, inventory_num, create_by, create_time, update_by, update_time from supermarket_product
|
||||
select product_id, supermarket_id, material_id, putaway_state, if_online, sale_price, pref_price,
|
||||
person_limit, one_day_limit, img_url, inventory_num, create_by, create_time, update_by, update_time
|
||||
from supermarket_product
|
||||
</sql>
|
||||
|
||||
<select id="selectSupermarketProductList" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" resultMap="SupermarketProductResult">
|
||||
|
|
@ -45,6 +47,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectSupermarketProductVo"/>
|
||||
where product_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="selectSupermarketProductByMaterialIds" parameterType="String" resultType="SupermarketProductResult">
|
||||
<include refid="selectSupermarketProductVo"/>
|
||||
where material_id in
|
||||
<foreach item="materialId" collection="array" open="(" separator="," close=")">
|
||||
#{materialId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="insertSupermarketProduct" parameterType="com.bonus.canteen.core.supermarket.domain.SupermarketProduct" useGeneratedKeys="true" keyProperty="productId">
|
||||
insert into supermarket_product
|
||||
|
|
|
|||
Loading…
Reference in New Issue