package com.jeequan.jeepay.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.db.entity.ProductInfo;
import com.jeequan.jeepay.db.entity.ProductType;
import com.jeequan.jeepay.service.mapper.ProductInfoMapper;
import com.jeequan.jeepay.service.mapper.ProductTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * <p>
 * 产品分类表 服务实现类
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2022-03-12
 */
@Service
public class ProductTypeService extends ServiceImpl<ProductTypeMapper, ProductType> {

    @Autowired private ProductTypeMapper productTypeMapper;

    @Transactional(rollbackFor = Exception.class)
    public void deleteProductType(String typeId) {
        // 当前产品是否存在
        ProductType type = getById(typeId);
        if (type == null) {
            throw new BizException("该分类不存在");
        }
        productTypeMapper.deleteById(typeId);
    }

}
