package com.ruoyi.web.controller.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.mall.domain.Vo.SchoolLevelVO;
import com.ruoyi.mall.domain.Vo.SchoolTypeVO;
import com.ruoyi.mall.mapper.*;
import com.ruoyi.mall.service.IMallConfigLevelService;
import com.ruoyi.set.domain.SetRegion;
import com.ruoyi.set.mapper.SetRegionMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.*;

/**志愿填报(自主选择) 筛选菜单*/
@RestController
@RequestMapping("/api/CheckingOutMenu")
public class ApiCheckingOutMenuController extends BaseController {

    @Resource
    private MallConfigMapper mallConfigMapper;
    @Resource
    private MallLinkMajorSchoolMapper mallLinkMajorSchoolMapper;
    @Resource
    private MallSchoolMapper mallSchoolMapper;
    @Resource
    private IMallConfigLevelService mallConfigLevelService;
    @Resource
    private MallMajorRankingMapper mallMajorRankingMapper;

    @Resource
    private SetRegionMapper setRegionMapper;
    @Resource
    private MallConfigTypeMapper mallConfigTypeMapper;
    @Resource
    private MallMajorClassMapper mallMajorClassMapper;

    /**筛选学校菜单*/
    @GetMapping("/getSchoolMenu")
    public AjaxResult getMenu() {
        try{
            Map<String,Object> result = new HashMap<>();
            /*学校层次*///学校层次(单选) mall_config_level
            List<SchoolLevelVO> schoolLevelVOS = mallConfigLevelService.selectLevelList();
            result.put("学校层次",schoolLevelVOS);
            /*所在省份*///所在省份(多选) tb_region表 字段 type=1
            List<SetRegion> setRegions = setRegionMapper.selectRegionProvinceList();
            result.put("所在省份",setRegions);
            /*学校类型*///学校类型(单选) mall_config_type表
            List<SchoolTypeVO> schoolTypeVOS = mallConfigTypeMapper.selectConfigTypeList();
            result.put("学校类型",schoolTypeVOS);
            return AjaxResult.success().put("data",result);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("公告列表查询异常");
        }
    }

    /**筛选专业菜单*/
    @GetMapping("/getMajorMenu")
    public AjaxResult getMajorMenu() {
        try{
            /*专业 大类下面是细分专业*/// 专业大类(mall_major_class) 选具体专业  专业分析 专业分类
            Map<String,Object> result = new HashMap<>();
            List<Map<String, Object>> maps = mallMajorClassMapper.selectOneOrTwoMallMajorClassList(0L);
            for (Map<String, Object> map : maps) {
                String subjectName = String.valueOf(map.get("majorName"));
                Object o = map.get("majorId");
                Long subjectId = Long.valueOf(String.valueOf(o));
                List<Map<String, Object>> child_maps = mallMajorClassMapper.selectOneOrTwoMallMajorClassList(subjectId);
                result.put(subjectName,child_maps);
            }
            return AjaxResult.success().put("data",result);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("公告列表查询异常");
        }
    }

    /**筛选评估菜单*/
    @GetMapping("/getAssessMenu")
    public AjaxResult getAssessMenu() {
        try{
            Map<String, Map<String,List<String>>> result = new HashMap<>();
                Map<String,List<String>> a = new HashMap<>();
            /*大类学科评估*/
                /*学科评估榜单*///
                 List<String> rankingMenuForReport = mallMajorRankingMapper.rankingMenuForReport("4");
                a.put("学科评估榜上有名(教育部）",rankingMenuForReport);
            /*开设硕士点*///配置表 8 masters_degree
                 //List<Object> masterDetailList = mallSchoolMapper.masterDetailList();
            List<String> masterDetailList = new ArrayList<>();
            masterDetailList.add("1-10"); // 1-10
            masterDetailList.add("11-20"); // 11-20
            masterDetailList.add("21-30"); // 21-30
            masterDetailList.add("31-40"); // 31- 40
            masterDetailList.add("41-50"); // 41-50
            masterDetailList.add("50以上"); // 大于50
            a.put("开设硕士点",masterDetailList);
                /*开设博士点*///配置表 9 doctorate
                 //List<Object> doctorateDetailList = mallSchoolMapper.doctorateDetailList();
            List<String> doctorateDetailList = new ArrayList<>();
            doctorateDetailList.add("1-10");
            doctorateDetailList.add("11-20");
            doctorateDetailList.add("21-30");
            doctorateDetailList.add("31-40");
            doctorateDetailList.add("41-50");
            doctorateDetailList.add("50以上");
                a.put("开设博士点",doctorateDetailList);

                /*其他（学科）*///配置表 10 subject_other
                List<String> otherSubjectTagList = mallLinkMajorSchoolMapper.otherSubjectTagList();
                a.put("其他",otherSubjectTagList);
                result.put("大类学科评估",a);
            ///*细分专业评估*/
            //    Map<String,List<String >> b = new HashMap<>();
            //    /*硕士点研究方向*/
            //    List<String> masterDirectionList = mallLinkMajorSchoolMapper.masterDirectionList();
            //    b.put("硕士点研究方向",masterDirectionList);
            //        /*博士点研究方向*/
            //        List<String> doctorateDirectionList = mallLinkMajorSchoolMapper.doctorateDirectionList();
            //    b.put("博士点研究方向",doctorateDirectionList);
            //        /*其他*///学校专业关联表
            //        List<String> otherMajorTagList = mallLinkMajorSchoolMapper.otherMajorTagList();
            //    b.put("其他",otherMajorTagList);
            //     result.put("细分专业评估",b);
           /*二合一*/
            return AjaxResult.success().put("data",result);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("公告列表查询异常");
        }
    }


}
