package com.huatek.busi.controller.cable;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant;
import com.huatek.busi.dto.cable.BusiCableThresholdDto;
import com.huatek.busi.service.IBusiCableThresholdService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 其他阈值控制层
 *
 * @author plus_wang
 * @date 2021年9月2日14:45:54
 */
@Api(tags = {ApiConstant.Tags.BUSI_Cable_THRESHOLD})
@Slf4j
@RestController
@RequestMapping("/api/busiCableThreshold")
public class BusiCableThresholdController {

    @Reference(check = false)
    private IBusiCableThresholdService busiCableThresholdService;

    /**
     * 根据状态查询阈值
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/find", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findCableThreshold(@RequestBody BusiCableThresholdDto dto) {
        return busiCableThresholdService.findCableVo(dto);
    }

    /**
     * 根据状态查询阈值
     *
     * @param dto
     * @return
     */
    @PostMapping(value = "/getGrowthRate", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> getGrowthRate(@RequestBody BusiCableThresholdDto dto) {
        return busiCableThresholdService.getGrowthRate(dto);
    }

    /**
     * 添加、编辑阈值
     *
     * @param token
     * @param dto
     * @return
     */
    @PostMapping(value = "/saveCableThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> saveCableThreshold(@RequestHeader("token") String token, @RequestBody BusiCableThresholdDto dto) {
        return busiCableThresholdService.saveCableThreshold(token, dto);
    }


    /**
     * 删除阈值
     *

     * @param dto
     * @return
     */
    @PostMapping(value = "/deleteCableThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> deleteCableThreshold(@RequestBody BusiCableThresholdDto dto) {
        return busiCableThresholdService.deleteCableThreshold(dto);
    }
}
