package com.srs.web.controller.routine;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;

import com.srs.routine.domain.RtStuAtSchool;
import com.srs.routine.service.IRtStuAtSchoolService;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.enums.BusinessType;
import com.srs.common.annotation.Log;
import com.srs.common.core.page.TableDataInfo;

/**
 * 测试Controller
 *
 * @author srs
 * @date 2024-05-27
 */
@RestController
@RequestMapping("/routine/school")
@Api(value = "测试管理", tags = "测试管理")
public class RtStuAtSchoolController extends BaseController {
    @Autowired
    private IRtStuAtSchoolService rtStuAtSchoolService;

    /**
     * 查询测试列表
     */
    @PreAuthorize("@ss.hasPermi('routine:school:list')")
    @GetMapping("/list")
    @ApiOperation("查询测试列表")
    public TableDataInfo list(RtStuAtSchool rtStuAtSchool) {
        startPage();
        List<RtStuAtSchool> list = rtStuAtSchoolService.selectRtStuAtSchoolList(rtStuAtSchool);
        return getDataTable(list);
    }

    /**
     * 导出测试列表
     */
    @PreAuthorize("@ss.hasPermi('routine:school:export')")
    @Log(title = "测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出测试列表")
    public void export(HttpServletResponse response, RtStuAtSchool rtStuAtSchool) {
        List<RtStuAtSchool> list = rtStuAtSchoolService.selectRtStuAtSchoolList(rtStuAtSchool);
        ExcelUtil<RtStuAtSchool> util = new ExcelUtil<RtStuAtSchool>(RtStuAtSchool.class);
        util.exportExcel(response, list, "测试数据");
    }

    /**
     * 获取测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('routine:school:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取测试详细信息")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(rtStuAtSchoolService.selectRtStuAtSchoolById(id));
    }

    /**
     * 新增测试
     */
    @PreAuthorize("@ss.hasPermi('routine:school:add')")
    @Log(title = "测试", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增测试")
    public AjaxResult add(@RequestBody RtStuAtSchool rtStuAtSchool) {
        return toAjax(rtStuAtSchoolService.insertRtStuAtSchool(rtStuAtSchool));
    }

    /**
     * 修改测试
     */
    @PreAuthorize("@ss.hasPermi('routine:school:edit')")
    @Log(title = "测试", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改测试")
    public AjaxResult edit(@RequestBody RtStuAtSchool rtStuAtSchool) {
        return toAjax(rtStuAtSchoolService.updateRtStuAtSchool(rtStuAtSchool));
    }

    /**
     * 删除测试
     */
    @PreAuthorize("@ss.hasPermi('routine:school:remove')")
    @Log(title = "测试", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除测试")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(rtStuAtSchoolService.deleteRtStuAtSchoolByIds(ids));
    }
}
