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

/**
 * 通道过检率记录Controller
 */
@RestController
@RequestMapping("/ledger/channelPassRate")
public class LedgerChannelPassRateController extends BaseController {

    @Autowired
    private ILedgerChannelPassRateService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:channelPassRate:export')")
    @Log(title = "通道过检率记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerChannelPassRate query) {
        List<LedgerChannelPassRate> list = service.selectList(query);
        ExcelUtil<LedgerChannelPassRate> util = new ExcelUtil<>(LedgerChannelPassRate.class);
        util.exportExcel(response, list, "通道过检率记录");
    }

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