Commit df7dae58c96d9f75aa1e477049ac384042e2c401

Authored by 云中非
1 parent 9280bee6

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

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