package com.yuchen.saas.park.service.fault.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuchen.saas.park.api.entity.fault.EquipmentBreakdownRule;
import com.yuchen.saas.park.service.fault.service.EquipmentBreakdownRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.mp.support.Condition;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/10/18 15:52
 * @Description: 设备故障规则
 * @Version: 1.0
 */
@RestController
@RequestMapping("/equipment_breakdown/rule")
@Api(tags = "设备故障", value = "设备故障规则")
public class EquipmentBreakdownRuleController {


    /**
     * 设备故障规则service
     */
    @Resource
    private EquipmentBreakdownRuleService breakdownRuleService;


    /**
     * 新增设备故障规则
     *
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "新增设备故障规则", notes = "新增设备故障规则")
    public R add(@RequestBody EquipmentBreakdownRule rule) {
        R result = breakdownRuleService.saveRule(rule);
        return result;
    }

    @GetMapping("/page")
    @ApiOperation(value = "设备故障规则分页", notes = "设备故障规则分页")
    public R page(Query query, EquipmentBreakdownRule rule) {
        Page page = (Page) Condition.getPage(query);
        R result = breakdownRuleService.pageVo(page, rule);
        return result;
    }

    @PostMapping("/update")
    @ApiOperation(value = "新增设备故障规则", notes = "新增设备故障规则")
    public R update(@RequestBody EquipmentBreakdownRule rule) {
        R result = breakdownRuleService.updateRule(rule);
        return result;
    }

    @PostMapping("/delete")
    @ApiOperation(value = "新增设备故障规则", notes = "新增设备故障规则")
    public R delete(@RequestBody EquipmentBreakdownRule rule) {
        R result = breakdownRuleService.deleteRule(rule);
        return result;
    }

}