package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.constant.ApiConstant.Tags;
import com.huatek.busi.dto.TransformerOilThresholdDto;
import com.huatek.busi.service.threshold.TransformerOilThresholdService;
import com.huatek.busi.vo.TransformerOilThresholdVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 油色谱阈值控制层
 *
 * @author walker_wang
 * @date Jul 5, 2019 1:43:01 PM
 */
@Api(tags = {Tags.BUSI_YSP_SENSOR_THRESHOLD})
@RestController
@RequestMapping("/api/BusiOilThreshold")
public class BusiTransformerOilThresholdController {

    @Reference(check = false)
    private TransformerOilThresholdService transformerOilThresholdService;

   
    @ApiOperation(value = Tags.BUSI_YSP_SENSOR_THRESHOLD)
    @ApiImplicitParam(name = "info", value = "油色谱阈值详情")
    @GetMapping(value = "/info", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> info( @RequestParam("sensorCode") String sensorCode) {
    	TransformerOilThresholdVo info = transformerOilThresholdService.getBySensorCode(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", info);
    }

    @ApiOperation(value = Tags.BUSI_YSP_TYPE)
    @ApiImplicitParam(name = "findType", value = "油色谱阈值详情")
    @GetMapping(value = "/findType", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> findType( @RequestParam("sensorCode") String sensorCode) {
        Map<String, Object> typeMap = transformerOilThresholdService.findType(sensorCode);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", typeMap);
    }

	@ApiOperation(value = Tags.BUSI_YSP_SENSOR_THRESHOLD_SAVE)
    @ApiImplicitParam(name = "save", value = "油色谱阈值保存")
    @PostMapping(value = "/save", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> save( @RequestBody TransformerOilThresholdDto dto) {
    	 transformerOilThresholdService.save(dto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }
    
    
	@ApiOperation(value = Tags.BUSI_YSP_SENSOR_THRESHOLD_UPDATE)   
    @ApiImplicitParam(name = "update", value = "油色谱阈值修改")
    @PostMapping(value = "/update", produces = {"application/json;charset=utf-8"})
    public Map<String, Object> update( @RequestBody TransformerOilThresholdDto dto) {
    	 transformerOilThresholdService.update(dto);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
    }
}