Skip to content

Commit

Permalink
1、增加渠道账号信息表和接口
Browse files Browse the repository at this point in the history
2、增加Dockerfile文件
  • Loading branch information
ZhongFuCheng3y committed Aug 1, 2022
1 parent 8ed6ec7 commit c9b4bbe
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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<ChannelAccount, Long> {


/**
* 查询 列表(分页)
*
* @param deleted 0:未删除 1:删除
* @param channelType 渠道值
* @return
*/
List<ChannelAccount> findAllByIsDeletedEqualsAndSendChannelEquals(Integer deleted, Integer channelType);


/**
* 统计未删除的条数
*
* @param deleted
* @return
*/
Long countByIsDeletedEquals(Integer deleted);
}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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));
}

}
Original file line number Diff line number Diff line change
@@ -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<ChannelAccount> queryByChannelType(Integer channelType);

}
Original file line number Diff line number Diff line change
@@ -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<ChannelAccount> queryByChannelType(Integer channelType) {
return channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(AustinConstant.FALSE, channelType);
}
}
17 changes: 17 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
49 changes: 42 additions & 7 deletions sql/austin.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
create database austin;
create
database austin;

use austin;
use
austin;


CREATE TABLE `message_template`
Expand All @@ -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 '创建者',
Expand Down Expand Up @@ -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);

0 comments on commit c9b4bbe

Please sign in to comment.