All Downloads are FREE. Search and download functionalities are using the official Maven repository.

group.rober.base.detector.service.DetectorService Maven / Gradle / Ivy

The newest version!
package group.rober.base.detector.service;

import group.rober.base.detector.model.Detector;
import group.rober.base.detector.model.DetectorItem;
import group.rober.sql.core.DataAccessor;
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 java.util.List;

@Service
public class DetectorService {
    public static final String CACHE_KEY = "DetectorCache";

    @Autowired
    protected DataAccessor dataAccessor;

    @Cacheable(value = CACHE_KEY, key = "#code")
    public Detector getDetector(String code) {

        Detector detector = dataAccessor.selectOne(Detector.class,
                "select * from CONF_DETECTOR where CODE=:code"
                , "code", code);
        if (detector != null) {
            List detectorItemList =
                    dataAccessor.selectList(DetectorItem.class
                            , "select * from CONF_DETECTOR_ITEM where DETECTOR_CODE=:detectorCode and ITEM_STATUS=:itemStatus order by SORT_CODE ASC,GROUP_CODE ASC,ITEM_CODE ASC"
                            , "detectorCode", code,
                            "itemStatus", "VALID");
            detector.setItems(detectorItemList);
        }


        return detector;
    }

    /**
     * 清空缓存
     */
    @CacheEvict(value=CACHE_KEY,allEntries=true,beforeInvocation=true)
    public void clearCacheAll(){

    }

    /**
     * 清空缓存
     */
    @CacheEvict(value=CACHE_KEY,key="#code",beforeInvocation=true)
    public void clearCacheItem(String code){
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy