package com.ruoyi.web.controller.api;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.mall.domain.MallExamSection;
import com.ruoyi.mall.domain.Vo.SchoolVO;
import com.ruoyi.mall.service.IMallSchoolService;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 升学规划
 * @author 萌
 */
@RestController
@RequestMapping("/api/enterPlan")
public class ApiEnterPlanController {

    @Resource
    private IMallSchoolService mallSchoolService;

    /**
     * 升学规划-目标学校列表
     * @param id 用户id
     * @param batchId 批次id
     * @param schoolName 学校名称
     * @param majorId 专业id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/enterPlanTargetList")
    public AjaxResult enterPlanTargetList(@RequestParam Long id,
                                          @RequestParam Long batchId,
                                          @RequestParam(required = false) String schoolName,
                                          @RequestParam(required = false) Long majorId,
                                          @RequestParam(defaultValue = "1") Integer pageNum,
                                          @RequestParam(defaultValue = "10") Integer pageSize){
        if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少用户id");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }

        try {
            return AjaxResult.success(mallSchoolService.enterPlanTargetList(id, batchId, schoolName, majorId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 升学规划-分类查询列表
     * @param rateType 类别(-1-全部, 0-可冒险, 1-搏一搏,2-较稳妥,3-可保底)
     * @param id 用户id
     * @param batchId 批次id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/enterPlanSchoolListByType")
    public AjaxResult enterPlanSchoolListByType(@RequestParam Integer rateType,
                                                @RequestParam Long id,
                                                @RequestParam Long batchId,
                                                @RequestParam(required = false) String schoolName,
                                                @RequestParam(required = false) Long majorId ,
                                                @RequestParam(defaultValue = "1")Integer pageNum,
                                                @RequestParam(defaultValue = "10") Integer pageSize){
        if (ObjectUtils.isEmpty(rateType)){
            return AjaxResult.error("缺少rateType");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少id");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }
        try{

            return mallSchoolService.enterPlanSchoolListByType(rateType, id, batchId, schoolName, majorId, pageNum, pageSize);

        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

}
