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

/**
 * 投诉情况记录Controller
 */
@RestController
@RequestMapping("/ledger/complaint")
public class LedgerComplaintController extends BaseController {

    @Autowired
    private ILedgerComplaintService service;

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

    @PreAuthorize("@ss.hasPermi('ledger:complaint:export')")
    @Log(title = "投诉情况记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedgerComplaint query) {
        List<LedgerComplaint> list = service.selectList(query);
        ExcelUtil<LedgerComplaint> util = new ExcelUtil<>(LedgerComplaint.class);
        util.exportExcel(response, list, "投诉情况记录");
    }

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