package com.srs.web.controller.stureg;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 com.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.stureg.domain.OfflineCheckIn;
import com.srs.stureg.service.IOfflineCheckInService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 现场办理学生信息Controller
 * 
 * @author 邓
 * @date 2023-05-20
 */
@RestController
@RequestMapping("/stureg/offlinecheckin")
public class OfflineCheckInController extends BaseController
{
    @Autowired
    private IOfflineCheckInService offlineCheckInService;

    /**
     * 查询现场办理学生信息列表
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:list')")
    @GetMapping("/list")
    public TableDataInfo list(OfflineCheckIn offlineCheckIn)
    {
        startPage();
        List<OfflineCheckIn> list = offlineCheckInService.selectOfflineCheckInList(offlineCheckIn);
        return getDataTable(list);
    }

    /**
     * 导出现场办理学生信息列表
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:export')")
    @Log(title = "现场办理学生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OfflineCheckIn offlineCheckIn)
    {
        List<OfflineCheckIn> list = offlineCheckInService.selectOfflineCheckInList(offlineCheckIn);
        ExcelUtil<OfflineCheckIn> util = new ExcelUtil<OfflineCheckIn>(OfflineCheckIn.class);
        util.exportExcel(response, list, "现场办理学生信息数据");
    }

    /**
     * 获取现场办理学生信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(offlineCheckInService.selectOfflineCheckInById(id));
    }

    /**
     * 新增现场办理学生信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:add')")
    @Log(title = "现场办理学生信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OfflineCheckIn offlineCheckIn)
    {
        return toAjax(offlineCheckInService.insertOfflineCheckIn(offlineCheckIn));
    }

    /**
     * 修改现场办理学生信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:edit')")
    @Log(title = "现场办理学生信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody OfflineCheckIn offlineCheckIn)
    {
        return toAjax(offlineCheckInService.updateOfflineCheckIn(offlineCheckIn));
    }

    /**
     * 删除现场办理学生信息
     */
//    @PreAuthorize("@ss.hasPermi('stureg:offlinecheckin:remove')")
    @Log(title = "现场办理学生信息", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(offlineCheckInService.deleteOfflineCheckInByIds(ids));
    }
}
