package com.ruoyi.web.controller.formal;

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.domain.entity.vo.FormalTeacherClassVo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.domain.entity.FormalTeacherClass;
import com.ruoyi.system.service.IFormalTeacherClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 老师-班级（学科）(审核通过之后数据)Controller
 *
 * @author ruoyi
 * @date 2023-05-30
 */
@RestController
@RequestMapping("/formal/class")
public class FormalTeacherClassController extends BaseController {
    @Autowired
    private IFormalTeacherClassService formalTeacherClassService;

    /**
     * 查询老师-班级（学科）(审核通过之后数据)列表
     */
    @PreAuthorize("@ss.hasPermi('formal:class:list')")
    @GetMapping("/list")
    public TableDataInfo list(FormalTeacherClass formalTeacherClass) {
        startPage();
        List<FormalTeacherClass> list = formalTeacherClassService.selectFormalTeacherClassList(formalTeacherClass);
        return getDataTable(list);
    }

    /**
     * 导出老师-班级（学科）(审核通过之后数据)列表
     */
    @PreAuthorize("@ss.hasPermi('formal:class:export')")
    @Log(title = "老师-班级（学科）(审核通过之后数据)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FormalTeacherClass formalTeacherClass) {
        List<FormalTeacherClass> list = formalTeacherClassService.selectFormalTeacherClassList(formalTeacherClass);
        ExcelUtil<FormalTeacherClass> util = new ExcelUtil<FormalTeacherClass>(FormalTeacherClass.class);
        util.exportExcel(response, list, "老师-班级（学科）(审核通过之后数据)数据");
    }

    /**
     * 获取老师-班级（学科）(审核通过之后数据)详细信息
     */
    @PreAuthorize("@ss.hasPermi('formal:class:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(formalTeacherClassService.selectFormalTeacherClassById(id));
    }

    /**
     * 新增老师-班级（学科）(审核通过之后数据)
     */
    @PreAuthorize("@ss.hasPermi('formal:class:add')")
    @Log(title = "老师-班级（学科）(审核通过之后数据)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FormalTeacherClass formalTeacherClass) {
        return toAjax(formalTeacherClassService.insertFormalTeacherClass(formalTeacherClass));
    }

    /**
     * 修改老师-班级（学科）(审核通过之后数据)
     */
    @PreAuthorize("@ss.hasPermi('formal:class:edit')")
    @Log(title = "老师-班级（学科）(审核通过之后数据)", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody FormalTeacherClass formalTeacherClass) {
        return toAjax(formalTeacherClassService.updateFormalTeacherClass(formalTeacherClass));
    }

    /**
     * 批量修改老师-班级（学科）(审核通过之后数据)
     */
    @PreAuthorize("@ss.hasPermi('formal:class:editAll')")
    @Log(title = "老师-班级（学科）(审核通过之后数据)", businessType = BusinessType.UPDATE)
    @PostMapping("/put/All")
    public AjaxResult editAll(@RequestBody FormalTeacherClassVo formalTeacherClassVo) {
        return formalTeacherClassService.updateFormalTeacherClassList(formalTeacherClassVo);
    }


    /**
     * 删除老师-班级（学科）(审核通过之后数据)
     */
    @PreAuthorize("@ss.hasPermi('formal:class:remove')")
    @Log(title = "老师-班级（学科）(审核通过之后数据)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(formalTeacherClassService.deleteFormalTeacherClassByIds(ids));
    }
}
