package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.query.WarningQuery;
import com.tuoheng.admin.entity.request.warning.QueryWarningListRequest;
import com.tuoheng.admin.entity.request.warning.WarningConfirmRequest;
import com.tuoheng.admin.service.warning.IWarningService;
import com.tuoheng.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc: 预警 前端控制器
 * @team: tuoheng
 * @author: wanjing
 * @date: 2023-02-06
 */
@RestController
@RequestMapping("/warning")
public class WarningController {

    @Autowired
    private IWarningService warningService;

    /**
     * 告警列表查询 分页
     * @param query
     * @return
     */
    @GetMapping("/index")
    public JsonResult index(WarningQuery query){
        return warningService.index(query);
    }

    /**
     * 查询预警列表
     */
    @GetMapping("/list")
    public JsonResult list(QueryWarningListRequest request) {
        return warningService.getList(request);
    }

    /**
     * 获取预警详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getOneById(@PathVariable("id") Integer id) {
        return warningService.getOneById(id);
    }

    /**
     * 预警确认
     */
    @PostMapping("/confirm")
    public JsonResult confirm(WarningConfirmRequest request){
        return warningService.confirm(request);
    }

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

    /**
     * 预警详情
     * @param id
     * @return
     */
    @GetMapping("/details/{id}")
    public JsonResult details(@PathVariable("id") Integer id){
        return warningService.details(id);
    }

    /**
     * 火灾通知下发
     * @return
     */
    @GetMapping("/notice")
    public JsonResult notice(){
        return warningService.notice();
    }

    /**
     * 通知预警与处理
     * @param id
     * @return
     */
    @PutMapping("/messageRead/status/{id}")
    public JsonResult editStatusById(@PathVariable("id") Integer id){
        return warningService.editStatusById(id);
    }
}
