package com.izouma.nineth.repo;

import com.izouma.nineth.domain.SysConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import javax.annotation.Nonnull;
import java.util.Optional;

public interface SysConfigRepo extends JpaRepository<SysConfig, String>, JpaSpecificationExecutor<SysConfig> {
    @Cacheable("sysConfig")
    Optional<SysConfig> findByName(String name);

    @Override
    @CachePut(value = "sysConfig", key = "#record.name")
    @Nonnull
    SysConfig save(@Nonnull SysConfig record);
}