package com.srs.web.controller.stureg;

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.stureg.domain.SrsStuCheck;
import com.srs.stureg.service.ISrsStuCheckService;
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-09-09
 */
@RestController
@RequestMapping("/stureg/check")
@Api(value = "报到核验管理", tags = "报到核验管理")
public class SrsStuCheckController extends BaseController {
    @Autowired
    private ISrsStuCheckService srsStuCheckService;

    /**
     * 查询报到核验列表
     */
//@PreAuthorize("@ss.hasPermi('stureg:check:list')")
@GetMapping("/list")
@ApiOperation("查询报到核验列表")
    public TableDataInfo list(SrsStuCheck srsStuCheck)
    {
        startPage();
        List<SrsStuCheck> list = srsStuCheckService.selectSrsStuCheckList(srsStuCheck);
        return getDataTable(list);
    }

    /**
     * 导出报到核验列表
     */
//    @PreAuthorize("@ss.hasPermi('stureg:check:export')")
    @Log(title = "报到核验", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出报到核验列表")
    public void export(HttpServletResponse response, SrsStuCheck srsStuCheck)
    {
        List<SrsStuCheck> list = srsStuCheckService.selectSrsStuCheckList(srsStuCheck);
        ExcelUtil<SrsStuCheck> util = new ExcelUtil<SrsStuCheck>(SrsStuCheck.class);
        util.exportExcel(response, list, "报到核验数据");
    }

    /**
     * 获取报到核验详细信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:check:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取报到核验详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsStuCheckService.selectSrsStuCheckById(id));
    }
    @GetMapping(value = "/ksh")
    @ApiOperation("获取报到核验详细信息")
    public AjaxResult getowmInfo()
    {
        String ksh=getUsername();
        return success(srsStuCheckService.getowmInfo(ksh));
    }

    /**
     * 新增报到核验
     */
//    @PreAuthorize("@ss.hasPermi('stureg:check:add')")
    @Log(title = "报到核验", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增报到核验")
    public AjaxResult add(@RequestBody SrsStuCheck srsStuCheck)
    {
        return toAjax(srsStuCheckService.insertSrsStuCheck(srsStuCheck));
    }

    /**
     * 修改报到核验
     */
//    @PreAuthorize("@ss.hasPermi('stureg:check:edit')")
    @Log(title = "报到核验", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改报到核验")
    public AjaxResult edit(@RequestBody SrsStuCheck srsStuCheck)
    {
        return toAjax(srsStuCheckService.updateSrsStuCheck(srsStuCheck));
    }

    /**
     * 删除报到核验
     */
//    @PreAuthorize("@ss.hasPermi('stureg:check:remove')")
    @Log(title = "报到核验", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除报到核验")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srsStuCheckService.deleteSrsStuCheckByIds(ids));
    }
}
