Commit e31bce9f3189ed0ae0175238f1471cd4fe861ccb
1 parent
f55cd9d6
fix: product detail add deviceCount
Showing
4 changed files
with
16 additions
and
4 deletions
... | ... | @@ -131,7 +131,7 @@ public class TkDeviceProfileController extends BaseController { |
131 | 131 | "@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{'api:yt:deviceProfile:get'})") |
132 | 132 | public ResponseEntity<DeviceProfileDTO> getDevice(@PathVariable("id") String id) |
133 | 133 | throws ThingsboardException { |
134 | - return ResponseEntity.of( | |
134 | + return ResponseEntity.ok( | |
135 | 135 | ytDeviceProfileService.getDeviceProfile(getCurrentUser().getCurrentTenantId(), id)); |
136 | 136 | } |
137 | 137 | ... | ... |
... | ... | @@ -71,6 +71,9 @@ public class DeviceProfileDTO extends BaseDTO { |
71 | 71 | @ApiModelProperty(value = "物模型") |
72 | 72 | private ThingsModelDTO thingsModel; |
73 | 73 | |
74 | + @ApiModelProperty(value = "产品下的设备数量") | |
75 | + private Integer deviceCount; | |
76 | + | |
74 | 77 | public DeviceProfileDTO() {} |
75 | 78 | |
76 | 79 | public DeviceProfileDTO( | ... | ... |
... | ... | @@ -152,8 +152,17 @@ public class TkDeviceProfileServiceImpl |
152 | 152 | } |
153 | 153 | |
154 | 154 | @Override |
155 | - public Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id) { | |
156 | - return Optional.ofNullable(baseMapper.selectDetail(tenantId, id)); | |
155 | + public DeviceProfileDTO getDeviceProfile(String tenantId, String id) { | |
156 | + DeviceProfileDTO deviceProfileDTO = baseMapper.selectDetail(tenantId, id); | |
157 | + if (null != deviceProfileDTO) { | |
158 | + int deviceCount = | |
159 | + deviceMapper.selectCount( | |
160 | + new LambdaQueryWrapper<TkDeviceEntity>() | |
161 | + .eq(TkDeviceEntity::getTenantId, tenantId) | |
162 | + .eq(TkDeviceEntity::getDeviceProfileId, deviceProfileDTO.getId())); | |
163 | + deviceProfileDTO.setDeviceCount(deviceCount); | |
164 | + } | |
165 | + return deviceProfileDTO; | |
157 | 166 | } |
158 | 167 | |
159 | 168 | @Override | ... | ... |
... | ... | @@ -19,7 +19,7 @@ public interface TkDeviceProfileService extends BaseService<TkDeviceProfileEntit |
19 | 19 | |
20 | 20 | void checkDeviceProfiles(String tenantId, Set<String> ids); |
21 | 21 | |
22 | - Optional<DeviceProfileDTO> getDeviceProfile(String tenantId, String id); | |
22 | + DeviceProfileDTO getDeviceProfile(String tenantId, String id); | |
23 | 23 | |
24 | 24 | TkPageData<DeviceProfileDTO> page(Map<String, Object> queryMap, boolean isTenantAdmin); |
25 | 25 | ... | ... |