package com.srs.web.controller.dormitory;


import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.core.page.TableDataInfo;
import com.srs.dormitory.domain.Dto.AddForeignApplicationDto;
import com.srs.dormitory.domain.Dto.ForeignApplicationListDto;
import com.srs.dormitory.service.IDmsForeignApplicationService;
import com.srs.dormitory.utils.DmsOperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 外来人员住宿申请表 前端控制器
 * </p>
 *
 * @author szz
 * @since 2023年08月04日
 */
@Api(tags = "外来人员住宿申请表")
@RestController
@RequestMapping("/dormitory/dms-foreign-application")
public class DmsForeignApplicationController extends BaseController {
    @Autowired
    private IDmsForeignApplicationService dmsForeignApplicationService;

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-foreign-application:add')")
    @ApiOperation("提交住宿申请")
    @PostMapping("/add")
    public AjaxResult addForeignApplication(@RequestBody @Validated AddForeignApplicationDto applicationDto){
        return dmsForeignApplicationService.addForeignApplication(applicationDto);
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-foreign-application:query')")
    @ApiOperation("查看外来人员住宿申请表详情")
    @GetMapping("/{id}")
    public AjaxResult getForeignApplicationInfo(@ApiParam(value = "外来人员住宿表ID") @PathVariable Long id){
        return dmsForeignApplicationService.getForeignApplicationInfo(id);
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-foreign-application:list')")
    @ApiOperation("查看外来住宿人员住宿申请列表")
    @PostMapping("/list")
    public TableDataInfo getForeignApplicationList(@RequestBody ForeignApplicationListDto dto){
        return getDataTable(dmsForeignApplicationService.getForeignApplicationList(dto));
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-foreign-application:remove')")
    @ApiOperation("删除外来住宿人员申请表")
    @PostMapping("/delete/{id}")
    public AjaxResult deleteForeignApplication(@PathVariable Long id){
        List<Long> ids = new ArrayList<>();
        ids.add(id);
        return dmsForeignApplicationService.batchDeleteForeignApplication(ids);
    }

//    @PreAuthorize("@ss.hasPermi('dormitory:dms-foreign-application:remove')")
    @ApiOperation("批量删除外来住宿人员申请表")
    @PostMapping("/batch/delete")
    public AjaxResult batchDeleteForeignApplication(@RequestBody List<Long> ids){
        return dmsForeignApplicationService.batchDeleteForeignApplication(ids);
    }
}

