package com.fastbee.data.controller.deviceActivation;

import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.iot.service.IDeviceActivationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "设备激活")
@RestController
@RequestMapping("/deviceactivation")
public class DeviceActivationController extends BaseController {
    @Autowired
    IDeviceActivationService deviceActivationService;

    @PutMapping("/activation")
    @ApiOperation("上电设备激活接口")
    public AjaxResult getDevieceList(@RequestBody DeviceActivationDto deviceActivationDto)
    {

        System.err.println("-=-=-=-=-=-=-=-=-=-=-=-=-=激活设备名称"+deviceActivationDto.name);
        //获取tenantId和tenantName
        String[] idAndName=deviceActivationDto.tenantIdAndName.split(",",2);
        Long tenantId= Long.valueOf(idAndName[0].replace(" ",""));
        String tenantName=idAndName[1].trim();
        return AjaxResult.success(deviceActivationService.selectDevice(deviceActivationDto.serialNumber,
                tenantId,tenantName,deviceActivationDto.longitude,
                deviceActivationDto.latitude,deviceActivationDto.imgUrl,
                deviceActivationDto.name));
    }

    /*@GetMapping("/info/{userId}")
    @ApiOperation("获取项目信息")
    public AjaxResult getProjectInfo(@PathVariable("userId") Long userId){
        return success(projectService.selectProjectByUserId(userId));
    }*/
}
