package com.ecep.contract.service;

import com.ecep.contract.model.VendorFileTypeLocal;
import com.ecep.contract.vm.VendorFileTypeLocalViewModel;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@CacheConfig(cacheNames = "vendor-file-type")
public class VendorFileTypeService extends QueryService<VendorFileTypeLocal, VendorFileTypeLocalViewModel> {
    @Cacheable(key = "#p0")
    @Override
    public VendorFileTypeLocal findById(Integer id) {
        return super.findById(id);
    }

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

    @Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
    @Override
    public VendorFileTypeLocal save(VendorFileTypeLocal entity) {
        return super.save(entity);
    }

    @Caching(put = {@CachePut(key = "#p0.id"), @CachePut(key = "'all'")})
    @Override
    public void delete(VendorFileTypeLocal entity) {
        super.delete(entity);
    }
}
