Commit a4dbed9b by yuwei

项目初始化

parent 0bcbbb22
# 数据源配置
spring:
datasource:
dynamic:
type: com.zaxxer.hikari.HikariDataSource
hikari:
auto-commit: false
connection-timeout: 30000
idle-timeout: 25000
login-timeout: 5
max-lifetime: 30000
read-only: false
validation-timeout: 3000
maximum-pool-size: 15
minimum-idle: 5
pool-name: DataxHikariCP
connection-test-query: SELECT 1 FROM DUAL
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
useLocalSessionState: true
rewriteBatchedStatements: true
cacheResultSetMetadata: true
cacheServerConfiguration: true
elideSetAutoCommits: true
maintainTimeStats: false
primary: mysql
datasource:
mysql:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://127.0.0.1:3306/data_cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 1234@abcd
mybatis-plus:
mapper-locations: classpath*:mapper/*Mapper.xml
type-aliases-package: cn.datax.email.api.entity
global-config:
db-config:
id-type: ID_WORKER_STR
logic-delete-value: 0 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 1 # 逻辑未删除值(默认为 0)
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# spring security 配置
security:
oauth2:
client:
access-token-uri: http://localhost:8612/auth/oauth/token
user-authorization-uri: http://localhost:8612/auth/oauth/authorize
client-id: datax
client-secret: 123456
scope: all
resource:
loadBalanced: true
token-info-uri: http://localhost:8612/auth/oauth/check_token
\ No newline at end of file
# 数据源配置
spring:
datasource:
dynamic:
type: com.zaxxer.hikari.HikariDataSource
hikari:
auto-commit: false
connection-timeout: 30000
idle-timeout: 25000
login-timeout: 5
max-lifetime: 30000
read-only: false
validation-timeout: 3000
maximum-pool-size: 15
minimum-idle: 5
pool-name: DataxHikariCP
connection-test-query: SELECT 1 FROM DUAL
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
useLocalSessionState: true
rewriteBatchedStatements: true
cacheResultSetMetadata: true
cacheServerConfiguration: true
elideSetAutoCommits: true
maintainTimeStats: false
primary: mysql
datasource:
mysql:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
url: jdbc:p6spy:mysql://127.0.0.1:3306/data_cloud?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 1234@abcd
mybatis-plus:
mapper-locations: classpath*:mapper/*Mapper.xml
type-aliases-package: cn.datax.file.api.entity
global-config:
db-config:
id-type: ID_WORKER_STR
logic-delete-value: 0 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 1 # 逻辑未删除值(默认为 0)
banner: false
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# spring security 配置
security:
oauth2:
client:
access-token-uri: http://localhost:8612/auth/oauth/token
user-authorization-uri: http://localhost:8612/auth/oauth/authorize
client-id: datax
client-secret: 123456
scope: all
resource:
loadBalanced: true
token-info-uri: http://localhost:8612/auth/oauth/check_token
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>email-service-parent</artifactId>
<groupId>cn.datax</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>email-service-api</artifactId>
<dependencies>
<!--feign 依赖-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-core</artifactId>
<version>${app.version}</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.datax.service.email.api.entity;
import cn.datax.common.base.BaseEntity;
import lombok.Data;
import java.io.File;
import java.util.List;
@Data
public class EmailEntity extends BaseEntity {
/**
* 标题
*/
private String subject;
/**
* 内容
*/
private String text;
/**
* 接收人
*/
private List<String> tos;
/**
* 抄送人
*/
private List<String> ccs;
/**
* 密送人
*/
private List<String> bccs;
/**
* 附件
*/
private List<File> files;
}
package cn.datax.service.email.api.feign;
import cn.datax.common.core.R;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.datax.service.email.api.feign.factory.EmailServiceFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(contextId = "emailServiceFeign", value = "datax-service-email", fallbackFactory = EmailServiceFeignFallbackFactory.class)
public interface EmailServiceFeign {
@PostMapping("/mail")
R sendMail(@RequestBody EmailEntity mail);
}
package cn.datax.service.email.api.feign.factory;
import cn.datax.service.email.api.feign.EmailServiceFeign;
import cn.datax.service.email.api.feign.fallback.EmailServiceFeignFallbackImpl;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
@Component
public class EmailServiceFeignFallbackFactory implements FallbackFactory<EmailServiceFeign> {
@Override
public EmailServiceFeign create(Throwable throwable) {
EmailServiceFeignFallbackImpl emailServiceFeignFallbackImpl = new EmailServiceFeignFallbackImpl();
emailServiceFeignFallbackImpl.setCause(throwable);
return emailServiceFeignFallbackImpl;
}
}
package cn.datax.service.email.api.feign.fallback;
import cn.datax.common.core.R;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.datax.service.email.api.feign.EmailServiceFeign;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class EmailServiceFeignFallbackImpl implements EmailServiceFeign {
@Setter
private Throwable cause;
@Override
public R sendMail(EmailEntity mail) {
log.error("feign 发送邮件失败", cause);
return null;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>email-service-parent</artifactId>
<groupId>cn.datax</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>email-service</artifactId>
<dependencies>
<!--配置中心客户端 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--web 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--mail 模块-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>${swagger-bootstrap.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-mybatis</artifactId>
<version>${app.version}</version>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-security</artifactId>
<version>${app.version}</version>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-log</artifactId>
<version>${app.version}</version>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>email-service-api</artifactId>
<version>${app.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package cn.datax.service.email;
import cn.datax.common.log.annotation.EnableDataLog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDataLog
@SpringBootApplication
public class DataxMailApplication {
public static void main(String[] args) {
SpringApplication.run(DataxMailApplication.class);
}
}
package cn.datax.service.email.controller;
import cn.datax.common.core.R;
import cn.datax.common.log.annotation.LogAop;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.datax.service.email.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/email")
public class EmailController {
@Autowired
private EmailService emailService;
@LogAop(module = "datax-service-email", value = "发送邮件")
@PostMapping
public R sendMail(@RequestBody EmailEntity mail) {
emailService.sendEmail(mail);
return R.ok();
}
}
package cn.datax.service.email.mapper;
import cn.datax.common.base.BaseDao;
import cn.datax.service.email.api.entity.EmailEntity;
public interface MailMapper extends BaseDao<EmailEntity> {
}
package cn.datax.service.email.service;
import cn.datax.service.email.api.entity.EmailEntity;
public interface EmailService {
void sendEmail(EmailEntity mail);
}
package cn.datax.service.email.service.impl;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.datax.service.email.service.EmailService;
import cn.datax.service.email.utils.EmailUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeUtility;
import java.io.UnsupportedEncodingException;
@Slf4j
@Service
public class EmailServiceImpl implements EmailService {
@Value("${spring.mail.from}")
private String fromNick;
@Value("${spring.mail.username}")
private String fromAddress;
@Autowired
private JavaMailSender mailSender;
@Override
public void sendEmail(EmailEntity emailEntity) {
log.info("实体类 {}", emailEntity);
InternetAddress from = null;
String alias = null;
try {
alias = MimeUtility.encodeText(fromNick);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
try {
from = new InternetAddress(alias + " <" + fromAddress + ">");
} catch (AddressException e) {
e.printStackTrace();
}
EmailUtil emailUtil = new EmailUtil(from, mailSender);
try {
emailUtil.sendEmail(emailEntity);
} catch (Exception e) {
e.printStackTrace();
}
}
}
package cn.datax.service.email.utils;
import cn.datax.service.email.api.entity.EmailEntity;
import cn.hutool.core.collection.CollUtil;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.util.List;
public class EmailUtil {
private InternetAddress from;
private JavaMailSender mailSender;
public EmailUtil(InternetAddress from, JavaMailSender mailSender) {
this.from = from;
this.mailSender = mailSender;
}
public void sendEmail(EmailEntity mailEntity) throws Exception {
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(from);
helper.setSubject(mailEntity.getSubject());
helper.setText(mailEntity.getText(),true);
List<String> tos = mailEntity.getTos();
helper.setTo((String[])tos.toArray(new String[tos.size()]));
List<String> ccs = mailEntity.getCcs();
if(CollUtil.isNotEmpty(ccs)){
helper.setCc((String[])ccs.toArray(new String[ccs.size()]));
}
List<String> bccs = mailEntity.getBccs();
if(CollUtil.isNotEmpty(bccs)){
helper.setBcc((String[])bccs.toArray(new String[bccs.size()]));
}
List<File> files = mailEntity.getFiles();
if(CollUtil.isNotEmpty(files)){
for (int i = 0; i < files.size(); i++) {
File file = files.get(i);
helper.addAttachment(file.getName(), file);
}
}
mailSender.send(mimeMessage);
}
}
server:
port: 8812
spring:
application:
name: datax-service-email
profiles:
active: dev
cloud:
config:
fail-fast: true
uri: http://localhost:8611
name: ${spring.application.name}
profile: ${spring.profiles.active}
discovery:
enabled: true
service-id: datax-config
# 注册中心配置
eureka:
instance:
lease-renewal-interval-in-seconds: 20
client:
register-with-eureka: true
fetch-registry: true
instance-info-replication-interval-seconds: 30
registry-fetch-interval-seconds: 3
service-url:
defaultZone: http://localhost:8610/eureka
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>datax-modules</artifactId>
<groupId>cn.datax</groupId>
<version>1.0.0</version>
</parent>
<packaging>pom</packaging>
<modules>
<module>email-service</module>
<module>email-service-api</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<artifactId>email-service-parent</artifactId>
</project>
\ No newline at end of file
......@@ -12,6 +12,15 @@
<artifactId>file-service-api</artifactId>
<dependencies>
<!--feign 依赖-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-core</artifactId>
......
......@@ -7,10 +7,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "data.file-server")
public class FileServerProperties {
/**
* 为以下3个值,指定不同的自动化配置
* 为以下4个值,指定不同的自动化配置
* qiniu:七牛oss
* aliyun:阿里云oss
* fastdfs:本地部署的fastDFS
* local:本地盘符部署
*/
private String type;
......
......@@ -15,6 +15,7 @@
<modules>
<module>system-service-parent</module>
<module>file-service-parent</module>
<module>email-service-parent</module>
</modules>
</project>
\ No newline at end of file
......@@ -12,6 +12,15 @@
<artifactId>system-service-api</artifactId>
<dependencies>
<!--feign 依赖-->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-core</artifactId>
......
......@@ -66,6 +66,11 @@
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>datax-common-log</artifactId>
<version>${app.version}</version>
</dependency>
<dependency>
<groupId>cn.datax</groupId>
<artifactId>system-service-api</artifactId>
<version>${app.version}</version>
</dependency>
......
package cn.datax.service.codegen;
package cn.datax.tool.codegen;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package cn.datax.service.codegen.utils;
package cn.datax.tool.codegen.utils;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>datax-tools</artifactId>
<groupId>cn.datax</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>datax-tool-monitor</artifactId>
<dependencies>
<!--监控服务端 -->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<!--web 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package cn.datax.tool.monitor;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@EnableDiscoveryClient
@EnableAdminServer
@SpringBootApplication
public class DataxMonitorApplication {
public static void main(String[] args) {
SpringApplication.run(DataxMonitorApplication.class, args);
}
}
server:
port: 8614
spring:
application:
name: datax-tool-monitor
# 注册中心配置
eureka:
instance:
lease-renewal-interval-in-seconds: 20
client:
register-with-eureka: true
fetch-registry: true
instance-info-replication-interval-seconds: 30
registry-fetch-interval-seconds: 3
service-url:
defaultZone: http://localhost:8610/eureka
\ No newline at end of file
......@@ -14,6 +14,7 @@
<modules>
<module>datax-tool-codegen</module>
<module>datax-tool-monitor</module>
</modules>
</project>
\ No newline at end of file
......@@ -22,6 +22,7 @@
<app.version>1.0.0</app.version>
<spring-boot.version>2.1.9.RELEASE</spring-boot.version>
<spring-cloud.version>Greenwich.SR3</spring-cloud.version>
<spring-boot-admin.version>2.1.6</spring-boot-admin.version>
<fastjson.version>1.2.62</fastjson.version>
<hutool.version>5.0.3</hutool.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment