package cn.gov.customs.demo.service.impl;

import cn.gov.customs.demo.constants.Constants;
import cn.gov.customs.demo.dao.OrderCategoryDao;
import cn.gov.customs.demo.pojo.OrderCategoryInfo;
import cn.gov.customs.demo.service.OrderCategoryService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @description TODO
 * @author sunxuewen
 * @since 2024/11/21 上午8:25
 */
@Service
@RequiredArgsConstructor
@CacheConfig(cacheNames = Constants.CACHE_NAME)
public class OrderCategoryServiceImpl implements OrderCategoryService {

  private static final String CACHE_KEY = "'ORDER_CATEGORY'";

  private final OrderCategoryDao mapper;

  @Cacheable(key = CACHE_KEY)
  @Override
  public List<OrderCategoryInfo> getList() {
    return this.mapper.getList();
  }

  @CacheEvict(key = CACHE_KEY)
  @Override
  public int insert(OrderCategoryInfo info) {
    return this.mapper.insert(info);
  }

  @CacheEvict(key = CACHE_KEY)
  @Override
  public int update(OrderCategoryInfo info) {
    return this.mapper.update(info);
  }

  @CacheEvict(key = CACHE_KEY)
  @Override
  public int delete(String categoryCode) {
    return this.mapper.delete(categoryCode);
  }
}
