package com.ruoyi.web.controller.front;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BoolValues;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.syzy.criteria.MarjorTdxCriteria;
import com.ruoyi.syzy.domain.BBusiWishUniversitySubmitMarjors;
import com.ruoyi.syzy.service.IBBusiWishUniversitySubmitMarjorsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
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 java.util.List;

@RestController
@Api(tags = "模拟志愿-投档线-专业")
@RequestMapping("front/syzy/tdx/marjor")
public class FrontSyzyTdxMarjorController extends BaseController {
    @Autowired
    private IBBusiWishUniversitySubmitMarjorsService marjorsService;

    @GetMapping("years")
    @ApiOperation("01.报考年份")
    public TableDataInfo years() {
        String location = SecurityUtils.getLoginUser().getUser().getProvinceName();
        List<String> arr = marjorsService.years(location, null, null);
        return getDataTable(arr);
    }

    @GetMapping("types")
    @ApiOperation("02.报考科类")
    public TableDataInfo types(@ApiParam("年份") @RequestParam Integer year) {
        String location = SecurityUtils.getLoginUser().getUser().getProvinceName();
        List<String> arr = marjorsService.types(location,year);
        return getDataTable(arr);
    }

    @GetMapping("levels")
    @ApiOperation("03.报考批次")
    public TableDataInfo levels(@ApiParam("年份") @RequestParam Integer year) {
        String location = SecurityUtils.getLoginUser().getUser().getProvinceName();
        List<String> arr = marjorsService.levels(location,year);
        return getDataTable(arr);
    }

    @GetMapping("getUniversityNameText")
    @ApiOperation("03-2.专业组名称")
    public AjaxResult getUniversityNameText(@ApiParam("院校编码") @RequestParam String universityCode,@ApiParam("年份") @RequestParam Integer year,
           @ApiParam("文理科/物理历史") @RequestParam String type, @ApiParam("批次")  String level) {
        String location = SecurityUtils.getLoginUser().getUser().getProvinceName();
        List<String> arr = marjorsService.getUniversityNameText(universityCode,location,year,type,level);
        return AjaxResult.success(arr);
    }

    @GetMapping("list")
    @ApiOperation("04.数据列表")
    public TableDataInfo search(MarjorTdxCriteria criteria, @ApiParam(value = "页数", example = "1") @RequestParam Integer pageNum,
        @ApiParam(value = "页大小", example = "15") @RequestParam Integer pageSize) {
        criteria.setSpro(SecurityUtils.getLoginUser().getUser().getProvinceName());
        if (BoolValues.isFalse(SecurityUtils.getLoginUser().getUser().getIsBind())) {
            PageHelper.startPage(1, 1);
        } else {
            startPage();
        }
        List<BBusiWishUniversitySubmitMarjors> arr = marjorsService.search(criteria);
        return getDataTable(arr);
    }
}
