package com.gyee.wisdom.alarm.sharding.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gyee.wisdom.alarm.sharding.entity.RuleUpdateEvent;
import com.gyee.wisdom.alarm.sharding.service.RuleUpdateEventService;
import com.gyee.wisdom.alarm.sharding.util.ResponseWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 报警规则日志
 * @auther: Wanghs
 * @date: 2022-04-01
 */

@Slf4j
@RestController
@RequestMapping("/rulevent")
@CrossOrigin
@Tag(name = "规则修改日志")
public class AlertRuleEventLogController {
    @Autowired
    private RuleUpdateEventService ruleUpdateEventService;

    @Operation(description = "分页查询报警规则修改日志")
    @GetMapping("/page")
    public ResponseWrapper getRuleEventLog(
            @Parameter(  name ="pagenum",description = "当前页") @RequestParam(value = "pagenum",required = true) Integer pageNum,
            @Parameter(  name ="pagesize",description = "分页大小") @RequestParam(value = "pagesize",required = true) Integer pageSize,
            @Parameter(  name ="ruleName",description = "报警名称") @RequestParam(value = "ruleName",required = false) String ruleName,
            @Parameter(  name ="ruleType",description = "规则类型（风机报警，升压站报警，自定义报警）") @RequestParam(value = "ruleType",required = false) String ruleType


            ) {
        Page<RuleUpdateEvent> page = new Page<RuleUpdateEvent>(pageNum,pageSize);

        IPage updateEventByPage = ruleUpdateEventService.getUpdateEventByPage(page, ruleName,ruleType);
        return ResponseWrapper.success("请求成功",updateEventByPage);
    }
}
