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.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

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

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

    @ApiOperation("分页查询报警规则修改日志")
    @GetMapping("/page")
    public ResponseWrapper getRuleEventLog(
            @ApiParam(value = "当前页") @RequestParam(value = "pagenum",required = true) Integer pageNum,
            @ApiParam(value = "分页大小") @RequestParam(value = "pagesize",required = true) Integer pageSize,
            @ApiParam(value = "报警名称") @RequestParam(value = "ruleName",required = false) String ruleName,
            @ApiParam(value = "规则类型（风机报警，升压站报警，自定义报警）") @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);
    }
}
