Commit b6a8d12fd246c646afec96bfa66ebe20a11a9779
1 parent
b38380d0
fix: configuration default content
Showing
2 changed files
with
21 additions
and
5 deletions
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/ConfigurationCenterDTO.java
... | ... | @@ -35,5 +35,8 @@ public class ConfigurationCenterDTO extends TenantDTO { |
35 | 35 | @ApiModelProperty(value = "组态缩略图") |
36 | 36 | private String thumbnail; |
37 | 37 | |
38 | + @ApiModelProperty(value = "默认内容") | |
39 | + private String defaultContent; | |
40 | + | |
38 | 41 | private OrganizationDTO organizationDTO; |
39 | 42 | } | ... | ... |
... | ... | @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
5 | 5 | import lombok.RequiredArgsConstructor; |
6 | 6 | import lombok.extern.slf4j.Slf4j; |
7 | +import org.apache.commons.lang3.StringUtils; | |
7 | 8 | import org.springframework.stereotype.Service; |
8 | 9 | import org.springframework.transaction.annotation.Transactional; |
9 | 10 | import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants; |
... | ... | @@ -52,7 +53,9 @@ public class TkConfigurationCenterServiceImpl |
52 | 53 | if (!tenantAdmin && null != queryMap.get("userId")) { |
53 | 54 | // 获取客户的组织关系 |
54 | 55 | String userId = (String) queryMap.get("userId"); |
55 | - organizationIds = userOrganizationMappingService.compareOrganizationIdsByCustomerId(organizationIds,userId); | |
56 | + organizationIds = | |
57 | + userOrganizationMappingService.compareOrganizationIdsByCustomerId( | |
58 | + organizationIds, userId); | |
56 | 59 | } |
57 | 60 | if (null != organizationIds && organizationIds.size() > FastIotConstants.MagicNumber.ZERO) { |
58 | 61 | queryMap.put("organizationIds", organizationIds); |
... | ... | @@ -70,13 +73,22 @@ public class TkConfigurationCenterServiceImpl |
70 | 73 | TkConfigurationCenterEntity configurationCenter = |
71 | 74 | configurationCenterDTO.getEntity(TkConfigurationCenterEntity.class); |
72 | 75 | baseMapper.insert(configurationCenter); |
76 | + Integer type = FastIotConstants.PC_TYPE; | |
77 | + String defaultContent = | |
78 | + "<mxGraphModel><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel>"; | |
79 | + if (StringUtils.isNotEmpty(configurationCenterDTO.getPlatform()) | |
80 | + && configurationCenterDTO.getPlatform().equals("phone")) { | |
81 | + type = FastIotConstants.MOBILE_TYPE; | |
82 | + } | |
83 | + if (StringUtils.isNotEmpty(configurationCenterDTO.getDefaultContent())) { | |
84 | + defaultContent = configurationCenterDTO.getDefaultContent(); | |
85 | + } | |
73 | 86 | ConfigurationContentDTO contentDTO = new ConfigurationContentDTO(); |
74 | 87 | contentDTO.setTenantId(configurationCenter.getTenantId()); |
75 | - contentDTO.setType(FastIotConstants.PC_TYPE); | |
88 | + contentDTO.setType(type); | |
76 | 89 | contentDTO.setName(FastIotConstants.FIRST_PAGE_NAME); |
77 | 90 | contentDTO.setConfigurationId(configurationCenter.getId()); |
78 | - contentDTO.setContent( | |
79 | - "<mxGraphModel><root><mxCell id=\"0\"/><mxCell id=\"1\" parent=\"0\"/></root></mxGraphModel>"); | |
91 | + contentDTO.setContent(defaultContent); | |
80 | 92 | ytConfigurationContentService.saveConfigurationContent(contentDTO); |
81 | 93 | return configurationCenterDTO; |
82 | 94 | } |
... | ... | @@ -84,7 +96,8 @@ public class TkConfigurationCenterServiceImpl |
84 | 96 | @Override |
85 | 97 | @Transactional |
86 | 98 | public ConfigurationCenterDTO updateConfiguration(ConfigurationCenterDTO configurationCenterDTO) { |
87 | - TkConfigurationCenterEntity configurationCenter = baseMapper.selectById(configurationCenterDTO.getId()); | |
99 | + TkConfigurationCenterEntity configurationCenter = | |
100 | + baseMapper.selectById(configurationCenterDTO.getId()); | |
88 | 101 | if (!configurationCenter.getTenantId().equals(configurationCenterDTO.getTenantId())) { |
89 | 102 | throw new TkDataValidationException(ErrorMessage.TENANT_MISMATCHING.getMessage()); |
90 | 103 | } | ... | ... |