From c9b4bbe22b2588abe2565df03f5c6c7409c1741b Mon Sep 17 00:00:00 2001 From: 3y Date: Mon, 1 Aug 2022 19:55:41 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E6=B8=A0=E9=81=93?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E4=BF=A1=E6=81=AF=E8=A1=A8=E5=92=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=202=E3=80=81=E5=A2=9E=E5=8A=A0Dockerfile=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../austin/support/dao/ChannelAccountDao.java | 37 +++++++++++ .../austin/support/domain/ChannelAccount.java | 61 +++++++++++++++++++ .../controller/ChannelAccountController.java | 51 ++++++++++++++++ .../web/service/ChannelAccountService.java | 34 +++++++++++ .../impl/ChannelAccountServiceImpl.java | 35 +++++++++++ docker/Dockerfile | 17 ++++++ sql/austin.sql | 49 ++++++++++++--- 7 files changed, 277 insertions(+), 7 deletions(-) create mode 100644 austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java create mode 100644 austin-support/src/main/java/com/java3y/austin/support/domain/ChannelAccount.java create mode 100644 austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java create mode 100644 austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java create mode 100644 austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java create mode 100644 docker/Dockerfile diff --git a/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java b/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java new file mode 100644 index 0000000..442201a --- /dev/null +++ b/austin-support/src/main/java/com/java3y/austin/support/dao/ChannelAccountDao.java @@ -0,0 +1,37 @@ +package com.java3y.austin.support.dao; + + +import com.java3y.austin.support.domain.ChannelAccount; +import com.java3y.austin.support.domain.MessageTemplate; +import com.java3y.austin.support.domain.SmsRecord; +import org.springframework.data.domain.Pageable; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +/** + * 渠道账号信息 Dao + * + * @author 3y + */ +public interface ChannelAccountDao extends CrudRepository { + + + /** + * 查询 列表(分页) + * + * @param deleted 0:未删除 1:删除 + * @param channelType 渠道值 + * @return + */ + List findAllByIsDeletedEqualsAndSendChannelEquals(Integer deleted, Integer channelType); + + + /** + * 统计未删除的条数 + * + * @param deleted + * @return + */ + Long countByIsDeletedEquals(Integer deleted); +} diff --git a/austin-support/src/main/java/com/java3y/austin/support/domain/ChannelAccount.java b/austin-support/src/main/java/com/java3y/austin/support/domain/ChannelAccount.java new file mode 100644 index 0000000..74fb731 --- /dev/null +++ b/austin-support/src/main/java/com/java3y/austin/support/domain/ChannelAccount.java @@ -0,0 +1,61 @@ +package com.java3y.austin.support.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +/** + * @author 3y + * 渠道账号信息 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Entity +public class ChannelAccount { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 账号名称 + */ + private String name; + + /** + * 发送渠道 + * 枚举值:com.java3y.austin.common.enums.ChannelType + */ + private Integer sendChannel; + + /** + * 账号配置 + */ + private String accountConfig; + + /** + * 是否删除 + * 0:未删除 + * 1:已删除 + */ + private Integer isDeleted; + + /** + * 创建时间 单位 s + */ + private Integer created; + + /** + * 更新时间 单位s + */ + private Integer updated; + +} diff --git a/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java new file mode 100644 index 0000000..36ae4f0 --- /dev/null +++ b/austin-web/src/main/java/com/java3y/austin/web/controller/ChannelAccountController.java @@ -0,0 +1,51 @@ +package com.java3y.austin.web.controller; + + +import com.java3y.austin.common.constant.AustinConstant; +import com.java3y.austin.common.vo.BasicResultVO; +import com.java3y.austin.support.dao.ChannelAccountDao; +import com.java3y.austin.support.domain.ChannelAccount; +import com.java3y.austin.support.domain.MessageTemplate; +import com.java3y.austin.web.service.ChannelAccountService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 渠道账号管理接口 + * + * @author 3y + */ +@Slf4j +@RestController +@RequestMapping("/account") +@Api("素材管理接口") +@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true", allowedHeaders = "*") +public class ChannelAccountController { + + @Autowired + private ChannelAccountService channelAccountService; + + + /** + * 如果Id存在,则修改 + * 如果Id不存在,则保存 + */ + @PostMapping("/save") + @ApiOperation("/保存数据") + public BasicResultVO saveOrUpdate(@RequestBody ChannelAccount channelAccount) { + return BasicResultVO.success(channelAccountService.save(channelAccount)); + } + + /** + * 根据渠道标识查询渠道账号相关的信息 + */ + @GetMapping("/query") + @ApiOperation("/保存数据") + public BasicResultVO query(Integer channelType) { + return BasicResultVO.success(channelAccountService.queryByChannelType(channelType)); + } + +} diff --git a/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java b/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java new file mode 100644 index 0000000..616e729 --- /dev/null +++ b/austin-web/src/main/java/com/java3y/austin/web/service/ChannelAccountService.java @@ -0,0 +1,34 @@ +package com.java3y.austin.web.service; + + +import com.java3y.austin.common.vo.BasicResultVO; +import com.java3y.austin.support.domain.ChannelAccount; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * 渠道账号接口 + * + * @author 3y + */ +public interface ChannelAccountService { + + + /** + * 保存/修改渠道账号信息 + * + * @param channelAccount + * @return + */ + ChannelAccount save(ChannelAccount channelAccount); + + /** + * 根据渠道标识查询账号信息 + * + * @param channelType 渠道标识 + * @return + */ + List queryByChannelType(Integer channelType); + +} diff --git a/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java b/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java new file mode 100644 index 0000000..20f5d90 --- /dev/null +++ b/austin-web/src/main/java/com/java3y/austin/web/service/impl/ChannelAccountServiceImpl.java @@ -0,0 +1,35 @@ +package com.java3y.austin.web.service.impl; + +import cn.hutool.core.date.DateUtil; +import com.java3y.austin.common.constant.AustinConstant; +import com.java3y.austin.support.dao.ChannelAccountDao; +import com.java3y.austin.support.domain.ChannelAccount; +import com.java3y.austin.web.service.ChannelAccountService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * @author 3y + */ +@Service +public class ChannelAccountServiceImpl implements ChannelAccountService { + + @Autowired + private ChannelAccountDao channelAccountDao; + @Override + public ChannelAccount save(ChannelAccount channelAccount) { + if (channelAccount.getId() == null) { + channelAccount.setCreated(Math.toIntExact(DateUtil.currentSeconds())); + channelAccount.setIsDeleted(AustinConstant.FALSE); + } + channelAccount.setUpdated(Math.toIntExact(DateUtil.currentSeconds())); + return channelAccountDao.save(channelAccount); + } + + @Override + public List queryByChannelType(Integer channelType) { + return channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, channelType); + } +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..6834454 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,17 @@ +# 使用openjdk8的镜像 +FROM openjdk:8-jre + +ENV PARAMS="" + +# 设置工作目录 +WORKDIR /build +# 将jar包复制到容器中 +ADD ./austin-web-0.0.1-SNAPSHOT.jar ./austin.jar +# 暴露8080端口 +EXPOSE 8080 + +# 运行jar包 +ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS austin.jar $PARAMS"] + + +# docker run -e PARAMS="--austin-database-ip= --austin-database-port=3306 --austin-redis-ip= --austin-mq-pipeline=eventbus " -p 8080:8080 --name austin:1.0 diff --git a/sql/austin.sql b/sql/austin.sql index fef403c..7975658 100644 --- a/sql/austin.sql +++ b/sql/austin.sql @@ -1,6 +1,8 @@ -create database austin; +create +database austin; -use austin; +use +austin; CREATE TABLE `message_template` @@ -14,10 +16,10 @@ CREATE TABLE `message_template` `cron_crowd_path` varchar(500) COMMENT '定时发送人群的文件路径', `expect_push_time` varchar(100) COLLATE utf8mb4_unicode_ci COMMENT '期望发送时间:0:立即发送 定时任务以及周期任务:cron表达式', `id_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息的发送ID类型:10. userId 20.did 30.手机号 40.openId 50.email 60.企业微信userId', - `send_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息发送渠道:10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序 70.企业微信', + `send_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息发送渠道:10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序 70.企业微信 80.钉钉机器人 90.钉钉工作通知 100.企业微信机器人 110.飞书机器人 110. 飞书应用消息 ', `template_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.运营类 20.技术类接口调用', `msg_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.通知类消息 20.营销类消息 30.验证码类消息', - `shield_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.夜间不屏蔽 20.夜间屏蔽 30.夜间屏蔽(次日早上9点发送)', + `shield_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.夜间不屏蔽 20.夜间屏蔽 30.夜间屏蔽(次日早上9点发送)', `msg_content` varchar(600) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '消息内容 占位符用{$var}表示', `send_account` tinyint(4) NOT NULL DEFAULT '0' COMMENT '发送账号 一个渠道下可存在多个账号', `creator` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者', @@ -59,12 +61,45 @@ CREATE TABLE `sms_record` DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='短信记录信息'; + +CREATE TABLE `channel_account` +( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '账号名称', + `send_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息发送渠道:10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序 70.企业微信 80.钉钉机器人 90.钉钉工作通知 100.企业微信机器人 110.飞书机器人 110. 飞书应用消息 ', + `account_config` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '账号配置', + `created` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `updated` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间', + `is_deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除:0.不删除 1.删除', + PRIMARY KEY (`id`), + KEY `idx_send_channel` (`send_channel`) +) ENGINE = InnoDB + AUTO_INCREMENT = 1 + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_unicode_ci COMMENT ='渠道账号信息'; + + -- 实时类型 短信(无占位符) -INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, send_account, creator, updator, auditor, team, proposer, is_deleted, created, updated) VALUES (1, '买一送十活动', 10, '', 10, null, '', '', 30, 30, 20, 20, '{"content":"6666","url":"","title":""}', 10, 'Java3y', 'Java3y', '3y', '公众号Java3y', '三歪', 0, 1646274112, 1646275242); +INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, + expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, + send_account, creator, updator, auditor, team, proposer, is_deleted, created, + updated) +VALUES (1, '买一送十活动', 10, '', 10, null, '', '', 30, 30, 20, 20, '{"content":"6666","url":"","title":""}', 10, 'Java3y', + 'Java3y', '3y', '公众号Java3y', '三歪', 0, 1646274112, 1646275242); -- 实时类型 邮件(无占位符) -INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, send_account, creator, updator, auditor, team, proposer, is_deleted, created, updated) VALUES (2, '校招信息', 10, '', 10, null, '', '', 50, 40, 20, 10, '{"content":"你已成功获取到offer","url":"","title":"招聘通知"}', 10, 'Java3y', 'Java3y', '3y', '公众号Java3y', '鸡蛋', 0, 1646274195, 1646274195); +INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, + expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, + send_account, creator, updator, auditor, team, proposer, is_deleted, created, + updated) +VALUES (2, '校招信息', 10, '', 10, null, '', '', 50, 40, 20, 10, '{"content":"你已成功获取到offer","url":"","title":"招聘通知"}', 10, + 'Java3y', 'Java3y', '3y', '公众号Java3y', '鸡蛋', 0, 1646274195, 1646274195); -- 实时类型 短信(有占位符)占位符key 为 content -INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, send_account, creator, updator, auditor, team, proposer, is_deleted, created, updated) VALUES (3, '验证码通知', 10, '', 10, null, '', '', 30, 30, 20, 30, '{"content":"{$content}","url":"","title":""}', 10, 'Java3y', 'Java3y', '3y', '公众号Java3y', '孙悟空', 0, 1646275213, 1646275213); +INSERT INTO austin.message_template (id, name, audit_status, flow_id, msg_status, cron_task_id, cron_crowd_path, + expect_push_time, id_type, send_channel, template_type, msg_type, msg_content, + send_account, creator, updator, auditor, team, proposer, is_deleted, created, + updated) +VALUES (3, '验证码通知', 10, '', 10, null, '', '', 30, 30, 20, 30, '{"content":"{$content}","url":"","title":""}', 10, + 'Java3y', 'Java3y', '3y', '公众号Java3y', '孙悟空', 0, 1646275213, 1646275213);