Commit 084bfe4e445ad807346719a25f4392bfa98ecbeb
Merge branch 'fix/configure' into 'master_dev'
Fix/configure See merge request yunteng/thingskit!451
Showing
14 changed files
with
155 additions
and
14 deletions
... | ... | @@ -7,7 +7,6 @@ update tk_configuration_content_node set configuration_node_id = id; |
7 | 7 | CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; |
8 | 8 | update tk_configuration_content_node set id = uuid_generate_v4(); |
9 | 9 | |
10 | ---添加3d组件的新表 | |
11 | 10 | CREATE TABLE "public"."tk_3d_component" ( |
12 | 11 | "id" varchar(36) COLLATE "pg_catalog"."default" NOT NULL, |
13 | 12 | "content" text COLLATE "pg_catalog"."default" NOT NULL, |
... | ... | @@ -17,7 +16,8 @@ CREATE TABLE "public"."tk_3d_component" ( |
17 | 16 | "create_time" timestamp(6), |
18 | 17 | "update_time" timestamp(6), |
19 | 18 | "name" varchar(128) COLLATE "pg_catalog"."default", |
20 | - "state" int2 | |
19 | + "state" int2, | |
20 | + "image_url" varchar(255) COLLATE "pg_catalog"."default" | |
21 | 21 | ) |
22 | 22 | ; |
23 | 23 | COMMENT ON COLUMN "public"."tk_3d_component"."id" IS '主建'; |
... | ... | @@ -28,9 +28,10 @@ COMMENT ON COLUMN "public"."tk_3d_component"."tenant_id" IS '租户ID'; |
28 | 28 | COMMENT ON COLUMN "public"."tk_3d_component"."create_time" IS '创建时间'; |
29 | 29 | COMMENT ON COLUMN "public"."tk_3d_component"."update_time" IS '更新时间'; |
30 | 30 | COMMENT ON COLUMN "public"."tk_3d_component"."name" IS '名称'; |
31 | -COMMENT ON COLUMN "public"."tk_3d_component"."state" IS '状态:0未发布,1已发布'; | |
31 | +COMMENT ON COLUMN "public"."tk_3d_component"."state" IS '状态:0创建,1发布'; | |
32 | +COMMENT ON COLUMN "public"."tk_3d_component"."image_url" IS '图标'; | |
32 | 33 | |
33 | 34 | -- ---------------------------- |
34 | 35 | -- Primary Key structure for table tk_3d_component |
35 | 36 | -- ---------------------------- |
36 | -ALTER TABLE "public"."tk_3d_component" ADD CONSTRAINT "tk_3d_component_pkey" PRIMARY KEY ("id"); | |
\ No newline at end of file | ||
37 | +ALTER TABLE "public"."tk_3d_component" ADD CONSTRAINT "tk_3d_component_pkey" PRIMARY KEY ("id"); | ... | ... |
... | ... | @@ -2,8 +2,11 @@ package org.thingsboard.server.controller.yunteng; |
2 | 2 | |
3 | 3 | import com.fasterxml.jackson.databind.JsonNode; |
4 | 4 | import io.swagger.annotations.Api; |
5 | +import io.swagger.annotations.ApiModelProperty; | |
5 | 6 | import io.swagger.annotations.ApiOperation; |
6 | 7 | import io.swagger.annotations.ApiParam; |
8 | +import lombok.Data; | |
9 | +import org.springframework.beans.BeanUtils; | |
7 | 10 | import org.springframework.http.ResponseEntity; |
8 | 11 | import org.springframework.security.access.prepost.PreAuthorize; |
9 | 12 | import org.springframework.util.StringUtils; |
... | ... | @@ -73,14 +76,15 @@ public class Tk3dComponentController extends BaseController { |
73 | 76 | } |
74 | 77 | |
75 | 78 | |
76 | - @PostMapping("/{id}") | |
79 | + @PostMapping | |
77 | 80 | @ApiOperation("保存") |
78 | - public ResponseEntity<Tk3dComponentDTO> save(@ApiParam("id")@PathVariable("id") String id, @RequestBody JsonNode jsonNode) throws ThingsboardException { | |
81 | + public ResponseEntity<Tk3dComponentDTO> save(@ApiParam("id")@RequestParam("id") String id, @RequestParam("imageUrl") String imageUrl,@RequestBody JsonNode jsonNode) throws ThingsboardException { | |
79 | 82 | if(!StringUtils.hasLength(id)){ |
80 | 83 | throw new TkDataValidationException(MessageUtils.message(ErrorMessage.INVALID_PARAMETER.getI18nCode())); |
81 | 84 | } |
82 | 85 | Tk3dComponentDTO dto=new Tk3dComponentDTO(); |
83 | 86 | dto.setId(id); |
87 | + dto.setImageUrl(imageUrl); | |
84 | 88 | dto.setTenantId(getTenantId().getId().toString()); |
85 | 89 | dto.setContent(jsonNode); |
86 | 90 | return ResponseEntity.ok(tk3dComponentService.save(dto)); |
... | ... | @@ -97,6 +101,7 @@ public class Tk3dComponentController extends BaseController { |
97 | 101 | return ResponseEntity.ok(tk3dComponentService.save(dto)); |
98 | 102 | } |
99 | 103 | |
104 | + | |
100 | 105 | @PutMapping("/publish/{id}/{state}") |
101 | 106 | @ApiOperation("发布") |
102 | 107 | public ResponseEntity<Tk3dComponentDTO> publish(@PathVariable("id") String id,@PathVariable("state") Integer state) throws ThingsboardException { |
... | ... | @@ -138,4 +143,20 @@ public class Tk3dComponentController extends BaseController { |
138 | 143 | return ResponseEntity.ok(tk3dComponentService.delete(getCurrentUser().getCurrentTenantId(),ids)); |
139 | 144 | } |
140 | 145 | |
146 | + @Data | |
147 | + private static class ComponentParam{ | |
148 | + | |
149 | + @ApiModelProperty("ID") | |
150 | + String id; | |
151 | + | |
152 | + @ApiModelProperty("名称") | |
153 | + String name; | |
154 | + | |
155 | + @ApiModelProperty("是否发布:0否,1是") | |
156 | + Integer state; | |
157 | + | |
158 | + @ApiModelProperty("图标地址") | |
159 | + String imageUrl; | |
160 | + } | |
161 | + | |
141 | 162 | } | ... | ... |
... | ... | @@ -86,6 +86,9 @@ import org.thingsboard.server.service.edge.rpc.yunteng.sys_tenant.SysTenantRepos |
86 | 86 | import org.thingsboard.server.service.edge.rpc.yunteng.sys_user.SysUserRepository; |
87 | 87 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_alarm_contact.TkAlarmContactRepository; |
88 | 88 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_alarm_profile.TkAlarmProfileRepository; |
89 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center.TkConfigurationCenterRepository; | |
90 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content.TkConfigurationContentRepository; | |
91 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node.TkConfigurationContentNodeRepository; | |
89 | 92 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_profile_category.TkDeviceProfileCategoryRepository; |
90 | 93 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log.TkDeviceStateLogRepository; |
91 | 94 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_event_kv.TkEventKvRepository; |
... | ... | @@ -321,5 +324,11 @@ public class EdgeContextComponent { |
321 | 324 | private final TkThingsModelRepository tkThingsModelRepository; |
322 | 325 | @Autowired |
323 | 326 | private final SysTenantRepository sysTenantRepository; |
327 | + @Autowired | |
328 | + private final TkConfigurationCenterRepository tkConfigurationCenterRepository; | |
329 | + @Autowired | |
330 | + private final TkConfigurationContentRepository tkConfigurationContentRepository; | |
331 | + @Autowired | |
332 | + private final TkConfigurationContentNodeRepository tkConfigurationContentNodeRepository; | |
324 | 333 | //thingskit end |
325 | 334 | } | ... | ... |
... | ... | @@ -45,6 +45,9 @@ import org.thingsboard.server.service.edge.rpc.yunteng.sys_tenant.SysTenantEdgeE |
45 | 45 | import org.thingsboard.server.service.edge.rpc.yunteng.sys_user.SysUserEdgeEventFetcher; |
46 | 46 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_alarm_contact.TkAlarmContactEdgeEventFetcher; |
47 | 47 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_alarm_profile.TkAlarmProfileEdgeEventFetcher; |
48 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center.TkConfigurationCenterEdgeEventFetcher; | |
49 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content.TkConfigurationContentEdgeEventFetcher; | |
50 | +import org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node.TkConfigurationContentNodeEdgeEventFetcher; | |
48 | 51 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_profile_category.TkDeviceProfileCategoryEdgeEventFetcher; |
49 | 52 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_device_state_log.TkDeviceStateLogEdgeEventFetcher; |
50 | 53 | import org.thingsboard.server.service.edge.rpc.yunteng.tk_java_script.TkJavaScriptEdgeEventFetcher; |
... | ... | @@ -96,6 +99,10 @@ public class EdgeSyncCursor { |
96 | 99 | fetchers.add(new MessageConfigEdgeEventFetcher(ctx.getMessageConfigRepository()));//消息字典 |
97 | 100 | fetchers.add(new TkMessageTemplateEdgeEventFetcher(ctx.getTkMessageTemplateRepository()));//消息模板 |
98 | 101 | fetchers.add(new TkOrganizationEdgeEventFetcher(ctx.getTkOrganizationRepository()));//组织 |
102 | + | |
103 | + fetchers.add(new TkConfigurationCenterEdgeEventFetcher(ctx.getTkConfigurationCenterRepository())); | |
104 | + fetchers.add(new TkConfigurationContentEdgeEventFetcher(ctx.getTkConfigurationContentRepository())); | |
105 | + fetchers.add(new TkConfigurationContentNodeEdgeEventFetcher(ctx.getTkConfigurationContentNodeRepository())); | |
99 | 106 | //thingsKit end |
100 | 107 | |
101 | 108 | fetchers.add(new DashboardsEdgeEventFetcher(ctx.getDashboardService())); | ... | ... |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_center; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.extern.slf4j.Slf4j; | |
5 | +import org.thingsboard.server.common.data.EdgeUtils; | |
6 | +import org.thingsboard.server.common.data.edge.Edge; | |
7 | +import org.thingsboard.server.common.data.edge.EdgeEvent; | |
8 | +import org.thingsboard.server.common.data.edge.EdgeEventActionType; | |
9 | +import org.thingsboard.server.common.data.edge.EdgeEventType; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.page.PageData; | |
12 | +import org.thingsboard.server.common.data.page.PageLink; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
14 | +import org.thingsboard.server.common.data.yunteng.sync.TkDeviceProfileCategory; | |
15 | +import org.thingsboard.server.service.edge.rpc.fetch.BasePageableEdgeEventFetcher; | |
16 | +@AllArgsConstructor | |
17 | +@Slf4j | |
18 | +public class TkConfigurationCenterEdgeEventFetcher extends BasePageableEdgeEventFetcher<TkConfigurationCenter> { | |
19 | + private TkConfigurationCenterRepository tkConfigurationCenterRepository; | |
20 | + @Override | |
21 | + protected PageData<TkConfigurationCenter> fetchPageData(TenantId tenantId, Edge edge, PageLink pageLink) { | |
22 | + return tkConfigurationCenterRepository.selectToEdge(tenantId,edge.getId(),pageLink); | |
23 | + } | |
24 | + | |
25 | + @Override | |
26 | + protected EdgeEvent constructEdgeEvent(TenantId tenantId, Edge edge, TkConfigurationCenter entity) { | |
27 | + return EdgeUtils.constructEdgeEvent(tenantId, edge.getId(), EdgeEventType.TK_CONFIGURATION_CENTER,EdgeEventActionType.UPDATED, entity.getId(), null); | |
28 | + } | |
29 | +} | ... | ... |
... | ... | @@ -43,7 +43,7 @@ public class TkConfigurationCenterRepository implements TkEdgeProcessorRepositor |
43 | 43 | } |
44 | 44 | |
45 | 45 | @Override |
46 | - public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
46 | + public PageData<TkConfigurationCenter> selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
47 | 47 | LambdaQueryWrapper<TkConfigurationCenterEntity> queryWrapper = Wrappers.lambdaQuery(); |
48 | 48 | queryWrapper.eq(TkConfigurationCenterEntity::getTenantId, tenantId.getId().toString()); |
49 | 49 | Page<TkConfigurationCenterEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | ... | ... |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.extern.slf4j.Slf4j; | |
5 | +import org.thingsboard.server.common.data.EdgeUtils; | |
6 | +import org.thingsboard.server.common.data.edge.Edge; | |
7 | +import org.thingsboard.server.common.data.edge.EdgeEvent; | |
8 | +import org.thingsboard.server.common.data.edge.EdgeEventActionType; | |
9 | +import org.thingsboard.server.common.data.edge.EdgeEventType; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.page.PageData; | |
12 | +import org.thingsboard.server.common.data.page.PageLink; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationCenter; | |
14 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
15 | +import org.thingsboard.server.service.edge.rpc.fetch.BasePageableEdgeEventFetcher; | |
16 | + | |
17 | +@AllArgsConstructor | |
18 | +@Slf4j | |
19 | +public class TkConfigurationContentEdgeEventFetcher extends BasePageableEdgeEventFetcher<TkConfigurationContent> { | |
20 | + TkConfigurationContentRepository TkConfigurationContentRepository; | |
21 | + @Override | |
22 | + protected PageData<TkConfigurationContent> fetchPageData(TenantId tenantId, Edge edge, PageLink pageLink) { | |
23 | + return TkConfigurationContentRepository.selectToEdge(tenantId,edge.getId(),pageLink); | |
24 | + } | |
25 | + | |
26 | + @Override | |
27 | + protected EdgeEvent constructEdgeEvent(TenantId tenantId, Edge edge, TkConfigurationContent entity) { | |
28 | + return EdgeUtils.constructEdgeEvent(tenantId, edge.getId(), EdgeEventType.TK_CONFIGURATION_CONTENT, EdgeEventActionType.UPDATED, entity.getId(), null); | |
29 | + } | |
30 | +} | ... | ... |
... | ... | @@ -39,7 +39,7 @@ public class TkConfigurationContentRepository implements TkEdgeProcessorReposito |
39 | 39 | } |
40 | 40 | |
41 | 41 | @Override |
42 | - public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
42 | + public PageData<TkConfigurationContent> selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
43 | 43 | LambdaQueryWrapper<TkConfigurationContentEntity> queryWrapper = Wrappers.lambdaQuery(); |
44 | 44 | queryWrapper.eq(TkConfigurationContentEntity::getTenantId, tenantId.getId().toString()); |
45 | 45 | Page<TkConfigurationContentEntity> queryPage = new Page<>(pageLink.getPage(), pageLink.getPageSize()); | ... | ... |
1 | +package org.thingsboard.server.service.edge.rpc.yunteng.tk_configuration_content_node; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.extern.slf4j.Slf4j; | |
5 | +import org.thingsboard.server.common.data.EdgeUtils; | |
6 | +import org.thingsboard.server.common.data.edge.Edge; | |
7 | +import org.thingsboard.server.common.data.edge.EdgeEvent; | |
8 | +import org.thingsboard.server.common.data.edge.EdgeEventActionType; | |
9 | +import org.thingsboard.server.common.data.edge.EdgeEventType; | |
10 | +import org.thingsboard.server.common.data.id.TenantId; | |
11 | +import org.thingsboard.server.common.data.page.PageData; | |
12 | +import org.thingsboard.server.common.data.page.PageLink; | |
13 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContent; | |
14 | +import org.thingsboard.server.common.data.yunteng.sync.TkConfigurationContentNode; | |
15 | +import org.thingsboard.server.service.edge.rpc.fetch.BasePageableEdgeEventFetcher; | |
16 | +@AllArgsConstructor | |
17 | +@Slf4j | |
18 | +public class TkConfigurationContentNodeEdgeEventFetcher extends BasePageableEdgeEventFetcher<TkConfigurationContentNode> { | |
19 | + TkConfigurationContentNodeRepository tkConfigurationContentNodeRepository; | |
20 | + @Override | |
21 | + protected PageData<TkConfigurationContentNode> fetchPageData(TenantId tenantId, Edge edge, PageLink pageLink) { | |
22 | + return tkConfigurationContentNodeRepository.selectToEdge(tenantId,edge.getId(),pageLink); | |
23 | + } | |
24 | + | |
25 | + @Override | |
26 | + protected EdgeEvent constructEdgeEvent(TenantId tenantId, Edge edge, TkConfigurationContentNode entity) { | |
27 | + return EdgeUtils.constructEdgeEvent(tenantId, edge.getId(), EdgeEventType.TK_CONFIGURATION_CONTENT_NODE, EdgeEventActionType.UPDATED, entity.getId(), null); | |
28 | + | |
29 | + } | |
30 | +} | ... | ... |
... | ... | @@ -39,7 +39,7 @@ public class TkConfigurationContentNodeRepository implements TkEdgeProcessorRepo |
39 | 39 | } |
40 | 40 | |
41 | 41 | @Override |
42 | - public PageData selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
42 | + public PageData<TkConfigurationContentNode> selectToEdge(TenantId tenantId, EdgeId edgeId, PageLink pageLink) { | |
43 | 43 | System.out.println(" 全量下行查询 TkConfigurationContentNode"); |
44 | 44 | |
45 | 45 | LambdaQueryWrapper<TkConfigurationContentNodeEntity> queryWrapper = Wrappers.lambdaQuery(); | ... | ... |
... | ... | @@ -754,9 +754,9 @@ spring: |
754 | 754 | datasource: |
755 | 755 | # Database driver for Spring JPA - org.postgresql.Driver |
756 | 756 | driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}" |
757 | - url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/postgres}" | |
757 | + url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://222.180.200.114:20638/z_tk_fatest_cloud_001}" | |
758 | 758 | username: "${SPRING_DATASOURCE_USERNAME:postgres}" |
759 | - password: "${SPRING_DATASOURCE_PASSWORD:postgres}" | |
759 | + password: "${SPRING_DATASOURCE_PASSWORD:Thw770!!uriq}" | |
760 | 760 | hikari: |
761 | 761 | # This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak. A value of 0 means leak detection is disabled |
762 | 762 | leakDetectionThreshold: "${SPRING_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLD:0}" | ... | ... |
... | ... | @@ -19,15 +19,24 @@ import java.io.Serializable; |
19 | 19 | @Getter |
20 | 20 | @Setter |
21 | 21 | @Accessors(chain = true) |
22 | -public class Tk3dComponentDTO extends TenantDTO implements Serializable { | |
22 | +public class Tk3dComponentDTO extends BaseDTO implements Serializable { | |
23 | 23 | |
24 | 24 | private static final long serialVersionUID = 1L; |
25 | 25 | |
26 | 26 | @ApiModelProperty("模板内容") |
27 | 27 | private JsonNode content; |
28 | 28 | |
29 | + @ApiModelProperty("名称") | |
30 | + String name; | |
31 | + | |
29 | 32 | @ApiModelProperty("是否发布:0否,1是") |
30 | 33 | Integer state; |
31 | 34 | |
35 | + @ApiModelProperty("图标地址") | |
36 | + String imageUrl; | |
37 | + | |
38 | + @ApiModelProperty(value = "租户ID") | |
39 | + private String tenantId; | |
40 | + | |
32 | 41 | |
33 | 42 | } | ... | ... |
... | ... | @@ -30,8 +30,11 @@ public class Tk3dComponentEntity extends TenantBaseEntity implements Serializabl |
30 | 30 | String name; |
31 | 31 | |
32 | 32 | @TableField |
33 | + String imageUrl; | |
34 | + | |
35 | + @TableField | |
33 | 36 | @ApiModelProperty("是否发布:0否,1是") |
34 | - Integer state; | |
37 | + Integer state=0; | |
35 | 38 | |
36 | 39 | @ApiModelProperty("模板内容") |
37 | 40 | @TableField(typeHandler = JacksonTypeHandler.class) | ... | ... |
... | ... | @@ -56,7 +56,9 @@ public class Tk3dComponentServiceImpl extends AbstractBaseService<Tk3dComponentM |
56 | 56 | .eq(Tk3dComponentEntity::getId, dto.getId()))) { |
57 | 57 | baseMapper.updateById(dto.getEntity(Tk3dComponentEntity.class)); |
58 | 58 | } else { |
59 | - baseMapper.insert(dto.getEntity(Tk3dComponentEntity.class)); | |
59 | + Tk3dComponentEntity entity=dto.getEntity(Tk3dComponentEntity.class); | |
60 | + entity.setState(0); | |
61 | + baseMapper.insert(entity); | |
60 | 62 | } |
61 | 63 | |
62 | 64 | return dto; | ... | ... |