Commit df7dae58c96d9f75aa1e477049ac384042e2c401

Authored by 云中非
1 parent 9280bee6

refactor: 设备配置返回更多信息

1 package org.thingsboard.server.common.data.yunteng.dto; 1 package org.thingsboard.server.common.data.yunteng.dto;
2 2
  3 +import com.fasterxml.jackson.databind.JsonNode;
3 import io.swagger.annotations.ApiModelProperty; 4 import io.swagger.annotations.ApiModelProperty;
4 import lombok.Data; 5 import lombok.Data;
5 import lombok.EqualsAndHashCode; 6 import lombok.EqualsAndHashCode;
  7 +import org.thingsboard.common.util.JacksonUtil;
  8 +import org.thingsboard.server.common.data.DeviceProfileType;
6 import org.thingsboard.server.common.data.DeviceTransportType; 9 import org.thingsboard.server.common.data.DeviceTransportType;
7 import org.thingsboard.server.common.data.device.profile.DeviceProfileData; 10 import org.thingsboard.server.common.data.device.profile.DeviceProfileData;
8 import org.thingsboard.server.common.data.yunteng.common.AddGroup; 11 import org.thingsboard.server.common.data.yunteng.common.AddGroup;
@@ -50,26 +53,39 @@ public class DeviceProfileDTO extends TenantDTO { @@ -50,26 +53,39 @@ public class DeviceProfileDTO extends TenantDTO {
50 /**默认消息队列*/ 53 /**默认消息队列*/
51 private String defaultQueueName; 54 private String defaultQueueName;
52 55
  56 + /**设备配置图片*/
  57 + private String image;
  58 + /**是否默认设备配置*/
  59 + private boolean isDefault;
  60 + private String type;
  61 +
53 public DeviceProfileDTO() { 62 public DeviceProfileDTO() {
54 } 63 }
55 64
56 - public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, UUID defaultRuleChainId) { 65 + public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, UUID defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type,Object profileData) {
57 setId(id.toString()); 66 setId(id.toString());
58 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); 67 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC));
59 this.name = name; 68 this.name = name;
  69 + this.isDefault = isDefault;
  70 + this.image = image;
60 this.description = description; 71 this.description = description;
  72 + this.type = type.name();
61 this.transportType = transportType.name(); 73 this.transportType = transportType.name();
62 this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null); 74 this.defaultRuleChainId = Optional.ofNullable(defaultRuleChainId).map(chainId -> chainId.toString()).orElse(null);
  75 + this.profileData = JacksonUtil.convertValue(profileData, DeviceProfileData.class);
  76 +
63 } 77 }
64 78
65 - public DeviceProfileDTO(UUID id, String name, Long time, String description, String convertJs, DeviceTransportType transportType, DeviceProfileData profileData, String defaultRuleChainId) { 79 + public DeviceProfileDTO(UUID id, String name, Long time, String description, DeviceTransportType transportType, String defaultRuleChainId,boolean isDefault,String image,DeviceProfileType type, String convertJs) {
66 setId(id.toString()); 80 setId(id.toString());
67 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC)); 81 setCreateTime(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneOffset.UTC));
68 this.name = name; 82 this.name = name;
  83 + this.isDefault = isDefault;
  84 + this.image = image;
69 this.description = description; 85 this.description = description;
  86 + this.type = type.name();
70 this.convertJs = convertJs; 87 this.convertJs = convertJs;
71 this.transportType = transportType.name(); 88 this.transportType = transportType.name();
72 this.defaultRuleChainId = defaultRuleChainId.toString(); 89 this.defaultRuleChainId = defaultRuleChainId.toString();
73 - this.profileData = profileData;  
74 } 90 }
75 } 91 }
@@ -30,7 +30,7 @@ import java.util.UUID; @@ -30,7 +30,7 @@ import java.util.UUID;
30 public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEntity, UUID> { 30 public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEntity, UUID> {
31 31
32 32
33 - @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId) " + 33 + @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId,d.isDefault,d.image,d.type,d.profileData) " +
34 "FROM DeviceProfileEntity d WHERE " + 34 "FROM DeviceProfileEntity d WHERE " +
35 "d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))") 35 "d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
36 Page<DeviceProfileDTO> findDeviceProfileInfos(@Param("tenantId") UUID tenantId, 36 Page<DeviceProfileDTO> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@@ -38,7 +38,7 @@ public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEn @@ -38,7 +38,7 @@ public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEn
38 @Param("transportType") DeviceTransportType transportType, 38 @Param("transportType") DeviceTransportType transportType,
39 Pageable pageable); 39 Pageable pageable);
40 40
41 - @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId) " + 41 + @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId,d.isDefault,d.image,d.type,d.profileData) " +
42 "FROM DeviceProfileEntity d WHERE " + 42 "FROM DeviceProfileEntity d WHERE " +
43 "d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))") 43 "d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
44 Page<DeviceProfileDTO> findDeviceProfileInfos(@Param("tenantId") UUID tenantId, 44 Page<DeviceProfileDTO> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@@ -46,7 +46,7 @@ public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEn @@ -46,7 +46,7 @@ public interface YtDeviceProfileRepository extends JpaRepository<DeviceProfileEn
46 Pageable pageable); 46 Pageable pageable);
47 47
48 48
49 - @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId) " + 49 + @Query("SELECT new org.thingsboard.server.common.data.yunteng.dto.DeviceProfileDTO(d.id, d.name, d.createdTime,d.description, d.transportType, d.defaultRuleChainId,d.isDefault,d.image,d.type,d.profileData) " +
50 "FROM DeviceProfileEntity d WHERE d.tenantId = :tenantId ") 50 "FROM DeviceProfileEntity d WHERE d.tenantId = :tenantId ")
51 List<DeviceProfileDTO> findDeviceProfileByTenantId(@Param("tenantId") UUID tenantId); 51 List<DeviceProfileDTO> findDeviceProfileByTenantId(@Param("tenantId") UUID tenantId);
52 52