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

@RestController
@RequestMapping("/ledger/healthSoldier")
public class LedgerHealthSoldierController extends BaseController {

    @Autowired
    private ILedgerHealthSoldierService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:healthSoldier:export')")
    @Log(title = "健康锐兵", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerHealthSoldier query) {
        List<LedgerHealthSoldier> list = service.selectList(query);
        ExcelUtil<LedgerHealthSoldier> util = new ExcelUtil<>(LedgerHealthSoldier.class);
        util.exportExcel(response, list, "健康锐兵");
    }

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