package com.huatek.busi.controller;

import java.util.Map;

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 com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.dto.TransformerTgThresholdDto;
import com.huatek.busi.service.threshold.TransformerTgThresholdService;
import com.huatek.busi.vo.TransformerTgThresholdVo;
import com.huatek.torch.frame.log.KerLog;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * 变压器套管阈值 控制层
 *
 * @author anker_cheng
 * @date 2019-8-8 19:26:07
 */
@Api(tags = {Tags.BUSI_TG_SENSOR_THRESHOLD})
@Slf4j
@RestController
@RequestMapping("/api/TransformerTgThreshold")
public class TransformerTgThresholdController {

    @Reference(check = false)
    private TransformerTgThresholdService transformerTgThresholdService;


    /**
     * 维护 变压器套管阈值
     *
     * @param token          the token
     * @param transformerTgThresholdDto 变压器套管阈值Dto
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TG_SENSOR_THRESHOLD_SAVE)
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERTGTHRESHOLD.MODELNAME", methodName = "TRANSFORMERTGTHRESHOLD.METHODNAME.ADDTRANSFORMERTGTHRESHOLD")
    @PostMapping(value = "/saveTransformerTgThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> addTransformerTgThreshold(String token,@RequestBody TransformerTgThresholdDto transformerTgThresholdDto) {
        int count = transformerTgThresholdService.saveTransformerTgThreshold(token, transformerTgThresholdDto);
        log.debug("addTransformerTgThreshold: {}", count);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }

     /**
     * 通过id查找 变压器套管阈值
     *
     * @param id id
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TG_SENSOR_THRESHOLD_INFO)
    @KerLog(projectName = "PROJECTNAME", modelName = "TRANSFORMERTGTHRESHOLD.MODELNAME", methodName = "TRANSFORMERTGTHRESHOLD.METHODNAME.FINDTRANSFORMERTGTHRESHOLD")
    @PostMapping(value = "/findTransformerTgThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object>  findTransformerTgThreshold(@RequestBody TransformerTgThresholdDto transformerTgThresholdDto) {
        TransformerTgThresholdVo transformerTgThreshold =transformerTgThresholdService.findTransformerTgThreshold(transformerTgThresholdDto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", transformerTgThreshold);
    }
}