package com.srs.web.controller.dormitory;

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

import com.srs.dormitory.domain.Dto.DmsAuditDto;
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 com.srs.dormitory.domain.DmsApprovalProcess;
import com.srs.dormitory.service.IDmsApprovalProcessService;
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 2023-10-31
 */
@RestController
@RequestMapping("/dormitory/dms-approval-process")
@Api(value = "宿舍管理审核管理", tags = "宿舍管理审核管理")
public class DmsApprovalProcessController extends BaseController {
    @Autowired
    private IDmsApprovalProcessService dmsApprovalProcessService;

    /**
     * 查询宿舍管理审核列表
     */
//    @PreAuthorize("@ss.hasPermi('system:process:list')")
    @GetMapping("/list")
    @ApiOperation("查询宿舍管理审核列表")
    public TableDataInfo list(DmsApprovalProcess dmsApprovalProcess)
    {
        startPage();
        List<DmsApprovalProcess> list = dmsApprovalProcessService.selectDmsApprovalProcessList(dmsApprovalProcess);
        return getDataTable(list);
    }

    /**
     * 导出宿舍管理审核列表
     */
//    @PreAuthorize("@ss.hasPermi('system:process:export')")
    @Log(title = "宿舍管理审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出宿舍管理审核列表")
    public void export(HttpServletResponse response, DmsApprovalProcess dmsApprovalProcess)
    {
        List<DmsApprovalProcess> list = dmsApprovalProcessService.selectDmsApprovalProcessList(dmsApprovalProcess);
        ExcelUtil<DmsApprovalProcess> util = new ExcelUtil<DmsApprovalProcess>(DmsApprovalProcess.class);
        util.exportExcel(response, list, "宿舍管理审核数据");
    }

    /**
     * 获取宿舍管理审核详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:process:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取宿舍管理审核详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dmsApprovalProcessService.selectDmsApprovalProcessById(id));
    }

    /**
     * 新增宿舍管理审核
     */
//    @PreAuthorize("@ss.hasPermi('system:process:add')")
    @Log(title = "宿舍管理审核", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ApiOperation("新增宿舍管理审核")
    public AjaxResult add(@RequestBody DmsApprovalProcess dmsApprovalProcess)
    {
        return toAjax(dmsApprovalProcessService.insertDmsApprovalProcess(dmsApprovalProcess));
    }

    /**
     * 修改宿舍管理审核
     */
//    @PreAuthorize("@ss.hasPermi('system:process:edit')")
    @Log(title = "宿舍管理审核", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改宿舍管理审核")
    public AjaxResult edit(@RequestBody DmsApprovalProcess dmsApprovalProcess)
    {
        return toAjax(dmsApprovalProcessService.updateDmsApprovalProcess(dmsApprovalProcess));
    }

    /**
     * 删除宿舍管理审核
     */
//    @PreAuthorize("@ss.hasPermi('system:process:remove')")
    @Log(title = "宿舍管理审核", businessType = BusinessType.DELETE)
    @PostMapping("/{ids}")
    @ApiOperation("删除宿舍管理审核")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dmsApprovalProcessService.deleteDmsApprovalProcessByIds(ids));
    }

    @ApiOperation("辅导员查看申请表")
    @GetMapping("/myApproval")
    public TableDataInfo myApproval(DmsApprovalProcess dmsApprovalProcess){
        startPage();
        List<Map<String,Object>> mapList = dmsApprovalProcessService.myApproval(dmsApprovalProcess);
        return getDataTable(mapList);
    }

    @ApiOperation("辅导员审核换宿申请表")
    @PostMapping("/auditTSSQ")
    public AjaxResult auditTSSQ(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.auditTSSQ(dmsAuditDto);
    }

    @ApiOperation("辅导员审核退宿申请表")
    @PostMapping("/auditOUT")
    public AjaxResult auditOUT(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.auditOUT(dmsAuditDto);
    }

    @ApiOperation("辅导员审核留宿申请")
    @PostMapping("/auditSTAY")
    public AjaxResult auditSTAY(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.auditSTAY(dmsAuditDto);
    }

    @ApiOperation("学务查看申请表")
    @GetMapping("/workApply")
    public TableDataInfo workApply(DmsApprovalProcess approvalProcess){
        startPage();
        List<Map<String,Object>> mapList = dmsApprovalProcessService.workApply(approvalProcess);
        return getDataTable(mapList);
    }

    @ApiOperation("学务审核换宿申请表")
    @PostMapping("/work/auditTSSQB")
    public AjaxResult workAuditTSSQB(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.workAuditTSSQB(dmsAuditDto);
    }

    @ApiOperation("学务审核退宿申请")
    @PostMapping("/work/auditOUT")
    public AjaxResult workAuditOUT(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.workAuditOUT(dmsAuditDto);
    }

    @ApiOperation("学务审核留宿申请")
    @PostMapping("/work/auditSTAY")
    public AjaxResult workAuditSTAY(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.workAuditSTay(dmsAuditDto);
    }

    @ApiOperation("学校查看申请表")
    @GetMapping("/finalApply")
    public TableDataInfo finalApply(DmsApprovalProcess approvalProcess){
        startPage();
        List<Map<String,Object>> mapList = dmsApprovalProcessService.finalApply(approvalProcess);
        return getDataTable(mapList);
    }

    @ApiOperation("学校审核调宿申请表")
    @PostMapping("/final/auditTSSQB")
    public AjaxResult finalAuditTSSQB(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.finalAuditTSSQB(dmsAuditDto);
    }

    @ApiOperation("学校审核退宿申请表")
    @PostMapping("/final/auditOUT")
    public AjaxResult finalAuditOUT(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.finalAuditOUT(dmsAuditDto);
    }

    @ApiOperation("学校审核留宿申请表")
    @PostMapping("/final/auditSTAY")
    public AjaxResult finalAuditSTAY(@RequestBody DmsAuditDto dmsAuditDto){
        return dmsApprovalProcessService.finalAuditSTAY(dmsAuditDto);
    }
}
