diff --git a/src/main/database/add.sql b/src/main/database/add.sql index f0159cb..72883b8 100644 --- a/src/main/database/add.sql +++ b/src/main/database/add.sql @@ -41,4 +41,14 @@ CREATE TABLE `physical_server` ( `is_deleted` tinyint(1) DEFAULT NULL COMMENT '是否删除', `display_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '展示名称', PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +INSERT INTO cmp.system_config +(code, name, value, remark, category, subclass, `type`, config, gmt_create, gmt_modify, mender_id, creator_id) +VALUES('vncProtocol', '协议', 'ws', 'VNC控制台', '系统对接', 'VNC控制台', 'TEXT', '{}', NULL, '2024-08-01 08:50:28', 1, 1); +INSERT INTO cmp.system_config +(code, name, value, remark, category, subclass, `type`, config, gmt_create, gmt_modify, mender_id, creator_id) +VALUES('vncHost', '地址', '1.1.1.1', 'VNC访问IP', '系统对接', 'VNC控制台', 'TEXT', '{}', NULL, '2024-08-01 08:50:28', 1, 1); +INSERT INTO cmp.system_config +(code, name, value, remark, category, subclass, `type`, config, gmt_create, gmt_modify, mender_id, creator_id) +VALUES('vncPort', '端口', '1234', 'VNC访问端口', '系统对接', 'VNC控制台', 'TEXT', '{}', NULL, '2024-08-01 08:50:28', 1, 1); \ No newline at end of file diff --git a/src/main/java/com/bocloud/cmp/entity/SystemConfig.java b/src/main/java/com/bocloud/cmp/entity/SystemConfig.java new file mode 100644 index 0000000..7954810 --- /dev/null +++ b/src/main/java/com/bocloud/cmp/entity/SystemConfig.java @@ -0,0 +1,104 @@ +package com.bocloud.cmp.entity; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.megatron.common.utils.DateSerializer; +import com.megatron.entity.annotations.Column; +import com.megatron.entity.annotations.IgnoreUpdate; +import com.megatron.entity.annotations.PK; +import com.megatron.entity.annotations.Table; +import com.megatron.entity.bean.Generic; +import com.megatron.entity.meta.PKStrategy; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 系统设置的类 + * + * @author lyy + * @Version 1.0 + * @since 2017年8月18日 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@Table("system_config") +public class SystemConfig extends Generic { + + /** + * id + */ + @PK(value = PKStrategy.AUTO) + private Long id; + /** + * 配置编码 + */ + @Column("code") + private String code; + /** + * 配置名称 + */ + @Column("name") + private String name; + /** + * 配置值 + */ + @Column("value") + private String value; + /** + * 配置注释 + */ + @Column("remark") + private String remark; + /** + * 配置分类 + */ + @Column("category") + private String category; + + /** + * 配置子类 + */ + @Column("subclass") + private String subclass; + /** + * 配置类型(TEXT、SELECTICON、PASSWORD) + */ + @Column("type") + private String type; + /** + * 配置json串 + */ + @Column("config") + private String config; + /** + * 创建人id + */ + @Column("creator_id") + private Long creatorId; + /** + * 修改人Id + */ + @Column("mender_id") + private Long menderId; + /** + * 创建时间 + */ + @Column("gmt_create") + @IgnoreUpdate + @JsonSerialize(using = DateSerializer.class) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date gmtCreate; + /** + * 修改时间 + */ + @Column("gmt_modify") + @JsonSerialize(using = DateSerializer.class) + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date gmtModify; +} diff --git a/src/main/java/com/bocloud/cmp/internal/SmsSystemConfigService.java b/src/main/java/com/bocloud/cmp/internal/SmsSystemConfigService.java index 80f468a..d58dd92 100644 --- a/src/main/java/com/bocloud/cmp/internal/SmsSystemConfigService.java +++ b/src/main/java/com/bocloud/cmp/internal/SmsSystemConfigService.java @@ -1,14 +1,9 @@ package com.bocloud.cmp.internal; -import java.util.HashMap; -import java.util.Map; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - +import com.alibaba.fastjson.JSON; import com.bocloud.cmp.boot.model.BocloudToken; +import com.bocloud.cmp.entity.SystemConfig; import com.megatron.common.model.GeneralResult; import com.megatron.common.utils.Common; import com.megatron.common.utils.MapTools; @@ -17,6 +12,12 @@ import com.megatron.framework.core.Service; import com.megatron.framework.http.core.HttpMethod; import com.megatron.framework.http.core.ServiceFactory; import com.megatron.framework.http.model.RemoteService; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; /** * SOC系统配置内部访问 @@ -35,7 +36,7 @@ public class SmsSystemConfigService implements InitializingBean { private static Service service = Service.create("sms"); private Map headers = new HashMap<>(4); - public String getByCode(String code) { + /*public String getByCode(String code) { RemoteService remote = serviceFactory.build(service, "/v1/sysconfigs", HttpMethod.GET, headers, MapTools.simpleMap(Common.CODE, code)); GeneralResult result = remote.invoke(); @@ -43,6 +44,21 @@ public class SmsSystemConfigService implements InitializingBean { return null; } return String.valueOf(result.getData()); + }*/ + + public String getByCode(String code) { + RemoteService remote = serviceFactory.build(service, "/v1/configs/queryByCode", HttpMethod.GET, headers, + MapTools.simpleMap(Common.CODE, code)); + GeneralResult result = remote.invoke(); + + if (result.isSuccess()) { + Object data = result.getData(); + if (data != null) { + SystemConfig config = JSON.parseObject(JSON.toJSONString(data), SystemConfig.class); + return config.getValue(); + } + } + return null; } @Override