package com.YuyeTech.HeartRate.service.impl;

import com.YuyeTech.HeartRate.dataobject.ProductCategory;
import com.YuyeTech.HeartRate.repository.ProductCategoryRepository;
import com.YuyeTech.HeartRate.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类目
 * @author:slambb
 * @date:2019/12/2
 * 1.implements  CategoryService 接口
 * 2.继承实现
 * 3.需要添加service注解
 */
@Service
public class CategoryServiceImpl implements CategoryService {

    //引入dto 层
    @Autowired
    private ProductCategoryRepository repository;

    @Override
    public ProductCategory findOne(Integer categoryId) {
        //TODO 后续修改，暂时这样写
        return repository.findById(categoryId).orElse(null);
    }

    @Override
    public List<ProductCategory> findAll() {
        return repository.findAll();
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList) {
        return repository.findByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public ProductCategory save(ProductCategory productCategory) {
        return repository.save(productCategory);
    }
}
