/**
 * 
 */
package com.huatek.busi.controller;

import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
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.BusiExternalEquipmentDto;
import com.huatek.busi.entity.BusiExternalEquipment;
import com.huatek.busi.service.BusiExternalEquipmentService;
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;

/**
  * @ClassName: BusiExternalEquipmentController
  * @FullClassPath: com.huatek.busi.controller.BusiExternalEquipmentController
  * @Description: 外挂设备控制器.
  * @author: Arno
  * @date: Jul 17, 2019 6:39:48 PM
  * @version: 1.0
  */
@Api(tags = {Tags.BUSI_EXTERNALEQUIPMENT})
@RestController
@RequestMapping("/api/BusiExternalEquipment")
public class BusiExternalEquipmentController {
	
	
	@Reference(check = false)
    private  BusiExternalEquipmentService busiExternalEquipmentService;
	
	
	 
    /** 
    * @Title: info 
    * @Description: 获取外挂设备信息 
    * @createDate: Jul 17, 2019 6:42:56 PM
    * @param    equipmentId   -- 外挂设备树节点ID
    * @return   Map<String,Object>    
    * @throws 
    */ 
    @ApiOperation(value = "获取外挂设备信息")
    @ApiImplicitParam(name = "equipmentId", value = "外挂设备树节点ID")
    @GetMapping(value = "/info")
    public Map<String, Object> info(@RequestParam("equipmentId") String equipmentId) {
    	BusiExternalEquipment entity = busiExternalEquipmentService.getByEquipmentId(equipmentId);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", entity);
    }
    
    @ApiOperation(value = "修改外挂设备信息")
    @PostMapping(value = "/update")
    public Map<String, Object> update(@RequestBody BusiExternalEquipmentDto entityDto) {
        busiExternalEquipmentService.updateBusiExternalEquipment(entityDto);
        Map<String, Object> map = ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
        return map;
    }

    @ApiOperation(value = "查询外挂设备信息")
    @PostMapping(value = "/queryBusiExternalEquipmentBySiteId")
    public Map<String, Object> queryBusiExternalEquipmentBySiteId() {
        List<BusiExternalEquipment> externalEquipmentList = busiExternalEquipmentService.queryBusiExternalEquipment();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", externalEquipmentList);
    }
    
    @ApiOperation(value = "根据siteId和设备类型查询外挂设备信息")
    @GetMapping(value = "/queryBusiExternalEquipmentByCondition")
    public Map<String, Object> queryBusiExternalEquipmentByCondition(@RequestParam("mainEqmId") String mainEqmId,@RequestParam("externalType") String externalType) {
        List<BusiExternalEquipment> externalEquipmentList = busiExternalEquipmentService.queryBusiExternalEquipmentByCondition(mainEqmId,externalType);
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", externalEquipmentList);
    }
}