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.project.domain.SurProjectStandard;
import com.yanzhu.jh.project.service.ISurProjectStandardService;
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/standard")
public class ProjectStandardController {
    @Autowired
    ISurProjectStandardService standardService;

    @Autowired
    private RedisCache redisCache;

    @GetMapping("/getList")
    public AjaxResult getList(Long deptId,Long projectId){
        SurProjectStandard where=new SurProjectStandard();
        where.setProjectId(projectId);
        where.setIsDel(0l);
        String key="bgscreen_standard_getList_"+projectId;
        Object obj=redisCache.getCacheObject(key);
        if(obj!=null){
            return AjaxResult.success(obj);
        }
        List<SurProjectStandard> list=standardService.selectSurProjectStandardList(where);
        redisCache.setCacheObject(key, list, Constants.BIGSCREEN_QUERY_CACHE, TimeUnit.MINUTES);
        return AjaxResult.success(list);
    }
}
