package com.keyware.shandan.bianmu.services;

import com.keyware.shandan.bianmu.mapper.AnalysisMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AnalysisService {

    @Autowired
    private AnalysisMapper analysisMapper;


    public List<Map<String, Object>> counts12Months() {
        return analysisMapper.countsBy12Months();
    }

    public List<Map<String, Object>> countsByResourceType(String orgId) {
        return analysisMapper.countsByResourceType(orgId);
    }

    public List<Map<String, Object>> countsByDirectoryLink(String orgId) {
        return analysisMapper.countsByDirectoryLink(orgId);
    }

    public Object countsByResourceNumber(String orgId, String type) {
        if("org".equalsIgnoreCase(type)){
            return analysisMapper.countsByOrgResourceNumber(orgId);
        }else if("user".equalsIgnoreCase(type)){
            return analysisMapper.countsByUserResourceNumber(orgId);
        }else{
            throw new RuntimeException("参数错误：type必须为“org”或者“user”");
        }
    }
}
