package com.yanzhu.jh.bigscreen.web.controller;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.yanzhu.jh.base.domain.BasePeriodical;
import com.yanzhu.jh.base.service.IBasePeriodicalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/bgscreen/periodical")
public class PeriodicalController {

    @Autowired
    IBasePeriodicalService periodicalService;
    @Autowired
    private RedisCache redisCache;

    @GetMapping("/getList")
    public AjaxResult getList() {
        String key="bgscreen_periodical_getList";
        Object obj=redisCache.getCacheObject(key);
        if(obj!=null){
           // return AjaxResult.success(obj);
        }
        BasePeriodical where = new BasePeriodical();
        where.setIsDel(0l);
        List<BasePeriodical> list = periodicalService.selectBasePeriodicalList(where);
        redisCache.setCacheObject(key, list, Constants.BIGSCREEN_QUERY_CACHE, TimeUnit.MINUTES);
        return AjaxResult.success(list);
    }

}
