package net.northking.cctp.scriptcase.pub.workbench.service;

import net.northking.cctp.scriptcase.db.service.AtuSceneInfoService;
import net.northking.cctp.scriptcase.db.service.AtuScriptInfoService;
import net.northking.cctp.scriptcase.pub.workbench.vo.WorkbenchUIScriptNumVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;

@Service
public class WorkbenchDataServiceImpl implements WorkbenchDataService {

    @Resource
    private AtuScriptInfoService atuScriptInfoService;

    @Resource
    private AtuSceneInfoService atuSceneInfoService;

    /**
     * 工作台 UI脚本相关数据
     *
     * 1.登录用户当日负责的新增脚本数(不区分一般脚本和场景脚本)
     * 2.登录用户当月负责的新增脚本数(不区分一般脚本和场景脚本)
     * 3.登录用户总计负责一般脚本数
     * 4.登录用户总计负责场景脚本数
     * @param principalId
     */
    @Override
    public WorkbenchUIScriptNumVO getScriptNumByPrincipalId(String principalId) {
        WorkbenchUIScriptNumVO scriptNumVO = new WorkbenchUIScriptNumVO();
        LocalDate now = LocalDate.now();
        Integer todayNewAllScriptNum = atuScriptInfoService.todayNewAllScriptNumByPrincipalId(now, principalId);
        Integer currentMonthAllScriptNum = atuScriptInfoService.currentMonthAllScriptNumByPrincipalId(now, principalId);
        Integer allCommonScriptNum = atuScriptInfoService.allCommonScriptNumByPrincipalId(principalId);
        Integer allSceneScriptNum = atuSceneInfoService.allSceneScriptNumByPrincipalId(principalId);
        scriptNumVO.setTodayNewAllScriptNum(todayNewAllScriptNum);
        scriptNumVO.setCurrentMonthAllScriptNum(currentMonthAllScriptNum);
        scriptNumVO.setAllCommonScriptNum(allCommonScriptNum);
        scriptNumVO.setAllSceneScriptNum(allSceneScriptNum);
        return scriptNumVO;
    }
}
