package com.x.attendance.assemble.control.service; import com.x.attendance.assemble.control.Business; import com.x.attendance.entity.AttendanceSelfHoliday; import com.x.base.core.container.EntityManagerContainer; import com.x.base.core.project.cache.CacheManager; import com.x.base.core.project.cache.Cache.CacheCategory; import com.x.base.core.project.cache.Cache.CacheKey; import java.util.List; import java.util.Map; import java.util.Optional; public class AttendanceSelfHolidayService { private CacheCategory cache_AttendanceSelfHoliday = new CacheCategory( AttendanceSelfHoliday.class); public AttendanceSelfHoliday get( EntityManagerContainer emc, String id ) throws Exception { if( id == null || id.isEmpty() ){ return null; } return emc.find(id, AttendanceSelfHoliday.class); } public List list(EntityManagerContainer emc, List ids) throws Exception { if( ids == null || ids.isEmpty() ){ return null; } Business business = new Business( emc ); return business.getAttendanceSelfHolidayFactory().list( ids ); } public List listAll(EntityManagerContainer emc) throws Exception { Business business = new Business( emc ); return business.getAttendanceSelfHolidayFactory().listAll(); } public List listWithPersonFromCache( EntityManagerContainer emc, String person, boolean debugger) throws Exception { //String cacheKey = ApplicationCache.concreteCacheKey( "list#" + person ); //Element element = cache_AttendanceSelfHoliday.get(cacheKey); CacheKey cacheKey = new CacheKey(this.getClass(),"list" , person); Optional optional = CacheManager.get(cache_AttendanceSelfHoliday, cacheKey); if (optional.isPresent()) { return ((List)optional.get()); }else{ List ids = getByPersonName( emc, person ); List list = list( emc, ids ); CacheManager.put(cache_AttendanceSelfHoliday, cacheKey,list); return list; } } public List getByPersonName(EntityManagerContainer emc, String personName) throws Exception { Business business = new Business( emc ); return business.getAttendanceSelfHolidayFactory().getByPersonName( personName ); } public List listWithBatchFlag(EntityManagerContainer emc, String batchFlag) throws Exception { Business business = new Business(emc); return business.getAttendanceSelfHolidayFactory().listWithBatchFlag( batchFlag ); } }