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

import com.yuchen.saas.park.api.entity.fault.EquipmentPictureRule;
import com.yuchen.saas.park.service.fault.service.EquipmentPictureRuleService;
import io.swagger.annotations.Api;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/10/19 16:49
 * @Description: 设备画像分析规则定义
 * @Version: 1.0
 */
@RestController
@RequestMapping("/equipment_picture/rule")
@Api(tags = "设备画像分析规则定义", value = "设备画像分析规则定义")
public class EquipmentPictureRuleController {

    @Resource
    private EquipmentPictureRuleService pictureRule;

    @RequestMapping("/list_vo")
    public R listVo() {
        R result = pictureRule.listVo();
        return result;
    }

    @RequestMapping("/list")
    public R list() {
        List<EquipmentPictureRule> list = pictureRule.list();
        return R.data(list);
    }

    @PostMapping("/add")
    public R add(@RequestBody EquipmentPictureRule rule) {
        pictureRule.save(rule);
        return R.data(true);
    }

    @PostMapping("/update")
    public R update(@RequestBody EquipmentPictureRule rule) {
        R result = pictureRule.updateRule(rule);
        return result;
    }

    /**
     * 批量更新是否显示
     *
     * @param rule 传递的需要显示的规则
     * @return
     */
    @PostMapping("/is_show")
    public R updateIsShowBatch(@RequestBody List<EquipmentPictureRule> rule) {
        R result = pictureRule.updateBatchShow(rule);
        return result;
    }

}