package com.fs.watch.controller;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.watch.domain.WatchAlarmData;
import com.fs.watch.service.WatchAlarmDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 设备预警数据(WatchAlarmData)表控制层
 *
 * @author makejava
 * @since 2024-08-12 14:54:03
 */
@RestController
@RequestMapping("/watch/alarm")
public class WatchAlarmDataController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private WatchAlarmDataService watchAlarmDataService;

    @PostMapping("/insert")
    public AjaxResult insertAlarmData(@RequestBody WatchAlarmData data){
        return AjaxResult.success(watchAlarmDataService.insert(data));
    }

    @PostMapping("/batchInsert")
    public AjaxResult batchInsert(@RequestBody List<WatchAlarmData> data){
        return AjaxResult.success(watchAlarmDataService.batchInsertData(data));
    }


    /**
     * 查询所有/未读0/已读1数据
     *
     * @param status 状态
     * @return 所有/未读/已读数据
     */
    @GetMapping("/queryByStatus")
    public AjaxResult queryByStatus(@RequestParam(value = "status",required = false) Integer status) {
        return AjaxResult.success(this.watchAlarmDataService.queryByStatus(status));
    }

    /**
     * 查询所有/未读0/已读1数据 分页
     *
     * @param data 状态
     * @return 所有/未读/已读数据
     */
    @GetMapping("/queryPageByStatus")
//    public TableDataInfo queryPageByStatus(@RequestParam(value = "pageNum",required = false) Integer pageNum,
//                                           @RequestParam(value = "pageSize",required = false) Integer pageSize,
//                                           @RequestParam(value = "status",required = false) Integer status) {
    public TableDataInfo queryPageByStatus(WatchAlarmData data){
        startPage();
        List<WatchAlarmData> list = this.watchAlarmDataService.queryPageByStatus(data);
        return getDataTable(list);
    }

    /**
     * 设置已读
     *
     * @param ids
     * @return 所有/未读/已读数据
     */
    @PostMapping("/setStatusById")
    public AjaxResult setStatusById(@RequestBody List<String> ids) {
        return AjaxResult.success(this.watchAlarmDataService.setStatusById(ids));
    }

}

