package com.tuoheng.admin.controller;

import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.*;
import com.tuoheng.admin.service.accident.IAccidentService;
import com.tuoheng.common.core.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 事故前端控制器
 *
 * @Author ChengWang
 * @Date 2023/3/2
 */
@RestController
@RequestMapping("/accident")
public class AccidentController {

    @Autowired
    private IAccidentService accidentService;

    /**
     * 查询事故卡片分页列表
     */
    @GetMapping("/card/page/list")
    public JsonResult getAccidentCardPageList(QueryAccidentCardPageListRequest request) {
//        log.info("进入查询事故分页列表接口");
        return accidentService.getAccidentCardPageList(request);
    }

    /**
     * 查询事故卡片列表
     */
    @GetMapping("/card/list")
    public JsonResult getAccidentCardList(QueryAccidentCardListRequest request) {
//        log.info("进入查询事故分页列表接口");
        return accidentService.getAccidentCardList(request);
    }

    /**
     * 获取巡检任务信息信息
     */
    @GetMapping(value = "/info/{id}")
    public JsonResult getInfo(@PathVariable("id") String id) {
//        log.info("进入查询事故详情接口, id={}", id);
        return accidentService.getAccidentInfo(id);
    }

    /**
     * 告警列表分页
     */
    @GetMapping("/index")
    public JsonResult queryAccidentPage(AccidentQuery query) {
        return accidentService.index(query);
    }

    /**
     * 事故详情
     *
     * @param id
     * @return
     */
    @GetMapping("/details/{id}")
    public JsonResult accidentDetails(@PathVariable("id") String id) {
        return accidentService.accidentDetails(id);
    }

    /**
     * 告警弹窗通知下发
     */
    @GetMapping("/notice")
    public JsonResult notice() {
        return accidentService.notice();
    }

    /**
     * 事故告警提示
     * @param accidentId
     * @return
     */
    @GetMapping("/tips/{accidentId}")
    public JsonResult getTips(@PathVariable("accidentId") String accidentId){
        return accidentService.getTips(accidentId);
    }

    /**
     * 事故时间轴
     * @param accidentId
     * @return
     */
    @GetMapping("/timeAxis/{accidentId}")
    public JsonResult getTimeAxis(@PathVariable("accidentId") String accidentId){
        return accidentService.getTimeAxis(accidentId);
    }

    /**
     * 事故核实
     * @param request
     * @return
     */
    @PostMapping("/verify")
    public JsonResult verify(AccidentVerifyRequest request) {
        return accidentService.verify(request);
    }

    /**
     * 事故核实完成
     * @param request
     * @return
     */
    @PostMapping("/verify/completed")
    public JsonResult verifyCompleted(AccidentVerifyCompletedRequest request) {
        return accidentService.verifyCompleted(request);
    }

    /**
     * 事故上报
     */
    @PostMapping("/report/accident")
    public JsonResult report(ReportAccidentRequest request) {
        return accidentService.report(request);
    }

    /**
     * 无事故
     */
    @PostMapping("/report/no/accident")
    public JsonResult noAccident(ReportNoAccidentRequest request) {
        return accidentService.noAccident(request);
    }

    /**
     * 预警忽略
     *
     * @return
     */
    @PostMapping("/ignore/{id}")
    public JsonResult ignore(@PathVariable("id") String id){
        return accidentService.ignore(id);
    }
}
