package org.jeecg.modules.newWarning.controller;

import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.newWarning.dto.WarnLogComprehensiveDto;
import org.jeecg.modules.newWarning.service.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 报警历史数据表 前端控制器
 * </p>
 *
 * @author zrj
 * @since 2022-12-09
 */
@RestController
@RequestMapping("/newWarn/warnLog")
public class WarnLogController {

    @Resource
    private WarnLogService warnLogService;

    @PostMapping(value = "/getWarnLogListByType")
    public Result<?> getWarnLogListByType(@RequestBody HashMap<String, Object> params){
        List<WarnLogComprehensiveDto> res = warnLogService.getWarnLogListByType(params);
        return Result.OK(res);
    }

    @GetMapping("/getWarnLogPageByType")
    public Result<?>  getWarnLogPageByType(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                     @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
                                     @RequestParam(name="type") String type, @RequestParam("jh")String jh){
        return warnLogService.getWarnLogPageByType(pageNo,pageSize,type,jh);
    }

    @PostMapping("/getMaxTimeWarnDataByJh")
    public Result<?>  getMaxTimeWarnDataByJh(@RequestBody HashMap<String, Object> params){
        List<WarnLogComprehensiveDto> res = warnLogService.getMaxTimeWarnDataByJh(params);
        return  Result.OK(res);
    }

    @GetMapping("/updateAjhWarnInfo")
    public void updateAjhWarnInfo(){
        warnLogService.updateAjhWarnInfo();
    }

    @GetMapping("/updateWarnLogStatusById")
    public Result<?>  updateWarnLogStatusById(@RequestParam("id") String id,@RequestParam("type") String type,
                                              @RequestParam("status")String status){
        warnLogService.updateWarnLogStatusById(id,type, status);
        return Result.OK();
    }

    @GetMapping("/saveWarnOperateLog")
    public Result<?>  saveWarnOperateLog(@RequestParam("id")String id,@RequestParam("jh")String jh,@RequestParam("type")String type){
        warnLogService.saveWarnOperateLog(id,jh,type);
        return Result.OK();
    };
}
