Commit 2cfc8a451c95da19dff2db4bb966d9f24a038f76

Authored by lijianfa_14810364212
1 parent edadb2a7

fix:3d-component接口修改

1   ---组态内容节点,增加一个字段
2   -alter table tk_configuration_content_node add configuration_node_id varchar(32);
3   -COMMENT ON COLUMN "public"."tk_configuration_content_node"."configuration_node_id" IS '组态内容节点ID';
4   ---更新已存在的数据
5   -update tk_configuration_content_node set configuration_node_id = id;
6   ---更新组态内容节点表的主键ID为uuid
7   -CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
8   -update tk_configuration_content_node set id = uuid_generate_v4();
  1 +/*
  2 + Navicat Premium Data Transfer
9 3
10   ---添加3d组件的新表
  4 + Source Server : 222.180.200.114
  5 + Source Server Type : PostgreSQL
  6 + Source Server Version : 130006
  7 + Source Host : 222.180.200.114:20638
  8 + Source Catalog : z_tk_fatest_cloud_001
  9 + Source Schema : public
  10 +
  11 + Target Server Type : PostgreSQL
  12 + Target Server Version : 130006
  13 + File Encoding : 65001
  14 +
  15 + Date: 22/10/2024 15:51:17
  16 +*/
  17 +
  18 +
  19 +-- ----------------------------
  20 +-- Table structure for tk_3d_component
  21 +-- ----------------------------
  22 +DROP TABLE IF EXISTS "public"."tk_3d_component";
11 23 CREATE TABLE "public"."tk_3d_component" (
12 24 "id" varchar(36) COLLATE "pg_catalog"."default" NOT NULL,
13 25 "content" text COLLATE "pg_catalog"."default" NOT NULL,
... ... @@ -17,7 +29,8 @@ CREATE TABLE "public"."tk_3d_component" (
17 29 "create_time" timestamp(6),
18 30 "update_time" timestamp(6),
19 31 "name" varchar(128) COLLATE "pg_catalog"."default",
20   - "state" int2
  32 + "state" int2,
  33 + "image_url" varchar(255) COLLATE "pg_catalog"."default"
21 34 )
22 35 ;
23 36 COMMENT ON COLUMN "public"."tk_3d_component"."id" IS '主建';
... ... @@ -28,9 +41,10 @@ COMMENT ON COLUMN "public"."tk_3d_component"."tenant_id" IS '租户ID';
28 41 COMMENT ON COLUMN "public"."tk_3d_component"."create_time" IS '创建时间';
29 42 COMMENT ON COLUMN "public"."tk_3d_component"."update_time" IS '更新时间';
30 43 COMMENT ON COLUMN "public"."tk_3d_component"."name" IS '名称';
31   -COMMENT ON COLUMN "public"."tk_3d_component"."state" IS '状态:0未发布,1已发布';
  44 +COMMENT ON COLUMN "public"."tk_3d_component"."state" IS '状态:0创建,1发布';
  45 +COMMENT ON COLUMN "public"."tk_3d_component"."image_url" IS '图标';
32 46
33 47 -- ----------------------------
34 48 -- Primary Key structure for table tk_3d_component
35 49 -- ----------------------------
36   -ALTER TABLE "public"."tk_3d_component" ADD CONSTRAINT "tk_3d_component_pkey" PRIMARY KEY ("id");
\ No newline at end of file
  50 +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 }
... ...
... ... @@ -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;
... ...