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.TransformerIcgeThresholdDto;
import com.huatek.busi.service.threshold.TransformerIcgeThresholdService;
import com.huatek.busi.vo.TransformerIcgeThresholdVo;
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 16:00:45
 */
@Api(tags = {Tags.BUSI_TXJJ_SENSOR_THRESHOLD})
@Slf4j
@RestController
@RequestMapping("/api/TransformerIcgeThreshold")
public class TransformerIcgeThresholdController {

    @Reference(check = false)
    private TransformerIcgeThresholdService transformerIcgeThresholdService;


    /**
     * 添加、编辑 变压器铁芯、夹件阈值表
     *
     * @param token          the token
     * @param transformerIcgeThresholdDto 变压器铁芯、夹件阈值表Dto
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TXJJ_SENSOR_THRESHOLD_SAVE)
    @PostMapping(value = "/saveTransformerIcgeThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> addTransformerIcgeThreshold(String token,@RequestBody TransformerIcgeThresholdDto transformerIcgeThresholdDto) {
        int count = transformerIcgeThresholdService.saveTransformerIcgeThreshold(token, transformerIcgeThresholdDto);
        log.debug("addTransformerIcgeThreshold: {}", count);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }

    /**
     * 通过id查找 变压器铁芯、夹件阈值表
     *
     * @param id
     *            id
     * @return map map
     */
    @ApiOperation(value = Tags.BUSI_TXJJ_SENSOR_THRESHOLD_INFO)
    @PostMapping(value = "/findTransformerIcgeThreshold", produces = {"application/json;charset=utf-8"})
    public Map<String, Object>
        findTransformerIcgeThreshold(@RequestBody TransformerIcgeThresholdDto transformerIcgeThresholdDto) {
        TransformerIcgeThresholdVo vo =
            transformerIcgeThresholdService.getTransformerIcgeThresholdVo(transformerIcgeThresholdDto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", vo);
    }
}