Commit 8d11400e1c59df0772e9b80374fd2b483eabc61d

Authored by 云中非
1 parent 0da8eb4e

refactor: 创建租户时,默认创建三种设备类型的设备配置

... ... @@ -43,6 +43,8 @@ public interface DeviceProfileService {
43 43
44 44 DeviceProfile createDefaultDeviceProfile(TenantId tenantId);
45 45
  46 + DeviceProfile createDeviceProfile(TenantId tenantId,String name);
  47 +
46 48 DeviceProfile findDefaultDeviceProfile(TenantId tenantId);
47 49
48 50 DeviceProfileInfo findDefaultDeviceProfileInfo(TenantId tenantId);
... ...
... ... @@ -215,6 +215,12 @@ public class DeviceProfileServiceImpl extends AbstractEntityService implements D
215 215 return doCreateDefaultDeviceProfile(tenantId, "default", true);
216 216 }
217 217
  218 + @Override
  219 + public DeviceProfile createDeviceProfile(TenantId tenantId, String name) {
  220 + log.trace("Executing createDeviceProfile tenantId [{}]", tenantId);
  221 + return doCreateDefaultDeviceProfile(tenantId, name, false);
  222 + }
  223 +
218 224 private DeviceProfile doCreateDefaultDeviceProfile(TenantId tenantId, String profileName, boolean defaultProfile) {
219 225 validateId(tenantId, INCORRECT_TENANT_ID + tenantId);
220 226 DeviceProfile deviceProfile = new DeviceProfile();
... ...
... ... @@ -140,8 +140,16 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
140 140
141 141 //Thingskit function
142 142 DeviceProfile deviceProfile = deviceProfileService.createDefaultDeviceProfile(savedTenant.getId());
143   - DeviceProfileDTO profileDTO = new DeviceProfileDTO(deviceProfile.getName(),deviceProfile.getTenantId(),deviceProfile.getId(), DeviceTypeEnum.DIRECT_CONNECTION);
  143 + DeviceProfileDTO profileDTO = new DeviceProfileDTO(deviceProfile.getName(),deviceProfile.getTenantId(),deviceProfile.getId(), DeviceTypeEnum.SENSOR);
144 144 ytDeviceProfileService.insertOrUpdate(profileDTO);
  145 + DeviceProfile gatewayProfile = deviceProfileService.createDeviceProfile(savedTenant.getId(),"默认MQTT网关设备");
  146 + DeviceProfileDTO gatewayDTO = new DeviceProfileDTO(gatewayProfile.getName(),gatewayProfile.getTenantId(),gatewayProfile.getId(), DeviceTypeEnum.GATEWAY);
  147 + ytDeviceProfileService.insertOrUpdate(gatewayDTO);
  148 + DeviceProfile directProfile = deviceProfileService.createDeviceProfile(savedTenant.getId(),"默认MQTT直连设备");
  149 + DeviceProfileDTO directDTO = new DeviceProfileDTO(directProfile.getName(),directProfile.getTenantId(),directProfile.getId(), DeviceTypeEnum.DIRECT_CONNECTION);
  150 + ytDeviceProfileService.insertOrUpdate(directDTO);
  151 +
  152 +
145 153 apiUsageStateService.createDefaultApiUsageState(savedTenant.getId(), null);
146 154
147 155 }
... ...