Commit b6a8d12fd246c646afec96bfa66ebe20a11a9779

Authored by 黄 x
1 parent b38380d0

fix: configuration default content

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