package com.ecep.contract.service;

import java.util.List;

import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import com.ecep.contract.vm.VendorCatalogViewModel;
import com.ecep.contract.vo.VendorCatalogVo;

@Service
@CacheConfig(cacheNames = "vendor-catalog")
public class VendorCatalogService extends QueryService<VendorCatalogVo, VendorCatalogViewModel> {
    @Override
    @Cacheable(key = "#id")
    public VendorCatalogVo findById(Integer id) {
        return super.findById(id);
    }

    @Override
    @Cacheable(key = "all")
    public List<VendorCatalogVo> findAll() {
        return super.findAll();
    }

    @Caching(evict = { @CacheEvict(key = "all"), @CacheEvict(key = "#entity.id") })
    @Override
    public VendorCatalogVo save(VendorCatalogVo entity) {
        return super.save(entity);
    }

    @Caching(evict = { @CacheEvict(key = "all"), @CacheEvict(key = "#entity.id") })
    @Override
    public void delete(VendorCatalogVo entity) {
        super.delete(entity);
    }
}
