package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.mapper.SysDailyMapper;
import com.ruoyi.system.service.ISysDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Shawn
 */
@Service
public class ISysDailyServiceImpl implements ISysDailyService {

    @Autowired
    private SysDailyMapper dailyMapper;

    @Override
    public String selectStatus(String id, String dateAt) {
        List<String> list = dailyMapper.selectStatus(id, dateAt, dateAt.split("-")[0] + dateAt.split("-")[1]);
        if(list.size() == 0){
            return null;
        }else{
            return "0";
        }
    }

    @Override
    public void setDailyStatus(String id, String username, String projectId, String dateAt) {
        if(projectId.contains(",")){
            for (String s : projectId.split(",")) {
                dailyMapper.insertDailyStatus(id,username, s,dateAt,dateAt.split("-")[0]+dateAt.split("-")[1]);
            }
        }else if(projectId.contains("，")){
            for (String s : projectId.split("，")) {
                dailyMapper.insertDailyStatus(id, username, s,dateAt,dateAt.split("-")[0]+dateAt.split("-")[1]);
            }
        }else{
                dailyMapper.insertDailyStatus(id, username, projectId,dateAt,dateAt.split("-")[0]+dateAt.split("-")[1]);
        }
    }
}
