/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.platform.service.impl;

import com.crunii.micro.domain.entity.main.TsmTemplate;
import com.crunii.micro.platform.jdbc.TemplateJdbcDao;
import com.crunii.micro.platform.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

/**
 * @author 田平 create 2020年1月9日上午11:31:26
 */
@Slf4j
public class TemplateServiceImpl implements TemplateService {

	@Autowired
	private TemplateJdbcDao tempJdbcDao;

	@Override
	@Cacheable(cacheNames = "GlobalCacheTemplate")
	public TsmTemplate getTemplate(String tempCode) {
		TsmTemplate temp = tempJdbcDao.getTemplate(tempCode);
		log.info("Load Template tempCode:{} from database result:{} !", tempCode, temp == null ? "null" : temp.getNoContentStr());
		return temp;
	}

	@Override
	@CacheEvict(cacheNames = "GlobalCacheTemplate")
	public void evictTemplateCache(String tempCode) {

	}

	@Override
	@CacheEvict(cacheNames = "GlobalCacheTemplate", allEntries = true)
	public void evictAllTemplateCache() {

	}
}
