0. 添加文件上传接口(人群信息通过csv文件传入)

1. 修改表结构 支持文件上传,剔除暂不需要用的字段
2. yaml文件配置改为properties
pull/4/head
3y 2 years ago
parent 57222439f6
commit a643975b05

@ -54,7 +54,7 @@ austin项目**核心流程**`austin-api`接收到发送消息请求,直接
**1**、austin使用的MySQL版本**5.7x**。如果目前使用的MySQL版本8.0,注意改变`pom.xml`所依赖的版本
**2**、适配`application.yml`的配置信息(`srping.datasource`)
**2**、适配`application.properties`的配置信息(`srping.datasource`)
**3**、执行`sql`文件夹下的`austin.sql`创建对应的表
@ -64,7 +64,7 @@ austin项目**核心流程**`austin-api`接收到发送消息请求,直接
**6**、填写apollo的`appid`/`namespace`
**7**、以上配置信息都在`application.yml`文件中修改。
**7**、以上配置信息都在`application.properties`文件中修改。
**8**、由于使用了Apollo且我是在云服务器上安装的我这边会直接跳过`metaserver`服务发现,在`AustinApplication`需要配置对应的apollo地址

@ -68,16 +68,5 @@ public class TaskInfo {
*/
private Integer sendAccount;
/**
*
*/
private Integer deduplicationTime;
/**
*
* 0:
* 1
*/
private Integer isNightShield;
}

@ -33,7 +33,7 @@ public class Receiver {
@Autowired
private TaskPendingHolder taskPendingHolder;
@KafkaListener(topics = "#{'${austin.topic.name}'}")
@KafkaListener(topics = "#{'${austin.business.topic.name}'}")
public void consumer(ConsumerRecord<?, String> consumerRecord, @Header(KafkaHeaders.GROUP_ID) String topicGroupId) {
Optional<String> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) {

@ -6,17 +6,16 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables;
import com.java3y.austin.constant.AustinConstant;
import com.java3y.austin.dto.ContentModel;
import com.java3y.austin.dto.SmsContentModel;
import com.java3y.austin.enums.ChannelType;
import com.java3y.austin.enums.RespStatusEnum;
import com.java3y.austin.dao.MessageTemplateDao;
import com.java3y.austin.domain.MessageParam;
import com.java3y.austin.domain.MessageTemplate;
import com.java3y.austin.domain.SendTaskModel;
import com.java3y.austin.domain.TaskInfo;
import com.java3y.austin.dto.ContentModel;
import com.java3y.austin.enums.ChannelType;
import com.java3y.austin.enums.RespStatusEnum;
import com.java3y.austin.pipeline.BusinessProcess;
import com.java3y.austin.pipeline.ProcessContext;
import com.java3y.austin.domain.TaskInfo;
import com.java3y.austin.utils.ContentHolderUtil;
import com.java3y.austin.utils.TaskInfoUtils;
import com.java3y.austin.vo.BasicResultVO;
@ -79,9 +78,7 @@ public class AssembleAction implements BusinessProcess {
.templateType(messageTemplate.getTemplateType())
.msgType(messageTemplate.getMsgType())
.sendAccount(messageTemplate.getSendAccount())
.contentModel(getContentModelValue(messageTemplate, messageParam))
.deduplicationTime(messageTemplate.getDeduplicationTime())
.isNightShield(messageTemplate.getIsNightShield()).build();
.contentModel(getContentModelValue(messageTemplate, messageParam)).build();
taskInfoList.add(taskInfo);
}

@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.base.Throwables;
import com.java3y.austin.domain.SendTaskModel;
import com.java3y.austin.domain.TaskInfo;
import com.java3y.austin.enums.RespStatusEnum;
import com.java3y.austin.pipeline.BusinessProcess;
import com.java3y.austin.pipeline.ProcessContext;
import com.java3y.austin.pipeline.ProcessModel;
import com.java3y.austin.vo.BasicResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -25,7 +23,7 @@ public class SendMqAction implements BusinessProcess {
@Autowired
private KafkaTemplate kafkaTemplate;
@Value("${austin.topic.name}")
@Value("${austin.business.topic.name}")
private String topicName;
@Override

@ -139,17 +139,6 @@ public class MessageTemplate implements Serializable {
*/
private Integer updated;
/**
*
*/
private Integer deduplicationTime;
/**
*
* 0:
* 1
*/
private Integer isNightShield;
}

@ -1,7 +1,10 @@
package com.java3y.austin.controller;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Throwables;
import com.java3y.austin.domain.MessageParam;
import com.java3y.austin.domain.MessageTemplate;
import com.java3y.austin.domain.SendRequest;
@ -16,10 +19,13 @@ import com.java3y.austin.vo.MessageTemplateParam;
import com.java3y.austin.vo.MessageTemplateVo;
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.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -31,6 +37,7 @@ import java.util.stream.Collectors;
*
* @author 3y
*/
@Slf4j
@RestController
@RequestMapping("/messageTemplate")
@Api("发送消息")
@ -44,6 +51,10 @@ public class MessageTemplateController {
@Autowired
private SendService sendService;
@Value("${austin.business.upload.crowd.path}")
private String dataPath;
/**
* Id
* Id
@ -51,6 +62,7 @@ public class MessageTemplateController {
@PostMapping("/save")
@ApiOperation("/保存数据")
public BasicResultVO saveOrUpdate(@RequestBody MessageTemplate messageTemplate) {
MessageTemplate info = messageTemplateService.saveOrUpdate(messageTemplate);
return BasicResultVO.success(info);
@ -132,6 +144,7 @@ public class MessageTemplateController {
public BasicResultVO start(@RequestBody @PathVariable("id") Long id) {
return messageTemplateService.startCronTask(id);
}
/**
*
*/
@ -147,8 +160,24 @@ public class MessageTemplateController {
@PostMapping("upload")
@ApiOperation("/上传人群文件")
public BasicResultVO upload(@RequestParam("file") MultipartFile file) {
return BasicResultVO.success();
String filePath = new StringBuilder(dataPath)
.append(IdUtil.fastSimpleUUID())
.append(file.getOriginalFilename())
.toString();
try {
File localFile = new File(filePath);
if (!localFile.exists()) {
localFile.mkdirs();
}
file.transferTo(localFile);
} catch (Exception e) {
log.error("MessageTemplateController#upload fail! e:{},params{}", Throwables.getStackTraceAsString(e), JSON.toJSONString(file));
return BasicResultVO.fail(RespStatusEnum.SERVICE_ERROR);
}
return BasicResultVO.success(MapUtil.of(new String[][]{{"value", filePath}}));
}
}

@ -131,7 +131,6 @@ public class MessageTemplateServiceImpl implements MessageTemplateService {
messageTemplate.setFlowId(StrUtil.EMPTY)
.setMsgStatus(MessageStatus.INIT.getCode()).setAuditStatus(AuditStatus.WAIT_AUDIT.getCode())
.setCreator("Java3y").setUpdator("Java3y").setTeam("公众号Java3y").setAuditor("3y")
.setDeduplicationTime(AustinConstant.FALSE).setIsNightShield(AustinConstant.FALSE)
.setCreated(Math.toIntExact(DateUtil.currentSeconds()))
.setIsDeleted(AustinConstant.FALSE);

@ -0,0 +1,68 @@
# TODO please replace ${var} !!
# TODO please replace ${var} !!
# TODO please replace ${var} !!
##################### database properties #####################
# notice:mysql version 5.7x !!! todo ip port username password
spring.datasource.url=jdbc:mysql://${ip}:${port}/austin?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
spring.datasource.username=${username}
spring.datasource.password=${password}
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
##################### kafka properties #####################
# todo ip port
spring.kafka.bootstrap-servers=${ip}:${port}
spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.auto.offset.reset=earliest
spring.kafka.consumer.auto-commit-interval=1000
spring.kafka.consumer.enable-auto-commit=true
##################### redis properties #####################
# todo ip port password
spring.redis.host=${ip}
spring.redis.port=${port}
spring.redis.password=${password}
##################### business properties #####################
austin.business.topic.name=austinTopicV2
# TODO if need graylog ,replace ip !
austin.business.graylog.ip=${ip}
# TODO if windows os ,replace path !
austin.business.upload.crowd.path=/Users/3y/temp
##################### xxl properties #####################
# todo ip port
xxl.job.admin.addresses=http://${ip}:${port}/xxl-job-admin
xxl.job.admin.username=admin
xxl.job.admin.password=123456
xxl.job.executor.appname=austin
xxl.job.executor.jobHandlerName=austinJob
xxl.job.executor.ip=
xxl.job.executor.port=6666
xxl.job.executor.logpath=
xxl.job.executor.logretentiondays=30
xxl.job.accessToken=
##################### apollo #####################
app.id=austin
apollo.bootstrap.enabled=true
apollo.bootstrap.namespaces=boss.austin
##################### httpUtils properties #####################
ok.http.connect-timeout=30
ok.http.keep-alive-duration=300
ok.http.max-idle-connections=200
ok.http.read-timeout=30
ok.http.write-timeout=30
##################### monitor properties #####################
management.endpoint.health.show-details=always
management.endpoint.metrics.enabled=true
management.endpoint.prometheus.enabled=true
management.endpoints.web.exposure.include=*
management.metrics.export.prometheus.enabled=true

@ -1,88 +0,0 @@
# HTTP 连接配置 T0D0
ok:
http:
connect-timeout: 30
keep-alive-duration: 300
max-idle-connections: 200
read-timeout: 30
write-timeout: 30
# 数据库相关的信息配置 TODO
spring:
datasource:
url:
username:
password:
driver-class-name:
# kafka相关的信息配置 TODO
kafka:
bootstrap-servers:
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
consumer:
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
auto:
offset:
reset: earliest
auto-commit-interval: 1000
enable-auto-commit: true
# redis 相关配置 TODO
redis:
host:
port:
password:
# 消息topicName TODO
austin:
topic:
name: austinTopic
# GrayLog ip 地址 TODO
grayLogIp:
# 监控配置 TODO
management:
endpoint:
health:
show-details: always
metrics:
enabled: true
prometheus:
enabled: true
endpoints:
web:
exposure:
include: '*'
metrics:
export:
prometheus:
enabled: true
# apollo TODO
app:
id: austin
apollo:
bootstrap:
enabled: true
namespaces: boss.austin
# xxl job TODO
xxl:
job:
admin:
addresses: # 调度中心部署跟地址 [选填]:如调度中心集群部署存在多个地址则用逗号分隔。执行器将会使用该地址进行"执行器心跳注册"和"任务结果回调";为空则关闭自动注册;
username: admin # 后台账号名
password: 123456 # 后台密码
executor:
appname: austin # 执行器 AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册
jobHandlerName: austinJob # 执行器任务名
ip: # 执行器IP [选填]默认为空表示自动获取IP多网卡时可手动设置指定IP该IP不会绑定Host仅作为通讯实用地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"
port: 6666 # ### 执行器端口号 [选填]小于等于0则自动获取默认端口为9999单机部署多个执行器时注意要配置不同执行器端口
logpath: # 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径;
logretentiondays: 30 # 执行器日志文件保存天数 [选填] 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能;
accessToken: # 执行器通讯TOKEN [选填]:非空时启用;

@ -7,7 +7,7 @@
<!-- 设置日志输出路径 可以使“${}”来使用变量。TODO 后面是可以读配置的 -->
<property name="log.path" value="logs"/>
<springProperty scope="context" name="grayLogIp" source="austin.grayLogIp"/>
<springProperty scope="context" name="grayLogIp" source="austin.business.graylog.ip"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">

@ -7,36 +7,34 @@ austin;
CREATE TABLE `message_template`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '标题',
`audit_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '当前消息审核状态: 10.待审核 20.审核成功 30.被拒绝',
`flow_id` varchar(50) COLLATE utf8mb4_unicode_ci COMMENT '工单ID',
`msg_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '当前消息状态10.新建 20.停用 30.启用 40.等待发送 50.发送中 60.发送成功 70.发送失败',
`cron_task_id` bigint(20) COMMENT '定时任务Id (xxl-job-admin返回)',
`cron_crowd_path` varchar (500) COMMENT '定时发送人群的文件路径',
`id_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息的发送ID类型10. userId 20.did 30.手机号 40.openId 50.email',
`send_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息发送渠道10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序',
`template_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.运营类 20.技术类接口调用',
`msg_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.通知类消息 20.营销类消息 30.验证码类消息',
`expect_push_time` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '期望发送时间:立即发送.10 定时任务以及周期任务.cron表达式',
`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 '创建者',
`updator` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
`auditor` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '审核人',
`team` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '业务方团队',
`proposer` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '业务方',
`is_deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除0.不删除 1.删除',
`created` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`updated` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`deduplication_time` tinyint(4) NOT NULL DEFAULT '0' COMMENT '去重时间 单位小时',
`is_night_shield` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否夜间屏蔽0.夜间不屏蔽 1.夜间屏蔽',
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '标题',
`audit_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '当前消息审核状态: 10.待审核 20.审核成功 30.被拒绝',
`flow_id` varchar(50) COLLATE utf8mb4_unicode_ci COMMENT '工单ID',
`msg_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '当前消息状态10.新建 20.停用 30.启用 40.等待发送 50.发送中 60.发送成功 70.发送失败',
`cron_task_id` bigint(20) COMMENT '定时任务Id (xxl-job-admin返回)',
`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',
`send_channel` tinyint(4) NOT NULL DEFAULT '0' COMMENT '消息发送渠道10.IM 20.Push 30.短信 40.Email 50.公众号 60.小程序',
`template_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.运营类 20.技术类接口调用',
`msg_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '10.通知类消息 20.营销类消息 30.验证码类消息',
`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 '创建者',
`updator` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '更新者',
`auditor` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '审核人',
`team` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '业务方团队',
`proposer` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '业务方',
`is_deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除0.不删除 1.删除',
`created` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`updated` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `idx_channel` (`send_channel`)
KEY `idx_channel` (`send_channel`)
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT ='消息模板信息'
COLLATE = utf8mb4_unicode_ci COMMENT ='消息模板信息';
@ -60,25 +58,27 @@ CREATE TABLE `sms_record`
) ENGINE = InnoDB
AUTO_INCREMENT = 1
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci COMMENT ='短信记录信息'
COLLATE = utf8mb4_unicode_ci COMMENT ='短信记录信息';
/*测试短信*/
INSERT INTO austin.message_template (id, name, audit_status, msg_status, id_type, send_channel, template_type, msg_type, expect_push_time, msg_content, send_account, creator, updator, auditor, team, proposer, is_deleted, created, updated, deduplication_time, is_night_shield)
VALUES (1, 'test短信', 10, 10, 30, 30, 10, 10, '0', '{"content":"{$contentValue}"}', 10, 'yyyyc', 'yyyyu', 'yyyyyyz', 'yyyt', 'yyyy22', 0, 1636978066, 1636978066, 1, 0);
INSERT INTO austin.message_template (id, name, audit_status, msg_status, id_type,
send_channel, template_type, msg_type, msg_content, send_account, creator,
updator, auditor, team, proposer, is_deleted, created, updated)
VALUES (1, 'test短信', 10, 10, 30, 30, 10, 10, '{"content":"{$contentValue}"}', 10, 'yyyyc', 'yyyyu', 'yyyyyyz', 'yyyt',
'yyyy22', 0, 1636978066, 1636978066);
/*测试短信+url链接追踪*/
INSERT INTO austin.message_template (id, name, audit_status, msg_status, id_type, send_channel, template_type,
msg_type, expect_push_time, msg_content, send_account, creator, updator, auditor,
team, proposer, is_deleted, created, updated, deduplication_time, is_night_shield)
VALUES (2, 'test短信', 10, 10, 30, 30, 10, 20, '0',
msg_type, msg_content, send_account, creator, updator, auditor,
team, proposer, is_deleted, created, updated)
VALUES (2, 'test短信', 10, 10, 30, 30, 10, 20,
'{"content":"{$contentValue}","url":"https://gitee.com/zhongfucheng/austin"}', 10, 'yyyyc', 'yyyyu', 'yyyyyyz',
'yyyt', 'yyyy22', 0, 1637411536, 1637411536, 1, 0);
'yyyt', 'yyyy22', 0, 1637411536, 1637411536);
/*测试邮件发送*/
INSERT INTO austin.message_template (id, name, audit_status, msg_status, id_type, send_channel, template_type,
msg_type, expect_push_time, msg_content, send_account, creator, updator, auditor,
team, proposer, is_deleted, created, updated, deduplication_time, is_night_shield)
VALUES (3, 'test邮件', 10, 10, 50, 40, 20, 10, '0', '{"content":"{$contentValue}","title":"{$title}"}', 10,
'yyyyc', 'yyyyu', 'yyyyyyz', 'yyyt', 'yyyy22', 0, 1641546914, 1641546914, 1, 0);
msg_type, msg_content, send_account, creator, updator, auditor,
team, proposer, is_deleted, created, updated)
VALUES (3, 'test邮件', 10, 10, 50, 40, 20, 10, '{"content":"{$contentValue}","title":"{$title}"}', 10,
'yyyyc', 'yyyyu', 'yyyyyyz', 'yyyt', 'yyyy22', 0, 1641546914, 1641546914);
Loading…
Cancel
Save