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

@RestController
@RequestMapping("/ledger/dailyTraining")
public class LedgerDailyTrainingController extends BaseController {

    @Autowired
    private ILedgerDailyTrainingService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:dailyTraining:export')")
    @Log(title = "日常培训记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerDailyTraining query) {
        List<LedgerDailyTraining> list = service.selectList(query);
        ExcelUtil<LedgerDailyTraining> util = new ExcelUtil<>(LedgerDailyTraining.class);
        util.exportExcel(response, list, "日常培训记录");
    }

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