【同步】BOOT 和 CLOUD 的功能

pull/250/head
YunaiV 2026-05-03 23:13:12 +08:00
parent 116b6766b3
commit e3a34d9067
1 changed files with 9 additions and 9 deletions

View File

@ -8,8 +8,6 @@ import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO;
import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterRespDTO;
import cn.iocoder.yudao.module.iot.core.topic.auth.IotSubDeviceRegisterRespDTO;
import cn.iocoder.yudao.module.iot.gateway.config.IotGatewayProperties;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.core.ParameterizedTypeReference;
@ -19,6 +17,8 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
@ -42,34 +42,34 @@ public class IotDeviceApiImpl implements IotDeviceCommonApi {
IotGatewayProperties.RpcProperties rpc = gatewayProperties.getRpc();
restTemplate = new RestTemplateBuilder()
.rootUri(rpc.getUrl())
.readTimeout(rpc.getReadTimeout())
.connectTimeout(rpc.getConnectTimeout())
.setReadTimeout(rpc.getReadTimeout())
.setConnectTimeout(rpc.getConnectTimeout())
.build();
}
@Override
public CommonResult<Boolean> authDevice(IotDeviceAuthReqDTO authReqDTO) {
return doPost("/rpc-api/iot/device/auth", authReqDTO, new ParameterizedTypeReference<>() { });
return doPost("/rpc-api/iot/device/auth", authReqDTO, new ParameterizedTypeReference<CommonResult<Boolean>>() { });
}
@Override
public CommonResult<IotDeviceRespDTO> getDevice(IotDeviceGetReqDTO getReqDTO) {
return doPost("/rpc-api/iot/device/get", getReqDTO, new ParameterizedTypeReference<>() { });
return doPost("/rpc-api/iot/device/get", getReqDTO, new ParameterizedTypeReference<CommonResult<IotDeviceRespDTO>>() { });
}
@Override
public CommonResult<List<IotModbusDeviceConfigRespDTO>> getModbusDeviceConfigList(IotModbusDeviceConfigListReqDTO listReqDTO) {
return doPost("/rpc-api/iot/modbus/config-list", listReqDTO, new ParameterizedTypeReference<>() { });
return doPost("/rpc-api/iot/modbus/config-list", listReqDTO, new ParameterizedTypeReference<CommonResult<List<IotModbusDeviceConfigRespDTO>>>() { });
}
@Override
public CommonResult<IotDeviceRegisterRespDTO> registerDevice(IotDeviceRegisterReqDTO reqDTO) {
return doPost("/rpc-api/iot/device/register", reqDTO, new ParameterizedTypeReference<>() { });
return doPost("/rpc-api/iot/device/register", reqDTO, new ParameterizedTypeReference<CommonResult<IotDeviceRegisterRespDTO>>() { });
}
@Override
public CommonResult<List<IotSubDeviceRegisterRespDTO>> registerSubDevices(IotSubDeviceRegisterFullReqDTO reqDTO) {
return doPost("/rpc-api/iot/device/register-sub", reqDTO, new ParameterizedTypeReference<>() { });
return doPost("/rpc-api/iot/device/register-sub", reqDTO, new ParameterizedTypeReference<CommonResult<List<IotSubDeviceRegisterRespDTO>>>() { });
}
private <T, R> CommonResult<R> doPost(String url, T body,