Merge pull request #4762 from YevhenBondarenko/feature/ota-improvements

improved countByDeviceProfileAndEmptyOtaPackage api
This commit is contained in:
Igor Kulikov 2021-06-18 17:30:37 +03:00 committed by GitHub
commit db9ef3e976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -782,15 +782,17 @@ public class DeviceController extends BaseController {
} }
@PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')") @PreAuthorize("hasAnyAuthority('TENANT_ADMIN', 'CUSTOMER_USER')")
@RequestMapping(value = "/devices/count/{otaPackageType}", method = RequestMethod.GET) @RequestMapping(value = "/devices/count/{otaPackageType}/{deviceProfileId}", method = RequestMethod.GET)
@ResponseBody @ResponseBody
public Long countDevicesByTenantIdAndDeviceProfileIdAndEmptyOtaPackage(@PathVariable("otaPackageType") String otaPackageType, public Long countByDeviceProfileAndEmptyOtaPackage(@PathVariable("otaPackageType") String otaPackageType,
@RequestParam String deviceProfileId) throws ThingsboardException { @PathVariable("deviceProfileId") String deviceProfileId) throws ThingsboardException {
checkParameter("OtaPackageType", otaPackageType); checkParameter("OtaPackageType", otaPackageType);
checkParameter("DeviceProfileId", deviceProfileId); checkParameter("DeviceProfileId", deviceProfileId);
try { try {
return deviceService.countDevicesByTenantIdAndDeviceProfileIdAndEmptyOtaPackage( return deviceService.countDevicesByTenantIdAndDeviceProfileIdAndEmptyOtaPackage(
getCurrentUser().getTenantId(), new DeviceProfileId(UUID.fromString(deviceProfileId)), OtaPackageType.valueOf(otaPackageType)); getTenantId(),
new DeviceProfileId(UUID.fromString(deviceProfileId)),
OtaPackageType.valueOf(otaPackageType));
} catch (Exception e) { } catch (Exception e) {
throw handleException(e); throw handleException(e);
} }

View File

@ -1257,7 +1257,7 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
params.put("deviceProfileId", deviceProfileId.getId().toString()); params.put("deviceProfileId", deviceProfileId.getId().toString());
return restTemplate.exchange( return restTemplate.exchange(
baseURL + "/api/devices/count/{otaPackageType}?deviceProfileId={deviceProfileId}", baseURL + "/api/devices/count/{otaPackageType}/{deviceProfileId}",
HttpMethod.GET, HttpMethod.GET,
HttpEntity.EMPTY, HttpEntity.EMPTY,
new ParameterizedTypeReference<Long>() { new ParameterizedTypeReference<Long>() {

View File

@ -133,7 +133,7 @@ export class OtaPackageService {
} }
public countUpdateDeviceAfterChangePackage(type: OtaUpdateType, entityId: EntityId, config?: RequestConfig): Observable<number> { public countUpdateDeviceAfterChangePackage(type: OtaUpdateType, entityId: EntityId, config?: RequestConfig): Observable<number> {
return this.http.get<number>(`/api/devices/count/${type}?deviceProfileId=${entityId.id}`, defaultHttpOptionsFromConfig(config)); return this.http.get<number>(`/api/devices/count/${type}/${entityId.id}`, defaultHttpOptionsFromConfig(config));
} }
public confirmDialogUpdatePackage(entity: BaseData<EntityId>&OtaPagesIds, public confirmDialogUpdatePackage(entity: BaseData<EntityId>&OtaPagesIds,