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.dto.LedgerCommonQueryReqVO;
import com.sundot.airport.common.dto.LedgerCommonResVO;
import com.sundot.airport.common.enums.BusinessType;
import com.sundot.airport.common.utils.poi.ExcelUtil;
import com.sundot.airport.ledger.domain.LedgerSupervisionProblem;
import com.sundot.airport.ledger.service.ILedgerSupervisionProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 部门监察问题记录Controller
 */
@RestController
@RequestMapping("/ledger/supervisionProblem")
public class LedgerSupervisionProblemController extends BaseController {

    @Autowired
    private ILedgerSupervisionProblemService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:supervisionProblem:export')")
    @Log(title = "部门监察问题记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerSupervisionProblem query) {
        List<LedgerSupervisionProblem> list = service.selectList(query);
        ExcelUtil<LedgerSupervisionProblem> util = new ExcelUtil<>(LedgerSupervisionProblem.class);
        util.exportExcel(response, list, "部门监察问题记录");
    }

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

    /**
     * 各岗位监察问题分布
     *
     * @param queryReq 查询参数
     * @return AjaxResult
     */
    @PostMapping("/supervisionProblemPosition")
    public AjaxResult supervisionProblemPosition(@RequestBody LedgerCommonQueryReqVO queryReq) {
        List<LedgerCommonResVO> result = service.supervisionProblemPosition(queryReq);
        return AjaxResult.success(result);
    }
}
