package com.cmvr.web.controller.api;


import com.cmvr.device.domain.DeDeviceRegistration;
import com.cmvr.device.service.IDeDeviceRegistrationService;
import com.cmvr.edge.client.service.EdgeSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "边缘--设备信息获取")
@RestController
@RequestMapping("/api/deviceList")
@RequiredArgsConstructor
public class DeviceListController {

    private final EdgeSystemService systemService;
    private final IDeDeviceRegistrationService registrationService;


    @PreAuthorize("@ss.hasPermi('device:profile:list')")
    @GetMapping("/addList")
    @ApiOperation("同步设备信息列表")
    public int addDeviceList(@RequestParam String terminalId){

        List<DeDeviceRegistration> list = systemService.deviceList(terminalId);

        return registrationService.addDeviceList(list);
    }



}
