package com.tuoheng.admin.controller;

import com.tuoheng.admin.request.report.QueryReportPageListRequest;
import com.tuoheng.admin.service.report.IReportService;
import com.tuoheng.admin.service.report.query.QueryInspectionReportService;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @desc: 巡检报告
 * @team: tuoheng
 * @author: wanjing
 * @date: 2022-12-09
 */
@Slf4j
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    private IReportService reportService;

    @Autowired
    private QueryInspectionReportService queryInspectionReportService;

    /**
     * 生成巡检报告
     */
    @PostMapping("/generate/{id}")
    public JsonResult generate(@PathVariable("id") String id) {
        log.info("进入生成报告接口");
        return reportService.generate(id);
    }

    /**
     * 查看巡检报告分页列表
     */
    @GetMapping("/page/list")
    public JsonResult getPageList(QueryReportPageListRequest request) {
//        log.info("进入查询报告分页列表接口");
        return reportService.getPageList(request);
    }

    /**
     * 查看巡检报告
     */
    @GetMapping("/inspection/{id}")
    public JsonResult getInspectionReport(@PathVariable("id") String id) {
//        log.info("进入查看巡检报告接口");
        return reportService.getInspectionReport(id);
    }

    /**
     * 导出巡检报告
     */
    @GetMapping("/export/inspection/{id}")
    public void exportInspectionReport(@PathVariable("id")String id, HttpServletRequest request, HttpServletResponse response) {
//        log.info("进入导出巡检报告接口");
        reportService.exportInspectionReport(request, response, id);
    }

    /**
     * 查看处理报告
     */
    @GetMapping("/inspection/handle/{id}")
    public JsonResult getHandleReport(@PathVariable("id") String id) {
//        log.info("进入查看处理报告接口");
        return reportService.getInspectionHandleReport(id);
    }

    /**
     * 导出处理报告
     */
    @GetMapping("/export/inspection/handle/{id}")
    public void exportHandleReport(@PathVariable("id")String id, HttpServletRequest request, HttpServletResponse response) {
//        log.info("进入导出处理报告接口");
        reportService.exportInspectionHandleReport(request, response, id);
    }

}
