package com.jsh.erp.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.vo.TreeNode;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public interface MaterialCategoryService extends IService<MaterialCategory> {


    MaterialCategory getMaterialCategory(long id)throws Exception;

    List<MaterialCategory> getMaterialCategoryListByIds(String ids)throws Exception;

    List<MaterialCategory> getMaterialCategory()throws Exception;

    List<MaterialCategory> getAllList(Long parentId)throws Exception;

    List<MaterialCategory> getMCList(Long parentId)throws Exception;

    List<MaterialCategory> select(String name, Integer parentId) throws Exception;

    /**
     * 新增商品类别
     * @param obj 商品类别数据
     */
    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int insertMaterialCategory(JSONObject obj, HttpServletRequest request)throws Exception;

    /**
     * 修改商品类别
     * @param obj 商品类别数据
     */
    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int updateMaterialCategory(JSONObject obj, HttpServletRequest request) throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int deleteMaterialCategory(Long id, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchDeleteMaterialCategory(String ids, HttpServletRequest request)throws Exception;

    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
    int batchDeleteMaterialCategoryByIds(String ids) throws Exception;

    int checkIsNameExist(Long id, String name)throws Exception;

    List<MaterialCategory> findById(Long id)throws Exception;

    List<TreeNode> getMaterialCategoryTree(Long id) throws Exception;

    void  checkMaterialCategorySerialNo(MaterialCategory mc)throws Exception;

    /**
     * 根据名称获取类型
     * @param name
     */
    Long getCategoryIdByName(String name);
}
