package com.sundot.airport.web.controller.ledger;

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

import com.sundot.airport.common.annotation.Log;
import com.sundot.airport.common.core.controller.BaseController;
import com.sundot.airport.common.core.domain.AjaxResult;
import com.sundot.airport.common.core.page.TableDataInfo;
import com.sundot.airport.common.enums.BusinessType;
import com.sundot.airport.common.utils.poi.ExcelUtil;
import com.sundot.airport.ledger.domain.LedgerSecurityTest;
import com.sundot.airport.common.dto.LedgerCommonQueryReqVO;
import com.sundot.airport.common.dto.LedgerCommonResVO;
import com.sundot.airport.ledger.service.ILedgerSecurityTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 安保测试记录Controller
 */
@RestController
@RequestMapping("/ledger/securityTest")
public class LedgerSecurityTestController extends BaseController {

    @Autowired
    private ILedgerSecurityTestService service;

    @PreAuthorize("@ss.hasPermi('ledger:securityTest:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedgerSecurityTest query) {
        startPage();
        List<LedgerSecurityTest> list = service.selectList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('ledger:securityTest:export')")
    @Log(title = "安保测试记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerSecurityTest query) {
        List<LedgerSecurityTest> list = service.selectList(query);
        ExcelUtil<LedgerSecurityTest> util = new ExcelUtil<>(LedgerSecurityTest.class);
        util.exportExcel(response, list, "安保测试记录");
    }

    @PreAuthorize("@ss.hasPermi('ledger:securityTest:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return AjaxResult.success(service.getById(id));
    }

    /**
     * 安保测试物品分类
     *
     * @param queryReq 查询参数
     * @return AjaxResult
     */
    @PostMapping("/securityTestItemClassification")
    public AjaxResult securityTestItemClassification(@RequestBody LedgerCommonQueryReqVO queryReq) {
        List<LedgerCommonResVO> result = service.securityTestItemClassification(queryReq);
        return AjaxResult.success(result);
    }

    /**
     * 安保测试通过情况
     *
     * @param queryReq 查询参数
     * @return AjaxResult
     */
    @PostMapping("/securityTestPassingStatus")
    public AjaxResult securityTestPassingStatus(@RequestBody LedgerCommonQueryReqVO queryReq) {
        List<LedgerCommonResVO> result = service.securityTestPassingStatus(queryReq);
        return AjaxResult.success(result);
    }

    /**
     * 安保测试区域情况
     *
     * @param queryReq 查询参数
     * @return AjaxResult
     */
    @PostMapping("/securityTestRegion")
    public AjaxResult securityTestRegion(@RequestBody LedgerCommonQueryReqVO queryReq) {
        List<LedgerCommonResVO> result = service.securityTestRegion(queryReq);
        return AjaxResult.success(result);
    }

}
