Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
wells2333 committed Oct 27, 2019
1 parent 6bbe33c commit e1b83ab
Show file tree
Hide file tree
Showing 117 changed files with 1,916 additions and 19,052 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ target/
out/
bin/
intellij/
build/
*.log
*.log.*
*.iml
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Version v3.4.0 (2019-10-27)
--------------------------
改进:

* 修复若干bug

Version v3.4.0 (2019-9-14)
--------------------------
改进:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.tangyi.common.core.utils;

import lombok.extern.slf4j.Slf4j;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -13,6 +15,7 @@
* @author tangyi
* @date 2019/4/28 16:03
*/
@Slf4j
public class DateUtils {

private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
Expand Down Expand Up @@ -78,4 +81,54 @@ public static LocalDate asLocalDate(Date date) {
public static LocalDateTime asLocalDateTime(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
}

/**
* 两个时间之差
*
* @param startDate startDate
* @param endDate endDate
* @return 分钟
*/
public static Integer getBetweenMinutes(Date startDate, Date endDate) {
int minutes = 0;
try {
if (startDate != null && endDate != null) {
long ss;
if (startDate.before(endDate)) {
ss = endDate.getTime() - startDate.getTime();
} else {
ss = startDate.getTime() - endDate.getTime();
}
minutes = (int) (ss / (60 * 1000));
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return minutes;
}

/**
* 两个时间只差
*
* @param startDate startDate
* @param endDate endDate
* @return 秒数
*/
public static Integer getBetweenSecond(Date startDate, Date endDate) {
int seconds = 0;
try {
if (startDate != null && endDate != null) {
long ss;
if (startDate.before(endDate)) {
ss = endDate.getTime() - startDate.getTime();
} else {
ss = startDate.getTime() - endDate.getTime();
}
seconds = (int) (ss / (1000));
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return seconds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public static String getTenantCode() {
tenantCode = getCurrentUserTenantCode();
if (StringUtils.isBlank(tenantCode))
tenantCode = SecurityConstant.DEFAULT_TENANT_CODE;
log.debug("租户code:{}", tenantCode);
return tenantCode;
}

Expand Down
3 changes: 1 addition & 2 deletions config-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
FROM anapsix/alpine-java:8_server-jre_unlimited
MAINTAINER tangyi(1633736729@qq.com)
ARG JAR_FILE
ENV PROFILE native
ADD target/${JAR_FILE} /opt/app.jar
EXPOSE 9181
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -Dspring.profiles.active=${PROFILE} -jar /opt/app.jar
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -jar /opt/app.jar

# JAVA_OPS配置,如:JAVA_OPS='-Xmx512m -Xms256m'
1 change: 0 additions & 1 deletion config-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
</executions>
<configuration>
<repository>${docker.registry}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<tag>latest</tag>
<!-- 构建参数,指定jar包名称 -->
<buildArgs>
Expand Down
9 changes: 9 additions & 0 deletions config-service/src/main/resources/application-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 生产环境的配置,采用git方式
spring:
cloud:
config:
server:
git:
uri: https://git.oschina.net/wells2333/config-server # 配置git仓库的地址
username: # git仓库的账号
password: # git仓库的密码
20 changes: 13 additions & 7 deletions config-service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,24 @@
</filter>
</appender>

<!-- 输出到logstash的appender -->
<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<!-- logstash的IP和端口,从环境变量注入 -->
<destination>${ELK_DESTINATION}</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<!-- 输出到logstash的appender, ELK_DESTINATION为logstash的IP和端口,从环境变量注入-->
<!-- <appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>${ELK_DESTINATION}</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>-->

<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<appender-ref ref="logstash"/>
<!--<appender-ref ref="logstash"/>-->
</root>

<logger name="com.github.tangyi" level="debug">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<!--<appender-ref ref="logstash"/>-->
</logger>
</configuration>
16 changes: 16 additions & 0 deletions docs/deploy/docker-compose-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ services:
networks:
- net

# # ---------------------------
# # example
# # ---------------------------
# spring-microservice-exam-web-Spencer:
# image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/exam-web-example:latest
# volumes:
# # 挂载nginx的配置文件
# - ./nginx.conf:/etc/nginx/nginx.conf
# container_name: web-service-example
# env_file: docker-compose.env # 从文件中获取配置
# restart: always
# ports:
# - "88:80"
# networks:
# - net

networks:
net:
driver: bridge
Expand Down
5 changes: 1 addition & 4 deletions docs/deploy/docker-compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,4 @@ CLUSTER_DATA_CENTER_ID=1
TZ=Asia/Shanghai

# elk配置
ELK_DESTINATION=localhost:5044

# 日志级别
LOGGING_LEVEL=error
ELK_DESTINATION=localhost:5044
4 changes: 2 additions & 2 deletions docs/deploy/mysql/init/microservice_auth.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ CREATE TABLE `oauth_client_details` (
`additional_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`autoapprove` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`creator` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '创建人',
`create_date` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
`create_date` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`modifier` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '修改人',
`modify_date` timestamp(0) NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '修改时间',
`modify_date` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
`del_flag` tinyint(4) NOT NULL COMMENT '删除标记',
`application_code` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统编号',
`tenant_code` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '租户编号',
Expand Down
Loading

0 comments on commit e1b83ab

Please sign in to comment.