diff --git a/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.java b/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.java index 8d3b3de1d56bfc0235a8bead4a5b2496acc0e1f7..fa03437b38efcc29d96a673467c9360220c2a453 100644 --- a/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.java +++ b/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.java @@ -16,11 +16,26 @@ along with this program. If not, see .*/ package neatlogic.framework.dao.mapper; +import neatlogic.framework.dto.NotifyConfigVo; import org.apache.ibatis.annotations.Param; +import java.util.List; + public interface NotifyConfigMapper { + List getNotifyConfigListByType(String type); + + NotifyConfigVo getNotifyConfigById(Long id); + String getConfigByType(String type); int insertNotifyConfig(@Param("type") String type, @Param("config") String config); + + int insertNotifyConfigVo(NotifyConfigVo notifyConfigVo); + + int updateNotifyConfigIsActive(@Param("id") Long id, @Param("isActive") Integer isActive); + + int updateNotifyConfigIsDefault(@Param("id") Long id, @Param("isDefault") Integer isDefault); + + int deleteNotifyConfigById(Long id); } diff --git a/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.xml b/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.xml index 9b95989e9469bd35eae6ad8c2d77de74bf0b7ecf..3d66e272f91644442ab3de1eb891202c1bf38371 100644 --- a/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.xml +++ b/src/main/java/neatlogic/framework/dao/mapper/NotifyConfigMapper.xml @@ -17,8 +17,32 @@ along with this program. If not, see .--> + + + + @@ -27,4 +51,48 @@ along with this program. If not, see .--> ON DUPLICATE KEY UPDATE `config` = #{config} + + + INSERT INTO `notify_config` ( + `id`, + `name`, + `is_active`, + `is_default`, + `type`, + `config` + ) + VALUES + ( + #{id}, + #{name}, + #{isActive}, + #{isDefault}, + #{type}, + #{configStr, typeHandler=CompressHandler} + ) + ON DUPLICATE KEY UPDATE + `name` = #{name}, + `config` = #{configStr, typeHandler=CompressHandler} + + + + UPDATE `notify_config` + SET + `is_active` = #{isActive} + WHERE `id` = #{id} + + + + UPDATE `notify_config` + SET + + `is_active` = 1, + + `is_default` = #{isDefault} + WHERE `id` = #{id} + + + + DELETE FROM `notify_config` WHERE `id` = #{value} + diff --git a/src/main/java/neatlogic/framework/dto/MailServerVo.java b/src/main/java/neatlogic/framework/dto/MailServerVo.java index 5ad764a3ad4aa73142a839ca77932ee3e615b8d2..bd13ede001884d3ed810ce241375fabe3fd5f0b3 100644 --- a/src/main/java/neatlogic/framework/dto/MailServerVo.java +++ b/src/main/java/neatlogic/framework/dto/MailServerVo.java @@ -3,9 +3,6 @@ package neatlogic.framework.dto; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.restful.annotation.EntityField; -import org.apache.commons.lang3.StringUtils; - -import java.util.UUID; /** * @program: neatlogic @@ -16,8 +13,8 @@ public class MailServerVo extends BasePageVo { private static final long serialVersionUID = 6550790567158161414L; - @EntityField(name = "common.uuid", type = ApiParamType.STRING) - private String uuid; + @EntityField(name = "common.id", type = ApiParamType.LONG) + private Long id; @EntityField(name = "common.name", type = ApiParamType.STRING) private String name; @@ -42,16 +39,17 @@ public class MailServerVo extends BasePageVo { @EntityField(name = "common.homeurl", type = ApiParamType.STRING) private String homeUrl; + @EntityField(name = "common.isactive", type = ApiParamType.INTEGER) + private Integer isActive; + @EntityField(name = "common.isdefault", type = ApiParamType.INTEGER) + private Integer isDefault; - public String getUuid() { - if (StringUtils.isBlank(uuid)) { - uuid = UUID.randomUUID().toString().replace("-", ""); - } - return uuid; + public Long getId() { + return id; } - public void setUuid(String uuid) { - this.uuid = uuid; + public void setId(Long id) { + this.id = id; } public String getName() { @@ -117,4 +115,20 @@ public class MailServerVo extends BasePageVo { public void setHomeUrl(String homeUrl) { this.homeUrl = homeUrl; } + + public Integer getIsActive() { + return isActive; + } + + public void setIsActive(Integer isActive) { + this.isActive = isActive; + } + + public Integer getIsDefault() { + return isDefault; + } + + public void setIsDefault(Integer isDefault) { + this.isDefault = isDefault; + } } diff --git a/src/main/java/neatlogic/framework/dto/NotifyConfigVo.java b/src/main/java/neatlogic/framework/dto/NotifyConfigVo.java new file mode 100644 index 0000000000000000000000000000000000000000..2620022bb7e9ef88726f6c96b344f1183887a285 --- /dev/null +++ b/src/main/java/neatlogic/framework/dto/NotifyConfigVo.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2025 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.framework.dto; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.annotation.JSONField; + +public class NotifyConfigVo { + private Long id; + private String name; + private Integer isActive; + private Integer isDefault; + private String type; + private JSONObject config; + @JSONField(serialize = false) + private String configStr; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getIsActive() { + return isActive; + } + + public void setIsActive(Integer isActive) { + this.isActive = isActive; + } + + public Integer getIsDefault() { + return isDefault; + } + + public void setIsDefault(Integer isDefault) { + this.isDefault = isDefault; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public JSONObject getConfig() { + if (config == null && configStr != null) { + config = JSON.parseObject(configStr); + } + return config; + } + + public void setConfig(JSONObject config) { + this.config = config; + } + + public String getConfigStr() { + if (configStr == null && config != null) { + configStr = config.toJSONString(); + } + return configStr; + } + + public void setConfigStr(String configStr) { + this.configStr = configStr; + } +} diff --git a/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/neatlogic_tenant.sql b/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/neatlogic_tenant.sql new file mode 100644 index 0000000000000000000000000000000000000000..f65fe49cd337087c4c7e730afeb4a8c060af2610 --- /dev/null +++ b/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/neatlogic_tenant.sql @@ -0,0 +1,12 @@ +ALTER TABLE `notify_config` + ADD COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID' FIRST, + ADD COLUMN `name` VARCHAR (250) NULL COMMENT '名称' AFTER `id`, + ADD COLUMN `is_active` TINYINT (1) DEFAULT 1 NOT NULL COMMENT '是否激活' AFTER `name`, + ADD COLUMN `is_default` TINYINT (1) DEFAULT 1 NOT NULL COMMENT '是否是默认配置' AFTER `is_active`, + DROP PRIMARY KEY, + ADD PRIMARY KEY (`id`); + +ALTER TABLE `notify_config` + CHANGE `id` `id` BIGINT NOT NULL COMMENT '主键ID', + CHANGE `is_active` `is_active` TINYINT (1) DEFAULT 0 NOT NULL COMMENT '是否激活', + CHANGE `is_default` `is_default` TINYINT (1) DEFAULT 0 NOT NULL COMMENT '是否是默认配置'; \ No newline at end of file diff --git a/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/version.json b/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/version.json new file mode 100644 index 0000000000000000000000000000000000000000..6152c80d2497743439e9a13de5bf4d17fd6a5e60 --- /dev/null +++ b/src/main/resources/neatlogic/resources/framework/changelog/2025-04-14/version.json @@ -0,0 +1,12 @@ +{ + "content": [ + { + "type": "功能添加", + "detail": [ + { + "msg": "1.支持配置多个邮件服务器" + } + ] + } + ] +} diff --git a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql index 201c871fc9939c98a111580c2da713f7fb6aa15e..8987dc4f70e658a2e938c36893bf1746636e87b3 100644 --- a/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql +++ b/src/main/resources/neatlogic/resources/framework/sqlscript/ddl.sql @@ -947,14 +947,15 @@ CREATE TABLE `mq_topic` -- ---------------------------- -- Table structure for notify_config -- ---------------------------- -CREATE TABLE IF NOT EXISTS `notify_config` -( - `type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通知类型', - `config` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置', - PRIMARY KEY (`type`) USING BTREE -) ENGINE = InnoDB - CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT = '通知配置表'; +CREATE TABLE `notify_config` ( + `id` bigint NOT NULL COMMENT '主键ID', + `name` varchar(250) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '名称', + `is_active` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否激活', + `is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是默认配置', + `type` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '通知类型', + `config` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '配置', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='通知配置表'; -- ---------------------------- -- Table structure for notify_job