package com.ruoyi.web.controller.contentCheck;

import com.ruoyi.common.annotation.Log;
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.BusinessType;
import com.ruoyi.system.domain.TbSchoolEntranceRequirements;
import com.ruoyi.system.service.ITbSchoolEntranceRequirementsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 入学要求Controller
 * 
 * @author ruoyi
 * @date 2022-10-11
 */
@Controller
@RequestMapping("/system/requirementsCheck")
public class TbSchoolEntranceRequirementsCheckController extends BaseController
{
    private String prefix = "system/requirements";

    @Autowired
    private ITbSchoolEntranceRequirementsService tbSchoolEntranceRequirementsService;

    @RequiresPermissions("system:requirementsCheck:view")
    @GetMapping()
    public String requirements()
    {
        return prefix + "/requirementsNotPass";
    }

    /**
     * 查询入学要求列表
     */
    @RequiresPermissions("system:requirementsCheck:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbSchoolEntranceRequirements tbSchoolEntranceRequirements)
    {
        startPage();
        List<TbSchoolEntranceRequirements> list = tbSchoolEntranceRequirementsService.selectTbSchoolEntranceRequirementsNotPassList(tbSchoolEntranceRequirements);
        return getDataTable(list);
    }

    /**
     * 修改入学要求
     */
    @RequiresPermissions("system:requirementsCheck:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TbSchoolEntranceRequirements tbSchoolEntranceRequirements = tbSchoolEntranceRequirementsService.selectTbSchoolEntranceRequirementsById(id);
        mmap.put("tbSchoolEntranceRequirements", tbSchoolEntranceRequirements);
        return prefix + "/editCheckResult";
    }

    /**
     * 修改保存入学要求
     */
    @RequiresPermissions("system:requirementsCheck:edit")
    @Log(title = "入学要求", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbSchoolEntranceRequirements tbSchoolEntranceRequirements)
    {
        tbSchoolEntranceRequirements.setChecker(getUserId());
        return toAjax(tbSchoolEntranceRequirementsService.updateCheckResult(tbSchoolEntranceRequirements));
    }

}
