package com.ruoyi.web.controller.api;

import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.mall.domain.Bo.CheckingOutParamBo;
import com.ruoyi.mall.domain.Bo.ExpectBO;
import com.ruoyi.mall.domain.Bo.MatchSchoolBO;
import com.ruoyi.mall.domain.Vo.SchoolVO;
import com.ruoyi.mall.service.*;

import org.apache.commons.lang3.ObjectUtils;
import org.apache.poi.hpsf.Decimal;
import org.checkerframework.checker.units.qual.A;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

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

/**
 * 学校信息控制层
 * @author 萌
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/api/school")
public class ApiSchoolController {

    @Resource
    private IMallSchoolService mallSchoolService;

    @Resource
    private IMallBatchService mallBatchService;

    @Resource
    private IMallConfigLevelService mallConfigLevelService;

    @Resource
    private IMallConfigTypeService mallConfigTypeService;

    @Resource
    private IMallBatchDetailService mallBatchDetailService;

    @Resource
    private IMallSubjectClassService mallSubjectClassService;

    @Resource
    private IMallConfigService mallConfigService;

    @Resource
    private IMallTestSchoolService mallTestSchoolService;

    @Resource
    private IMallSchoolAcceptRulesService mallSchoolAcceptRulesService;

    @Resource
    private IMallArtService mallArtService;

    @Resource
    private IMallMemberExpectService mallMemberExpectService;

    @Resource
    private IMallSchoolAcceptService mallSchoolAcceptService;

    @Resource IMallSchoolAcceptRecordService mallSchoolAcceptRecordService;

    @Resource
    private IMallMajorClassService majorClassService;
    @Resource
    private IMallLinkMajorSchoolService linkMajorSchoolService;
    @Resource
    private IMallMemberUserService memberUserService;

    /**
     * 学校列表
     * @param schoolName 学校名城
     * @param batchId 批次id
     * @param configLevelId 办学层次id
     * @param configTypeId 学校类型id
     * @param provinceId 省份id
     * @param cityId 城市id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectSchoolList")
    public AjaxResult selectSchoolList(@RequestParam(required = false) String schoolName,
                                       @RequestParam Long batchId,
                                       @RequestParam(required = false)Long configLevelId,
                                       @RequestParam(required = false)Long configTypeId,
                                       @RequestParam(required = false)Long provinceId,
                                       @RequestParam(required = false)Long cityId ,
                                       @RequestParam(required = false) Long id,
                                       @RequestParam(defaultValue = "1")Integer pageNum,
                                       @RequestParam(defaultValue = "10")Integer pageSize){
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolList(schoolName, batchId, configLevelId, configTypeId, provinceId, cityId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 学校概况
     * @param schoolId 学校id
     * @return 结果
     */
    @GetMapping("/selectSchoolDetail")
    public AjaxResult selectSchoolDetail(@RequestParam Long id,
                                         @RequestParam Long schoolId,
                                         @RequestParam Long batchId){
        if(ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少id");
        }else if(ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolDetail( id,  schoolId,  batchId));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 学校介绍详情
     * @param schoolId 学校id
     * @return 结果
     */
    @GetMapping("/selectSchoolIntroduceDetail")
    public AjaxResult selectSchoolIntroduceDetail(@RequestParam Long schoolId){
        if(ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolIntroduceDetail(schoolId));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 校园风景
     * @param schoolId 校园id
     * @param pageNum 页码
     * @param pageSize  每页个数
     * @return 结果
     */
    @GetMapping("/selectSchoolSceneryList")
    public AjaxResult selectSchoolSceneryList(@RequestParam Long schoolId,
                                              @RequestParam(defaultValue = "1") Integer pageNum,
                                              @RequestParam(defaultValue = "10") Integer pageSize){
        if(ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolSceneryList(schoolId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 批次查询条件列表
     * @return 结果
     */
    @GetMapping("/selectBatchList")
    public AjaxResult selectBatchList(){
        try{
            return AjaxResult.success(mallBatchService.selectBatchList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 办学层次查询条件列表
     * @return 结果
     */
    @GetMapping("/selectLevelList")
    public AjaxResult selectLevelList(){
        try{
            return AjaxResult.success(mallConfigLevelService.selectLevelList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 学校类型查询列表
     * @return 结果
     */
    @GetMapping("/selectConfigTypeList")
    public AjaxResult selectConfigTypeList(){
        try{
            return AjaxResult.success(mallConfigTypeService.selectConfigTypeList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 院校录取数据
     * @param schoolId 学校id
     * @param batchId 批次id
     * @return 结果
     */
    @GetMapping("/selectSchoolRecord")
    public AjaxResult selectSchoolRecord(@RequestParam Long schoolId, @RequestParam Long batchId, @RequestParam Long id){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }
        try{
            return mallSchoolService.selectSchoolRecord(schoolId, batchId, id);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 个人
     * @param schoolId
     * @param batchId
     * @param id
     * @return
     */
    @GetMapping("/myTotalScore")
    public AjaxResult myTotalScore(@RequestParam Long schoolId, @RequestParam Long batchId, @RequestParam Long id){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少用户id");
        }
        try {
            return AjaxResult.success(mallSchoolService.myTotalScore(schoolId, batchId, id));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 院校录取数据详情
     * @param schoolAcceptRecordId 录取数据id
     * @return 结果
     */
    @GetMapping("/selectSchoolRecordDetail")
    public AjaxResult selectSchoolRecordDetail(@RequestParam Long schoolAcceptRecordId){
        if (ObjectUtils.isEmpty(schoolAcceptRecordId)){
            return AjaxResult.error("缺少schoolAcceptRecordId");
        }

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

    /**
     * 学校专业评估
     * @param schoolId 学校id
     * @return 结果
     */
    @GetMapping("/selectSchoolAppraiseList")
    public AjaxResult selectSchoolAppraiseList(@RequestParam Long schoolId){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolAppraiseList(schoolId));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 学校相关信息
     * @param schoolId 学校id
     * @param batchId 批次id
     * @param
     * @return 结果
     */
    @GetMapping("/schoolAboutInfo")
    public AjaxResult schoolAboutInfo(Long schoolId, Long batchId, Long id){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else if(ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少用户id");
        }

        try{
            return mallSchoolService.schoolAboutInfo(schoolId, batchId, id);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 批次说明
     * @return
     */
    @GetMapping("/selectBatchDetailList")
    public AjaxResult selectBatchDetailList(){
        try{
            return mallBatchDetailService.selectBatchDetailList();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 层级院校
     * @param configLevelId 结果
     * @param batchId 批次id
     * @return 结果
     */
    @GetMapping("/selectSchoolListByLevel")
    public AjaxResult selectSchoolListByLevel(@RequestParam Long configLevelId,
                                              @RequestParam Long batchId,
                                              @RequestParam Long schoolId,
                                              @RequestParam Long id){
        if (ObjectUtils.isEmpty(configLevelId)){
            return AjaxResult.error("缺少configLevelId");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少用户id");
        }
        try{
            return mallSchoolService.selectSchoolListByLevel(configLevelId, batchId, schoolId, id);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 层级院校更多列表
     * @param configLevelId 层级id
     * @param batchId 批次id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectSchoolListByLevelId")
    public AjaxResult selectSchoolListByLevelId(@RequestParam Long configLevelId,
                                                @RequestParam Long batchId,
                                                @RequestParam Long schoolId,
                                                @RequestParam Long id,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "10") Integer pageSize){
        if (ObjectUtils.isEmpty(configLevelId)){
            return AjaxResult.error("缺少configLevelId");
        }else if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if (ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少用户id");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectSchoolListByLevelId(configLevelId, batchId, schoolId, id,pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 联考成绩分析
     * @param schoolId 学校id
     * @param batchId 批次id
     * @param id 用户id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectUnionTestAnalysisList")
    public AjaxResult selectUnionTestAnalysisList(@RequestParam Long schoolId,
                                                  @RequestParam Long batchId,
                                                  @RequestParam Long id,
                                                  @RequestParam(defaultValue = "1") Integer pageNum,
                                                  @RequestParam(defaultValue = "10") Integer pageSize){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else  if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if(ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少id");
        }
        try{
            return mallSchoolService.selectUnionTestAnalysisList(schoolId, batchId, id, pageNum, pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 综合分录取分析
     * @param schoolId 学校id
     * @param batchId 批次id
     * @param id 用户id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectUserScoreAnalysisList")
    public AjaxResult selectUserScoreAnalysisList(@RequestParam Long schoolId,
                                                  @RequestParam Long batchId,
                                                  @RequestParam Long id,
                                                  @RequestParam(defaultValue = "1") Integer pageNum,
                                                  @RequestParam(defaultValue = "10") Integer pageSize){
        if (ObjectUtils.isEmpty(schoolId)){
            return AjaxResult.error("缺少schoolId");
        }else  if (ObjectUtils.isEmpty(batchId)){
            return AjaxResult.error("缺少batchId");
        }else if(ObjectUtils.isEmpty(id)){
            return AjaxResult.error("缺少id");
        }
        try{
            return AjaxResult.success(mallSchoolService.selectUserScoreAnalysisList(schoolId, batchId, id, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 智能匹配学校
     * @param matchSchoolBO 匹配信息
     * @param bindingResult 校验结果
     * @return 结果
     */
    @PostMapping("/matchSchoolList")
    public AjaxResult matchSchoolList(@RequestBody @Validated MatchSchoolBO matchSchoolBO, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return AjaxResult.allParameterErrors(bindingResult);
        }
        try {
            return mallSchoolService.matchSchoolList(matchSchoolBO);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 学科列表
     * @return 结果
     */
    @GetMapping("/selectSubjectList")
    public AjaxResult selectSubjectList(){
        try {
            return AjaxResult.success(mallSubjectClassService.selectSubjectList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 大学对比
     * @param schoolName 学校名称
     * @param batchId 批次id
     * @param configLevelId 层次id
     * @param configTypeId 学校类型
     * @param provinceId 省份id
     * @param cityId 城市id
     * @param id 用户id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectMatchSchoolList")
    public AjaxResult selectMatchSchoolList(@RequestParam(required = false) String schoolName,
                                            @RequestParam(required = false) Long batchId,
                                            @RequestParam(required = false) Long configLevelId,
                                            @RequestParam(required = false) Long configTypeId,
                                            @RequestParam(required = false) Long provinceId,
                                            @RequestParam(required = false) Long cityId,
                                            @RequestParam Long id,
                                            @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 mallSchoolService.selectMatchSchoolList(schoolName, batchId, configLevelId, configTypeId, provinceId, cityId, id, pageNum, pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 匹配结果同类院校列表查询
     * @param rateType 类型(0-可冒险,1-搏一搏,2-较稳妥,3-可保底)
     * @param id 用户id
     * @param batchId 批次id
     * @param cultureScore 文化分
     * @param majorScore 专业分
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/matchSchoolListByType")
    public AjaxResult matchSchoolListByType(@RequestParam Integer rateType,
                                            @RequestParam Long id,
                                            @RequestParam Long batchId,
                                            @RequestParam Integer cultureScore,
                                            @RequestParam Integer majorScore,
                                            @RequestParam (required = false)Integer subjectId,
                                            @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");
        }else if (ObjectUtils.isEmpty(cultureScore)){
            return AjaxResult.error("缺少cultureScore");
        }else if (ObjectUtils.isEmpty(majorScore)){
            return AjaxResult.error("缺少majorScore");
        }
        try {
            List<SchoolVO> schoolVOS = mallSchoolService.matchSchoolListByType(rateType, id, batchId, cultureScore, majorScore, pageNum, pageSize, subjectId);
            Page page = new Page<>(pageNum,pageSize);
            //为Page类中的total属性赋值
            int total = schoolVOS.size();
            page.setTotal(total);
            //计算当前需要显示的数据下标起始值
            int startIndex = (pageNum - 1) * pageSize;
            int endIndex = Math.min(startIndex + pageSize,total);
            //从链表中截取需要显示的子链表，并加入到Page
            if(schoolVOS.size()>pageSize) {
                page.addAll(schoolVOS.subList(startIndex, endIndex));
            }else{
                page.addAll(schoolVOS);
            }
            //以Page创建PageInfo
            PageInfo pageInfo = new PageInfo<>(page);
            return AjaxResult.success(pageInfo);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 根据标记查询配置说明
     * @param mark 标记
     * @return 结果
     */
    @GetMapping("/selectExplainConfig")
    public AjaxResult selectExplainConfig(String mark){
        try {
            return AjaxResult.success(mallConfigService.selectExplainConfig(mark));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 校考院校列表
     * @param searchValue 搜索词
     * @param acceptYear 年份
     * @param majorId 专业id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectTestSchoolList")
    public AjaxResult selectTestSchoolList(@RequestParam(required = false) String searchValue,
                                           @RequestParam(required = false)String acceptYear,
                                           @RequestParam(required = false)Integer majorId,
                                           @RequestParam(defaultValue = "1")Integer pageNum,
                                           @RequestParam(defaultValue = "10")Integer pageSize){
        try {
            return AjaxResult.success(mallTestSchoolService.selectTestSchoolList(searchValue, acceptYear, majorId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 招生简章列表
     * @param searchValue 搜索词
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectRulesList")
    public AjaxResult selectRulesList(@RequestParam(required = false) String searchValue,
                                      @RequestParam(defaultValue = "1") Integer pageNum,
                                      @RequestParam(defaultValue = "10") Integer pageSize){
        try {
            return AjaxResult.success(mallSchoolAcceptRulesService.selectRulesList(searchValue, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 招生简章详情
     * @param acceptRulesId 简章id
     * @return 结果
     */
    @GetMapping("/selectRulesDetail")
    public AjaxResult selectRulesDetail(@RequestParam Long acceptRulesId){
        try {
            return AjaxResult.success(mallSchoolAcceptRulesService.selectRulesDetail(acceptRulesId));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 保研率院校列表
     * @param schoolName 学校名
     * @param batchId 批次id
     * @param configLevelId 层次id
     * @param configTypeId 学校类型
     * @param provinceId 省份id
     * @param cityId 城市id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectSchoolListForMaster")
    public  AjaxResult selectSchoolListForMaster(@RequestParam(required = false) String schoolName,
                                                 @RequestParam Long batchId,
                                                 @RequestParam(required = false) Long configLevelId,
                                                 @RequestParam(required = false) Long configTypeId,
                                                 @RequestParam(required = false) Long provinceId,
                                                 @RequestParam(required = false) Long cityId,
                                                 @RequestParam(defaultValue = "1") Integer pageNum,
                                                 @RequestParam(defaultValue = "10") Integer pageSize){
        try {
            return AjaxResult.success(mallSchoolService.selectSchoolListForMaster(schoolName, batchId, configLevelId, configTypeId, provinceId, cityId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 艺术分类列表
     * @return 结果
     */
    @GetMapping("/selectArtList")
    public AjaxResult selectArtList(){
        try {
            return AjaxResult.success(mallArtService.selectArtList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 专业开始院校
     * @param schoolName 学校id
     * @param batchId 批次id
     * @param configLevelId 层次id
     * @param configTypeId 类型id
     * @param provinceId 省份id
     * @param cityId 城市id
     * @param type 接口类型(0-专业强校,1-硕士点)
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结束
     */
    @GetMapping("/selectSchoolListByMajorId")
    public AjaxResult selectSchoolListByMajorId(@RequestParam(required = false) String schoolName,
                                                @RequestParam Long batchId,
                                                @RequestParam(required = false) Long configLevelId,
                                                @RequestParam(required = false) Long configTypeId,
                                                @RequestParam(required = false) Long provinceId,
                                                @RequestParam(required = false) Long cityId,
                                                @RequestParam Integer type,
                                                @RequestParam Long majorId,
                                                @RequestParam(defaultValue = "1") Integer pageNum,
                                                @RequestParam(defaultValue = "10") Integer pageSize){
        try {
            if (ObjectUtils.isEmpty(batchId)){
                return AjaxResult.error("缺少batchId");
            }else if (ObjectUtils.isEmpty(type)){
                return AjaxResult.error("缺少type");
            }
            return AjaxResult.success(mallSchoolService.selectSchoolListByMajorId(schoolName, batchId, configLevelId, configTypeId, provinceId, cityId, type,majorId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }

    }

    /**
     * 我的意向修改状态
     * @param expectBO 意向参数
     * @param bindingResult 校验结果
     * @return 结果
     */
    @RepeatSubmit
    @PostMapping("/changeExpectStatus")
    public AjaxResult changeExpectStatus(@RequestBody @Validated ExpectBO expectBO, BindingResult bindingResult){
        if (bindingResult.hasErrors()){
            return AjaxResult.allParameterErrors(bindingResult);
        }
        try {
            return mallMemberExpectService.changeExpectStatus(expectBO);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 招生分析学校列表
     * @return 结果
     */
    @GetMapping("/selectSteadySchoolList")
    public AjaxResult selectSteadySchoolList(CheckingOutParamBo checkingOutParamBo){
        try {
            //return AjaxResult.success(mallSchoolAcceptService.selectSteadySchoolList( checkingOutParamBo));
            return AjaxResult.success(mallSchoolAcceptService.selectSteadySchoolList2( checkingOutParamBo));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    /**
     * 招生数据分析
     * @return 结果
     */
    @GetMapping("/getAcceptData")
    public AjaxResult getAcceptData(CheckingOutParamBo checkingOutParamBo){
        try {
            //return mallSchoolAcceptService.getAcceptData(checkingOutParamBo.getMemberId(), checkingOutParamBo.getBatchId());
            return mallSchoolAcceptService.getAcceptData2(checkingOutParamBo.getMemberId(), checkingOutParamBo.getBatchId());

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

    /**
     * 意向学校列表
     * @param id 用户id
     * @param batchId 批次id
     * @param pageNum 页码
     * @param pageSize 每页个数
     * @return 结果
     */
    @GetMapping("/selectExpectSchoolList")
    public AjaxResult selectExpectSchoolList(@RequestParam Long id,
                                             @RequestParam Long batchId,
                                             @RequestParam(defaultValue = "1") Integer pageNum,
                                             @RequestParam(defaultValue = "10") Integer pageSize){
        try {
            if (ObjectUtils.isEmpty(id)){
                return AjaxResult.error("缺少id");
            }else  if (ObjectUtils.isEmpty(batchId)){
                return AjaxResult.error("缺少batchId");
            }
            return AjaxResult.success(mallMemberExpectService.selectExpectSchoolList(id, batchId, pageNum, pageSize));
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("服务器异常");
        }
    }

    @GetMapping("/update")
    public AjaxResult update(){
        try {
            mallSchoolAcceptRecordService.update();
            return AjaxResult.success();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error();
        }
    }

    /**
     * 专业级联列表
     * @return
     */
    @GetMapping("/getMajorList")
    public AjaxResult getMajorList(){
        try {
            return AjaxResult.success(majorClassService.getMajorList());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error();
        }
    }

    /**
     * 关联专业
     * @return
     */
    @GetMapping("/test1")
    public AjaxResult linkAccept(){
        try {
            return AjaxResult.toAjax(linkMajorSchoolService.linkAccept());
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error();
        }
    }

    @GetMapping("/test2")
    public AjaxResult linkAcceptPlan(){
        try {
            linkMajorSchoolService.newSchool();
            //memberUserService.createUserRate();
            return AjaxResult.success();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error();
        }
    }


}
