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.LedgerPatrolInspection;
import com.sundot.airport.ledger.service.ILedgerPatrolInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 队室三级质控巡查记录Controller
 */
@RestController
@RequestMapping("/ledger/patrolInspection")
public class LedgerPatrolInspectionController extends BaseController {

    @Autowired
    private ILedgerPatrolInspectionService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:patrolInspection:export')")
    @Log(title = "队室三级质控巡查记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerPatrolInspection query) {
        List<LedgerPatrolInspection> list = service.selectList(query);
        ExcelUtil<LedgerPatrolInspection> util = new ExcelUtil<>(LedgerPatrolInspection.class);
        util.exportExcel(response, list, "队室三级质控巡查记录");
    }

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