Showing
15 changed files
with
376 additions
and
60 deletions
... | ... | @@ -429,12 +429,12 @@ COMMENT ON COLUMN qg_db_connect.connect_timeout IS '最大ç‰å¾…æ—¶é—´(毫秒)ï¼ |
429 | 429 | CREATE TABLE "qg_db_connect_ssh" ( |
430 | 430 | "id" varchar(36) PRIMARY KEY, |
431 | 431 | "connect_id" varchar(36) NOT NULL, |
432 | - "ip" varchar(20) NOT NULL, | |
433 | - "port" varchar(20) NOT NULL, | |
434 | - "ssh_name" varchar(50) NOT NULL, | |
435 | - "ssh_password" varchar(50) NOT NULL, | |
436 | - "verify_method" varchar(200) NOT NULL, | |
437 | - "private_key" varchar(200) NOT NULL, | |
432 | + "ip" varchar(20), | |
433 | + "port" varchar(20), | |
434 | + "ssh_name" varchar(50), | |
435 | + "ssh_password" varchar(50), | |
436 | + "verify_method" varchar(200), | |
437 | + "private_key" varchar(200), | |
438 | 438 | "tenant_id" varchar(36), |
439 | 439 | "create_time" timestamp(6), |
440 | 440 | "creator" varchar(36) NULL, |
... | ... | @@ -447,44 +447,17 @@ COMMENT ON COLUMN qg_db_connect.connect_id IS 'æ•°æ®åº“链接信æ¯id'; |
447 | 447 | COMMENT ON COLUMN qg_db_connect_ssh.ip IS 'ssh的ip'; |
448 | 448 | COMMENT ON COLUMN qg_db_connect_ssh.port IS 'ssh的port'; |
449 | 449 | COMMENT ON COLUMN qg_db_connect_ssh.ssh_name IS '用户名'; |
450 | -COMMENT ON COLUMN qg_db_connect_ssh.ssh_password IS '租户ID'; | |
451 | 450 | COMMENT ON COLUMN qg_db_connect_ssh.ssh_password IS '密码/密码短语'; |
452 | -COMMENT ON COLUMN qg_db_connect_ssh.verify_method IS '验证方式(PASSWORD:密码;PUBLIC_KEY)'; | |
451 | +COMMENT ON COLUMN qg_db_connect_ssh.verify_method IS '验证方式(PASSWORD:密码;PUBLIC_KEY:公钥)'; | |
453 | 452 | COMMENT ON COLUMN qg_db_connect_ssh.private_key IS '私钥文件'; |
454 | 453 | |
455 | 454 | CREATE TABLE "qg_db_connect_ssl" ( |
456 | - "id" varchar(36) PRIMARY KEY, | |
457 | - "connect_id" varchar(36) NOT NULL, | |
458 | - "ip" varchar(20) NOT NULL, | |
459 | - "port" varchar(20) NOT NULL, | |
460 | - "ssh_name" varchar(50) NOT NULL, | |
461 | - "ssh_password" varchar(50) NOT NULL, | |
462 | - "verify_method" varchar(200) NOT NULL, | |
463 | - "private_key" varchar(200) NOT NULL, | |
464 | - "tenant_id" varchar(36), | |
465 | - "create_time" timestamp(6), | |
466 | - "creator" varchar(36) NULL, | |
467 | - "updater" varchar(36) NULL, | |
468 | - "update_time" timestamp(6) | |
469 | -); | |
470 | -COMMENT ON TABLE qg_db_connect IS 'SSH通道配置信息'; | |
471 | -COMMENT ON COLUMN qg_db_connect.tenant_id IS '租户ID'; | |
472 | -COMMENT ON COLUMN qg_db_connect.connect_id IS '数据库链接信息id'; | |
473 | -COMMENT ON COLUMN qg_db_connect.ip IS 'ssh的ip'; | |
474 | -COMMENT ON COLUMN qg_db_connect.port IS 'ssh的port'; | |
475 | -COMMENT ON COLUMN qg_db_connect.ssh_name IS '用户名'; | |
476 | -COMMENT ON COLUMN qg_db_connect.ssh_password IS '租户ID'; | |
477 | -COMMENT ON COLUMN qg_db_connect.ssh_password IS '密码/密码短语'; | |
478 | -COMMENT ON COLUMN qg_db_connect.verify_method IS '验证方式(PASSWORD:密码;PUBLIC_KEY)'; | |
479 | -COMMENT ON COLUMN qg_db_connect.private_key IS '私钥文件'; | |
480 | - | |
481 | -CREATE TABLE "qg_db_connect_ssl" ( | |
482 | 455 | "id" varchar(36) PRIMARY KEY, |
483 | 456 | "connect_id" varchar(36) NOT NULL, |
484 | - "ca_cert" varchar(50) NOT NULL, | |
457 | + "ca_cert" varchar(50), | |
485 | 458 | "verify_ca_cert" bool NOT NULL DEFAULT FALSE, |
486 | - "client_key" varchar(50) NOT NULL, | |
487 | - "client_cert" varchar(50) NOT NULL, | |
459 | + "client_key" varchar(50), | |
460 | + "client_cert" varchar(50), | |
488 | 461 | "tenant_id" varchar(36), |
489 | 462 | "create_time" timestamp(6), |
490 | 463 | "creator" varchar(36) NULL, | ... | ... |
... | ... | @@ -1161,12 +1161,12 @@ CREATE TABLE IF NOT EXISTS qg_db_connect ( |
1161 | 1161 | CREATE TABLE IF NOT EXISTS qg_db_connect_ssl ( |
1162 | 1162 | "id" varchar(36) PRIMARY KEY, |
1163 | 1163 | "connect_id" varchar(36) NOT NULL, |
1164 | - "ip" varchar(20) NOT NULL, | |
1165 | - "port" varchar(20) NOT NULL, | |
1166 | - "ssh_name" varchar(50) NOT NULL, | |
1167 | - "ssh_password" varchar(50) NOT NULL, | |
1168 | - "verify_method" varchar(200) NOT NULL, | |
1169 | - "private_key" varchar(200) NOT NULL, | |
1164 | + "ip" varchar(20), | |
1165 | + "port" varchar(20), | |
1166 | + "ssh_name" varchar(50), | |
1167 | + "ssh_password" varchar(50), | |
1168 | + "verify_method" varchar(200), | |
1169 | + "private_key" varchar(200), | |
1170 | 1170 | "tenant_id" varchar(36), |
1171 | 1171 | "create_time" timestamp(6), |
1172 | 1172 | "creator" varchar(36) NULL, |
... | ... | @@ -1176,11 +1176,11 @@ CREATE TABLE IF NOT EXISTS qg_db_connect_ssl ( |
1176 | 1176 | |
1177 | 1177 | CREATE TABLE IF NOT EXISTS qg_db_connect_ssl ( |
1178 | 1178 | "id" varchar(36) PRIMARY KEY, |
1179 | - "connect_id" varchar(36) NOT NULL, | |
1180 | - "ca_cert" varchar(50) NOT NULL, | |
1179 | + "connect_id" varchar(36, | |
1180 | + "ca_cert" varchar(50), | |
1181 | 1181 | "verify_ca_cert" bool NOT NULL DEFAULT FALSE, |
1182 | - "client_key" varchar(50) NOT NULL, | |
1183 | - "client_cert" varchar(50) NOT NULL, | |
1182 | + "client_key" varchar(50), | |
1183 | + "client_cert" varchar(50), | |
1184 | 1184 | "tenant_id" varchar(36), |
1185 | 1185 | "create_time" timestamp(6), |
1186 | 1186 | "creator" varchar(36) NULL, | ... | ... |
... | ... | @@ -53,4 +53,10 @@ public class TkDbConnectDTO extends TenantDTO { |
53 | 53 | |
54 | 54 | @ApiModelProperty("最大等待时间(毫秒)") |
55 | 55 | private int connectTimeout; |
56 | + | |
57 | + @ApiModelProperty("SSH通道配置信息") | |
58 | + private TkDbConnectSshDTO ssh; | |
59 | + | |
60 | + @ApiModelProperty("SSL通道配置信息") | |
61 | + private TkDbConnectSslDTO ssl; | |
56 | 62 | } | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkDbConnectSshDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | |
2 | + | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | +import lombok.Data; | |
5 | +import lombok.EqualsAndHashCode; | |
6 | + | |
7 | +/** | |
8 | + * SSH通道配置信息 | |
9 | + */ | |
10 | +@EqualsAndHashCode(callSuper = true) | |
11 | +@Data | |
12 | +public class TkDbConnectSshDTO extends TenantDTO { | |
13 | + | |
14 | + @ApiModelProperty("数据库链接信息id") | |
15 | + private String connectId; | |
16 | + | |
17 | + @ApiModelProperty("ssh的ip") | |
18 | + private String ip; | |
19 | + | |
20 | + @ApiModelProperty("ssh的port") | |
21 | + private String port; | |
22 | + | |
23 | + @ApiModelProperty("用户名") | |
24 | + private String sshName; | |
25 | + | |
26 | + @ApiModelProperty("ssh的ip") | |
27 | + private String sshPassword; | |
28 | + | |
29 | + @ApiModelProperty("验证方式(PASSWORD:密码;PUBLIC_KEY:公钥)") | |
30 | + private String verifyMethod; | |
31 | + | |
32 | + @ApiModelProperty("私钥文件") | |
33 | + private String privateKey; | |
34 | +} | ... | ... |
common/data/src/main/java/org/thingsboard/server/common/data/yunteng/dto/TkDbConnectSslDTO.java
0 → 100644
1 | +package org.thingsboard.server.common.data.yunteng.dto; | |
2 | + | |
3 | +import io.swagger.annotations.ApiModelProperty; | |
4 | +import lombok.Data; | |
5 | +import lombok.EqualsAndHashCode; | |
6 | + | |
7 | +/** | |
8 | + * SSL通道配置信息 | |
9 | + */ | |
10 | +@EqualsAndHashCode(callSuper = true) | |
11 | +@Data | |
12 | +public class TkDbConnectSslDTO extends TenantDTO { | |
13 | + | |
14 | + @ApiModelProperty("数据库链接信息id") | |
15 | + private String connectId; | |
16 | + | |
17 | + @ApiModelProperty("CA证书") | |
18 | + private String caCert; | |
19 | + | |
20 | + @ApiModelProperty("验证CA证书") | |
21 | + private boolean verifyCaCert; | |
22 | + | |
23 | + @ApiModelProperty("客户端秘钥") | |
24 | + private String clientKey; | |
25 | + | |
26 | + @ApiModelProperty("客户端证书") | |
27 | + private String clientCert; | |
28 | +} | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2024 The Thingsboard Authors |
3 | - * | |
3 | + * <p> | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
7 | + * <p> | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * <p> | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | 13 | * See the License for the specific language governing permissions and |
14 | 14 | * limitations under the License. |
15 | + * <p> | |
16 | + * This file has been modified from its original version. | |
17 | + * Source: ThingsBoard Community Edition | |
18 | + * Modifications made by: Chengdu Yunteng Wuzhou Technology Co., Ltd | |
19 | + * Modification date: 2022-05-17 | |
20 | + * Description of changes: extend constant for table. | |
15 | 21 | */ |
16 | 22 | /** |
17 | 23 | * This file has been modified from its original version. |
... | ... | @@ -45,7 +51,7 @@ public class ModelConstants { |
45 | 51 | */ |
46 | 52 | public static final String ID_PROPERTY = "id"; |
47 | 53 | public static final String CREATED_TIME_PROPERTY = "created_time"; |
48 | - //thingskit | |
54 | + //thingskit | |
49 | 55 | public static final String STATUS_PROPERTY = "status"; |
50 | 56 | public static final String USER_ID_PROPERTY = "user_id"; |
51 | 57 | public static final String TENANT_ID_PROPERTY = "tenant_id"; |
... | ... | @@ -71,7 +77,7 @@ public class ModelConstants { |
71 | 77 | public static final String EVENT_TIME_COLUMN = "event_time"; |
72 | 78 | public static final String EVENT_TYPE_COLUMN = "event_type"; |
73 | 79 | public static final String EVENT_VALUE_COLUMN = "event_value"; |
74 | - public static final String DATA_COMBINATION_IS_DEFAULT_PROPERTY= "is_data_combination"; | |
80 | + public static final String DATA_COMBINATION_IS_DEFAULT_PROPERTY = "is_data_combination"; | |
75 | 81 | |
76 | 82 | /** |
77 | 83 | * User constants. |
... | ... | @@ -689,13 +695,15 @@ public class ModelConstants { |
689 | 695 | public static final String TKINSTALLLOCATION_TABLE_NAME = "qg_install_location";//设备台账 |
690 | 696 | public static final String TKSUPPLIER_TABLE_NAME = "qg_supplier";//供应商 |
691 | 697 | |
692 | - public static final String TKINSPECTIONPLAN_TABLE_NAME= "qg_inspection_plan"; // 巡检计划 | |
693 | - public static final String TKCHECKPLAN_TABLE_NAME= "qg_check_plan"; // 巡检/保养方案 | |
694 | - public static final String TKCHECKDETAILS_TABLE_NAME= "qg_check_details"; // 巡检明细 | |
695 | - public static final String TKINSPECTIONRECORD_TABLE_NAME= "qg_inspection_record"; // 巡检记录 | |
696 | - public static final String TKINSPECTIONDETAILS_TABLE_NAME= "qg_inspection_details"; // 巡检记录明细 | |
698 | + public static final String TKINSPECTIONPLAN_TABLE_NAME = "qg_inspection_plan"; // 巡检计划 | |
699 | + public static final String TKCHECKPLAN_TABLE_NAME = "qg_check_plan"; // 巡检/保养方案 | |
700 | + public static final String TKCHECKDETAILS_TABLE_NAME = "qg_check_details"; // 巡检明细 | |
701 | + public static final String TKINSPECTIONRECORD_TABLE_NAME = "qg_inspection_record"; // 巡检记录 | |
702 | + public static final String TKINSPECTIONDETAILS_TABLE_NAME = "qg_inspection_details"; // 巡检记录明细 | |
697 | 703 | |
698 | - public static final String TKDBCONNECT_TABLE_NAME= "qg_db_connect"; // 数据库链接信息 | |
704 | + public static final String TKDBCONNECT_TABLE_NAME = "qg_db_connect"; // 数据库链接信息 | |
705 | + public static final String TKDBCONNECTSSH_TABLE_NAME = "qg_db_connect_ssh"; // SSH通道配置信息 | |
706 | + public static final String TKDBCONNECTSSL_TABLE_NAME = "qg_db_connect_ssl"; // SSL通道配置信息 | |
699 | 707 | |
700 | 708 | protected static final String[] NONE_AGGREGATION_COLUMNS = new String[]{LONG_VALUE_COLUMN, DOUBLE_VALUE_COLUMN, BOOLEAN_VALUE_COLUMN, STRING_VALUE_COLUMN, JSON_VALUE_COLUMN, KEY_COLUMN, TS_COLUMN}; |
701 | 709 | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.entities; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
4 | +import lombok.Data; | |
5 | +import lombok.EqualsAndHashCode; | |
6 | +import org.thingsboard.server.dao.model.ModelConstants; | |
7 | + | |
8 | +/** | |
9 | + * SSH通道配置信息 | |
10 | + */ | |
11 | +@Data | |
12 | +@EqualsAndHashCode(callSuper = true) | |
13 | +@TableName(value = ModelConstants.TKDBCONNECTSSH_TABLE_NAME, autoResultMap = true) | |
14 | +public class TkDbConnectSshEntity extends TenantBaseEntity { | |
15 | + | |
16 | + private String connectId; | |
17 | + | |
18 | + private String ip; | |
19 | + | |
20 | + private String port; | |
21 | + | |
22 | + private String sshName; | |
23 | + | |
24 | + private String sshPassword; | |
25 | + | |
26 | + private String verifyMethod; | |
27 | + | |
28 | + private String privateKey; | |
29 | + | |
30 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.entities; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.annotation.TableName; | |
4 | +import io.swagger.annotations.ApiModelProperty; | |
5 | +import lombok.Data; | |
6 | +import lombok.EqualsAndHashCode; | |
7 | +import org.thingsboard.server.dao.model.ModelConstants; | |
8 | + | |
9 | +/** | |
10 | + * SSL通道配置信息 | |
11 | + */ | |
12 | +@Data | |
13 | +@EqualsAndHashCode(callSuper = true) | |
14 | +@TableName(value = ModelConstants.TKDBCONNECTSSL_TABLE_NAME, autoResultMap = true) | |
15 | +public class TkDbConnectSslEntity extends TenantBaseEntity { | |
16 | + | |
17 | + private String connectId; | |
18 | + | |
19 | + private String ip; | |
20 | + | |
21 | + private String port; | |
22 | + | |
23 | + private String sshName; | |
24 | + | |
25 | + private String sshPassword; | |
26 | + | |
27 | + private String verifyMethod; | |
28 | + | |
29 | + private String privateKey; | |
30 | + | |
31 | +} | ... | ... |
... | ... | @@ -9,11 +9,15 @@ import org.apache.commons.lang3.StringUtils; |
9 | 9 | import org.springframework.stereotype.Service; |
10 | 10 | import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; |
11 | 11 | import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectDTO; |
12 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSshDTO; | |
13 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSslDTO; | |
12 | 14 | import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; |
13 | 15 | import org.thingsboard.server.dao.yunteng.entities.TkDbConnectEntity; |
14 | 16 | import org.thingsboard.server.dao.yunteng.mapper.TkDbConnectMapper; |
15 | 17 | import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; |
16 | 18 | import org.thingsboard.server.dao.yunteng.service.TkDbConnectService; |
19 | +import org.thingsboard.server.dao.yunteng.service.TkDbConnectSshService; | |
20 | +import org.thingsboard.server.dao.yunteng.service.TkDbConnectSslService; | |
17 | 21 | |
18 | 22 | import java.util.Map; |
19 | 23 | |
... | ... | @@ -22,6 +26,8 @@ import java.util.Map; |
22 | 26 | @Slf4j |
23 | 27 | public class TkDbConnectServiceImpl extends AbstractBaseService<TkDbConnectMapper, TkDbConnectEntity> |
24 | 28 | implements TkDbConnectService { |
29 | + private final TkDbConnectSshService tkDbConnectSshService; | |
30 | + private final TkDbConnectSslService tkDbConnectSslService; | |
25 | 31 | |
26 | 32 | @Override |
27 | 33 | public TkPageData<TkDbConnectDTO> page(Map<String, Object> queryMap, String tenantId) { |
... | ... | @@ -55,7 +61,15 @@ public class TkDbConnectServiceImpl extends AbstractBaseService<TkDbConnectMappe |
55 | 61 | entity = tkDbConnectDTO.getEntity(TkDbConnectEntity.class); |
56 | 62 | baseMapper.update(entity, filter); |
57 | 63 | } |
58 | - | |
64 | + String connectId = entity.getId(); | |
65 | + TkDbConnectSshDTO ssh = tkDbConnectDTO.getSsh(); | |
66 | + ssh.setConnectId(connectId); | |
67 | + ssh.setTenantId(tkDbConnectDTO.getTenantId()); | |
68 | + tkDbConnectSshService.save(ssh); | |
69 | + TkDbConnectSslDTO ssl = tkDbConnectDTO.getSsl(); | |
70 | + ssl.setConnectId(connectId); | |
71 | + ssl.setTenantId(tkDbConnectDTO.getTenantId()); | |
72 | + tkDbConnectSslService.save(ssl); | |
59 | 73 | entity.copyToDTO(tkDbConnectDTO); |
60 | 74 | return tkDbConnectDTO; |
61 | 75 | } |
... | ... | @@ -68,6 +82,8 @@ public class TkDbConnectServiceImpl extends AbstractBaseService<TkDbConnectMappe |
68 | 82 | |
69 | 83 | @Override |
70 | 84 | public boolean delete(String id) { |
85 | + tkDbConnectSshService.deleteByConnectId(id); | |
86 | + tkDbConnectSslService.deleteByConnectId(id); | |
71 | 87 | int count = baseMapper.deleteById(id); |
72 | 88 | return count > 0; |
73 | 89 | } |
... | ... | @@ -81,6 +97,11 @@ public class TkDbConnectServiceImpl extends AbstractBaseService<TkDbConnectMappe |
81 | 97 | TkDbConnectEntity entity = baseMapper.selectById(id); |
82 | 98 | TkDbConnectDTO tkDbConnectDTO = new TkDbConnectDTO(); |
83 | 99 | entity.copyToDTO(tkDbConnectDTO); |
100 | + | |
101 | + TkDbConnectSshDTO ssh = tkDbConnectSshService.getByConnectId(id); | |
102 | + TkDbConnectSslDTO ssl = tkDbConnectSslService.getByConnectId(id); | |
103 | + tkDbConnectDTO.setSsh(ssh); | |
104 | + tkDbConnectDTO.setSsl(ssl); | |
84 | 105 | return tkDbConnectDTO; |
85 | 106 | } |
86 | 107 | } | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import lombok.extern.slf4j.Slf4j; | |
7 | +import org.apache.commons.lang3.StringUtils; | |
8 | +import org.springframework.stereotype.Service; | |
9 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | |
10 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSshDTO; | |
11 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSshEntity; | |
12 | +import org.thingsboard.server.dao.yunteng.mapper.TkDbConnectSshMapper; | |
13 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | |
14 | +import org.thingsboard.server.dao.yunteng.service.TkDbConnectSshService; | |
15 | + | |
16 | +@Service | |
17 | +@RequiredArgsConstructor | |
18 | +@Slf4j | |
19 | +public class TkDbConnectSshServiceImpl extends AbstractBaseService<TkDbConnectSshMapper, TkDbConnectSshEntity> | |
20 | + implements TkDbConnectSshService { | |
21 | + | |
22 | + @Override | |
23 | + public TkDbConnectSshDTO save(TkDbConnectSshDTO tkDbConnectSshDTO) { | |
24 | + checkDto(tkDbConnectSshDTO); | |
25 | + TkDbConnectSshEntity entity = new TkDbConnectSshEntity(); | |
26 | + if (StringUtils.isBlank(tkDbConnectSshDTO.getId())) { | |
27 | + tkDbConnectSshDTO.copyToEntity(entity); | |
28 | + baseMapper.insert(entity); | |
29 | + } else { | |
30 | + LambdaQueryWrapper<TkDbConnectSshEntity> filter = new QueryWrapper<TkDbConnectSshEntity>().lambda() | |
31 | + .eq(TkDbConnectSshEntity::getId, tkDbConnectSshDTO.getId()); | |
32 | + entity = tkDbConnectSshDTO.getEntity(TkDbConnectSshEntity.class); | |
33 | + baseMapper.update(entity, filter); | |
34 | + } | |
35 | + | |
36 | + entity.copyToDTO(tkDbConnectSshDTO); | |
37 | + return tkDbConnectSshDTO; | |
38 | + } | |
39 | + | |
40 | + @Override | |
41 | + public void deleteByConnectId(String connectId) { | |
42 | + if (StringUtils.isBlank(connectId)) { | |
43 | + return; | |
44 | + } | |
45 | + | |
46 | + baseMapper.delete(new LambdaQueryWrapper<TkDbConnectSshEntity>().eq(TkDbConnectSshEntity::getConnectId, connectId)); | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + public TkDbConnectSshDTO getByConnectId(String connectId) { | |
51 | + if (StringUtils.isBlank(connectId)) { | |
52 | + return new TkDbConnectSshDTO(); | |
53 | + } | |
54 | + | |
55 | + TkDbConnectSshEntity entity = baseMapper.selectOne(new LambdaQueryWrapper<TkDbConnectSshEntity>().eq(TkDbConnectSshEntity::getConnectId, connectId)); | |
56 | + if (entity == null) { | |
57 | + return new TkDbConnectSshDTO(); | |
58 | + } | |
59 | + | |
60 | + TkDbConnectSshDTO dto = new TkDbConnectSshDTO(); | |
61 | + entity.copyToDTO(dto); | |
62 | + return dto; | |
63 | + } | |
64 | + | |
65 | + private void checkDto(TkDbConnectSshDTO dto) { | |
66 | + if (StringUtils.isBlank(dto.getTenantId())) { | |
67 | + throw new TkDataValidationException("租户id为空!"); | |
68 | + } | |
69 | + } | |
70 | + | |
71 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.impl; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
5 | +import lombok.RequiredArgsConstructor; | |
6 | +import lombok.extern.slf4j.Slf4j; | |
7 | +import org.apache.commons.lang3.StringUtils; | |
8 | +import org.springframework.stereotype.Service; | |
9 | +import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException; | |
10 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSslDTO; | |
11 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSslEntity; | |
12 | +import org.thingsboard.server.dao.yunteng.mapper.TkDbConnectSslMapper; | |
13 | +import org.thingsboard.server.dao.yunteng.service.AbstractBaseService; | |
14 | +import org.thingsboard.server.dao.yunteng.service.TkDbConnectSslService; | |
15 | + | |
16 | +@Service | |
17 | +@RequiredArgsConstructor | |
18 | +@Slf4j | |
19 | +public class TkDbConnectSslServiceImpl extends AbstractBaseService<TkDbConnectSslMapper, TkDbConnectSslEntity> | |
20 | + implements TkDbConnectSslService { | |
21 | + | |
22 | + @Override | |
23 | + public TkDbConnectSslDTO save(TkDbConnectSslDTO tkDbConnectSslDTO) { | |
24 | + checkDto(tkDbConnectSslDTO); | |
25 | + TkDbConnectSslEntity entity = new TkDbConnectSslEntity(); | |
26 | + if (StringUtils.isBlank(tkDbConnectSslDTO.getId())) { | |
27 | + tkDbConnectSslDTO.copyToEntity(entity); | |
28 | + baseMapper.insert(entity); | |
29 | + } else { | |
30 | + LambdaQueryWrapper<TkDbConnectSslEntity> filter = new QueryWrapper<TkDbConnectSslEntity>().lambda() | |
31 | + .eq(TkDbConnectSslEntity::getId, tkDbConnectSslDTO.getId()); | |
32 | + entity = tkDbConnectSslDTO.getEntity(TkDbConnectSslEntity.class); | |
33 | + baseMapper.update(entity, filter); | |
34 | + } | |
35 | + | |
36 | + entity.copyToDTO(tkDbConnectSslDTO); | |
37 | + return tkDbConnectSslDTO; | |
38 | + } | |
39 | + | |
40 | + @Override | |
41 | + public void deleteByConnectId(String connectId) { | |
42 | + if (StringUtils.isBlank(connectId)) { | |
43 | + return; | |
44 | + } | |
45 | + | |
46 | + baseMapper.delete(new LambdaQueryWrapper<TkDbConnectSslEntity>().eq(TkDbConnectSslEntity::getConnectId, connectId)); | |
47 | + } | |
48 | + | |
49 | + @Override | |
50 | + public TkDbConnectSslDTO getByConnectId(String connectId) { | |
51 | + if (StringUtils.isBlank(connectId)) { | |
52 | + return new TkDbConnectSslDTO(); | |
53 | + } | |
54 | + | |
55 | + TkDbConnectSslEntity entity = baseMapper.selectOne(new LambdaQueryWrapper<TkDbConnectSslEntity>().eq(TkDbConnectSslEntity::getConnectId, connectId)); | |
56 | + if (entity == null) { | |
57 | + return new TkDbConnectSslDTO(); | |
58 | + } | |
59 | + | |
60 | + TkDbConnectSslDTO dto = new TkDbConnectSslDTO(); | |
61 | + entity.copyToDTO(dto); | |
62 | + return dto; | |
63 | + } | |
64 | + | |
65 | + private void checkDto(TkDbConnectSslDTO dto) { | |
66 | + if (StringUtils.isBlank(dto.getTenantId())) { | |
67 | + throw new TkDataValidationException("租户id为空!"); | |
68 | + } | |
69 | + } | |
70 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.mapper; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
4 | +import org.apache.ibatis.annotations.Mapper; | |
5 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSshEntity; | |
6 | + | |
7 | +@Mapper | |
8 | +public interface TkDbConnectSshMapper extends BaseMapper<TkDbConnectSshEntity> { | |
9 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.mapper; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |
4 | +import org.apache.ibatis.annotations.Mapper; | |
5 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSslEntity; | |
6 | + | |
7 | +@Mapper | |
8 | +public interface TkDbConnectSslMapper extends BaseMapper<TkDbConnectSslEntity> { | |
9 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.service; | |
2 | + | |
3 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSshDTO; | |
4 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSshEntity; | |
5 | + | |
6 | +public interface TkDbConnectSshService extends BaseService<TkDbConnectSshEntity> { | |
7 | + | |
8 | + TkDbConnectSshDTO save(TkDbConnectSshDTO tkDbConnectSshDTO); | |
9 | + | |
10 | + void deleteByConnectId(String connectId); | |
11 | + | |
12 | + TkDbConnectSshDTO getByConnectId(String connectId); | |
13 | +} | ... | ... |
1 | +package org.thingsboard.server.dao.yunteng.service; | |
2 | + | |
3 | +import org.thingsboard.server.common.data.yunteng.dto.TkDbConnectSslDTO; | |
4 | +import org.thingsboard.server.dao.yunteng.entities.TkDbConnectSslEntity; | |
5 | + | |
6 | +public interface TkDbConnectSslService extends BaseService<TkDbConnectSslEntity> { | |
7 | + | |
8 | + TkDbConnectSslDTO save(TkDbConnectSslDTO tkDbConnectSslDTO); | |
9 | + | |
10 | + void deleteByConnectId(String connectId); | |
11 | + | |
12 | + TkDbConnectSslDTO getByConnectId(String connectId); | |
13 | +} | ... | ... |