package com.hzya.frame.sysnew.integtationTask.service.impl;

import com.hzya.frame.sysnew.application.plugin.dao.ISysApplicationPluginDao;
import com.hzya.frame.sysnew.application.plugin.entity.SysApplicationPluginDto;
import com.hzya.frame.sysnew.application.plugin.entity.SysApplicationPluginEntity;
import com.hzya.frame.sysnew.integtationTask.IIntegrationTaskCacheableService;
import com.hzya.frame.sysnew.integtationTask.dao.IIntegrationTaskDao;
import com.hzya.frame.sysnew.integtationTask.entity.IntegrationTaskEntity;
import com.hzya.frame.sysnew.integtationTaskLiving.dao.IIntegrationTaskLivingDao;
import com.hzya.frame.sysnew.integtationTaskLiving.entity.IntegrationTaskLivingEntity;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 集成任务缓存服务实现类
 *
 * @author makejava
 * @since 2024-05-06 15:36:12
 */
@Service(value = "integrationTaskCacheableService")
public class IntegrationTaskCacheableServiceImpl implements IIntegrationTaskCacheableService {
	@Resource
	private IIntegrationTaskDao integrationTaskDao;
    @Resource
    private IIntegrationTaskLivingDao iIntegrationTaskLivingDao;
    @Resource
    private ISysApplicationPluginDao iSysApplicationPluginDao;
	@Override
	@Cacheable(cacheNames="IntegrationTask",key = "#id")
	public IntegrationTaskEntity getIntegrationTaskEntity(String id) {
		IntegrationTaskEntity entity = null;
		if(id != null && !"".equals(id)){
			entity = integrationTaskDao.get(id);
		}
		return entity;
	}

	@Override
	@CacheEvict(cacheNames="IntegrationTask",key = "#entity.id")
	public IntegrationTaskEntity updateIntegrationTaskEntity(IntegrationTaskEntity entity) {
		if(entity.getId() != null && !"".equals(entity.getId())){
			integrationTaskDao.update(entity);
		}
		return entity;
	}
	@Override
	@CacheEvict(cacheNames="IntegrationTask",key = "#entity.id")
	public void deleteIntegrationTaskEntity(IntegrationTaskEntity entity) {
		integrationTaskDao.logicRemove(entity);
	}


	@Override
	@Cacheable(cacheNames="IntegrationTaskLiving",key = "#id")
	public IntegrationTaskLivingEntity getIntegrationTaskLivingEntity(String id) {
		IntegrationTaskLivingEntity entity = null;
		if(id != null && !"".equals(id)){
			entity = iIntegrationTaskLivingDao.get(id);
		}
		return entity;
	}

	@Override
	@CacheEvict(cacheNames="IntegrationTaskLiving",key = "#entity.id")
	public IntegrationTaskLivingEntity updateIntegrationTaskLivingEntity(IntegrationTaskLivingEntity entity) {
		if(entity.getId() != null && !"".equals(entity.getId())){
			iIntegrationTaskLivingDao.update(entity);
		}
		return entity;
	}
	@Override
	@CacheEvict(cacheNames="IntegrationTaskLiving",key = "#entity.id")
	public void deleteIntegrationTaskLivingEntity(IntegrationTaskLivingEntity entity) {
		iIntegrationTaskLivingDao.logicRemove(entity);
	}


	@Override
	@Cacheable(cacheNames="sysApplicationPlugin",key = "#id")
	public SysApplicationPluginEntity getSysApplicationPluginEntity(String id) {
		SysApplicationPluginEntity entity = null;
		if(id != null && !"".equals(id)){
			entity = iSysApplicationPluginDao.get(id);
		}
		return entity;
	}

	@Override
	@CacheEvict(cacheNames="sysApplicationPlugin",key = "#entity.id")
	public SysApplicationPluginEntity updateSysApplicationPluginEntity(SysApplicationPluginEntity entity) {
		if(entity.getId() != null && !"".equals(entity.getId())){
			iSysApplicationPluginDao.update(entity);
		}
		return entity;
	}
	@Override
	@CacheEvict(cacheNames="sysApplicationPlugin",key = "#entity.id")
	public void deleteSysApplicationPluginEntity(SysApplicationPluginEntity entity) {
		iSysApplicationPluginDao.logicRemove(entity);
	}
}
