package com.ruoyi.web.controller.ie;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ie.domain.Subject;
import com.ruoyi.ie.service.ISubjectService;
import com.ruoyi.mxjb.domain.MxjbContants;
import com.ruoyi.web.domain.Constant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.math.NumberUtils;
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.RestController;

import java.util.List;

@Api(tags = "前端V2 科目")
@RestController
@RequestMapping("front/subject")
public class FrontSubjectController extends BaseController {
    @Autowired
    private ISubjectService subjectService;

    /**
     * 查询科目列表
     */
    @ApiOperation("科目列表")
    @GetMapping("/list")
    public TableDataInfo list() {
        startPage();
        Subject cond = new Subject();
        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
        cond.setLocation(sysUser.getProvinceName());
        cond.setExamType(sysUser.getExamType());
        if(Constant.EXAM_TYPE_ZG.equals(sysUser.getExamType())) {
            cond.setSubjectId(100L + NumberUtils.toInt(sysUser.getExamMajor(), 0));
        }
        List<Subject> list = subjectService.selectSubjectList(cond);
        return getDataTable(list);
    }
}
