package com.goafanti.common.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.goafanti.common.dao.IndustryCategoryMapper;
import com.goafanti.common.model.IndustryCategory;
import com.goafanti.common.utils.LoggerUtils;

@Service
public class IndustryCategoryService {

	private static final Logger	logger	= LoggerFactory.getLogger(IndustryCategoryService.class);

	@Autowired
	IndustryCategoryMapper		industryCategoryMapper;

	@Cacheable(value = "IndustryCategoryCache", key = "'IndustryCategory:'+#pid")
	public List<IndustryCategory> list(Integer pid) {
		LoggerUtils.debug(logger, "缓存行业列表:[%s]", pid);
		return industryCategoryMapper.listByPid(pid);
	}

	@CacheEvict(value = "IndustryCategoryCache", key = "'IndustryCategory:'+#pid")
	public void clear(Integer pid) {
		LoggerUtils.debug(logger, "清除行业列表缓存:[%s]", pid);
	}

}
