Skip to content

Commit edd02a0

Browse files
author
jinzhiqiang
committed
重新整理项目结构
0 parents  commit edd02a0

File tree

249 files changed

+10857
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+10857
-0
lines changed

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#gralde build
2+
build
3+
gradle
4+
.gradle
5+
classes
6+
gradlew*
7+
8+
#idea
9+
.idea
10+
*.iml
11+
out
12+
13+
#java
14+
*.class
15+
*.jar
16+
*.war
17+
*.ear
18+
.DS*
19+
20+
#log
21+

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## 每个项目下都有README.md对相关技术进行了详细的使用说明,在github项目中会显示在主页。
2+
3+
## 谢谢 star
4+
5+
### kingboy-springboot-auto
6+
- 端口
7+
- 8080
8+
- 分支功能
9+
- master --> 演示SpringBoot自动配置的模块
10+
11+
### kingboy-springboot-data
12+
- 端口
13+
- 8080
14+
- 分支功能
15+
- feature_jpa_hibernate --> 详细的演示了hibernate JPA各种使用示例(带测试用例)
16+
- feature_jpa_elastic --> 详细演示了ES的JPA使用(带测试用例)
17+
- feature_redis_lock --> redis全局锁使用示例
18+
- feature_mybatis_annotation --> mybatis使用注解开发的全部示例
19+
- feature_mybatis_annotation_one_many --> mybatis使用注解进行一对一、一对多开发
20+
21+
### kingboy-springboot-ddd
22+
- 端口
23+
- 8080
24+
- 分支功能
25+
- master --> DDD的项目尝试
26+
27+
### kingboy-springboot-file
28+
- 端口
29+
- 8080
30+
- 分支功能
31+
- master --> 演示使用SpringBoot进行文件上传下载
32+
33+
34+
### kingboy-springboot-mq(rabbit)
35+
- 端口
36+
- 8080
37+
- 分支功能
38+
- feature_rabbit --> SpringBoot与RabbitMQ的使用示例
39+
40+
### kingboy-springboot-security
41+
- 端口
42+
- 8080
43+
- 分支功能
44+
- master --> SpringBoot使用Security进行认证授权
45+
46+
### kingboy-springboot-web
47+
- 端口
48+
- 8080
49+
- 分支功能
50+
- feature_restful --> 如何正确的使用Restful风格url
51+
- feature_jsonview --> 如何返回同一实体的不同视图
52+
- feature_validate --> 如何进行参数校验,以及校验分组使用
53+
- feature_swagger --> 优雅的使用Swagger,项目最佳实践

build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
group 'com.kingboy'
2+
version '1.0-SNAPSHOT'
3+
4+
apply plugin: 'java'
5+
6+
sourceCompatibility = 1.8
7+
8+
repositories {
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
testCompile (
14+
"junit:junit:4.11"
15+
)
16+
}

common/.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#gralde build
2+
build
3+
gradle
4+
.gradle
5+
classes
6+
gradlew*
7+
8+
#idea
9+
.idea
10+
*.iml
11+
out
12+
13+
#java
14+
*.class
15+
*.jar
16+
*.war
17+
*.ear
18+
19+
#log

common/build.gradle

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
group 'com.kingboy'
2+
version '1.0'
3+
4+
apply plugin: 'java'
5+
apply plugin: 'maven-publish'
6+
7+
sourceCompatibility = 1.8
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
ext {
14+
orikaVersion = '1.5.2'
15+
fastJsonVersion = '1.2.41'
16+
lombokVersion = '1.16.18'
17+
langVersion='3.7'
18+
collectsVersion='3.2.2'
19+
beanUtilsVersion='1.9.3'
20+
ioVersion='2.6'
21+
}
22+
23+
dependencies {
24+
25+
compile (
26+
"ma.glasnost.orika:orika-core:$orikaVersion",
27+
"org.projectlombok:lombok:$lombokVersion",
28+
"com.alibaba:fastjson:$fastJsonVersion",
29+
"org.apache.commons:commons-lang3:$langVersion",
30+
"commons-collections:commons-collections:$collectsVersion",
31+
"commons-beanutils:commons-beanutils:$beanUtilsVersion",
32+
"commons-io:commons-io:$ioVersion"
33+
)
34+
35+
}
36+
37+
//打包源码
38+
task sourceJar(type: Jar) {
39+
from sourceSets.main.allJava
40+
}
41+
42+
publishing {
43+
publications {
44+
maven(MavenPublication) {
45+
//指定group/artifact/version信息,可以不填。默认使用项目group/name/version作为groupId/artifactId/version
46+
groupId project.group
47+
artifactId project.name
48+
version project.version
49+
//如果是war包填写components.web,如果是jar包填写components.java
50+
from components.java
51+
52+
//配置上传源码
53+
artifact sourceJar {
54+
classifier "sources"
55+
}
56+
57+
}
58+
}
59+
repositories {
60+
maven {
61+
//指定要上传的maven私服仓库
62+
url = "http://jenkins.maxrocky.com:8081/repository/maxrocky/"
63+
//认证用户和密码
64+
credentials {
65+
username 'admin'
66+
password 'admin123'
67+
}
68+
}
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package com.kingboy.common.utils.date;
2+
3+
import java.time.LocalDate;
4+
import java.time.LocalDateTime;
5+
import java.time.Period;
6+
import java.time.ZoneId;
7+
import java.time.format.DateTimeFormatter;
8+
import java.time.temporal.ChronoUnit;
9+
import java.time.temporal.TemporalUnit;
10+
import java.util.Date;
11+
12+
/**
13+
14+
* @date 2017/7/23 下午9:16
15+
* @desc java8日期工具.
16+
*/
17+
public final class LocalDateTimeUtils {
18+
19+
//获取当前时间的LocalDateTime对象
20+
//LocalDateTime.now();
21+
22+
//根据年月日构建LocalDateTime
23+
//LocalDateTime.of();
24+
25+
//比较日期先后
26+
//LocalDateTime.now().isBefore(),
27+
//LocalDateTime.now().isAfter(),
28+
29+
//Date转换为LocalDateTime
30+
public static LocalDateTime convertDateToLDT(Date date) {
31+
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
32+
}
33+
34+
//LocalDateTime转换为Date
35+
public static Date convertLDTToDate(LocalDateTime time) {
36+
return Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
37+
}
38+
39+
40+
//获取指定日期的毫秒
41+
public static Long getMilliByTime(LocalDateTime time) {
42+
return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
43+
}
44+
45+
//获取指定日期的秒
46+
public static Long getSecondsByTime(LocalDateTime time) {
47+
return time.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
48+
}
49+
50+
//获取指定时间的指定格式
51+
public static String formatTime(LocalDateTime time, String pattern) {
52+
return time.format(DateTimeFormatter.ofPattern(pattern));
53+
}
54+
55+
//获取当前时间的指定格式
56+
public static String formatNow(String pattern) {
57+
return formatTime(LocalDateTime.now(), pattern);
58+
}
59+
60+
//日期加上一个数,根据field不同加不同值,field为ChronoUnit.*
61+
public static LocalDateTime plus(LocalDateTime time, long number, TemporalUnit field) {
62+
return time.plus(number, field);
63+
}
64+
65+
//日期减去一个数,根据field不同减不同值,field参数为ChronoUnit.*
66+
public static LocalDateTime minu(LocalDateTime time, long number, TemporalUnit field) {
67+
return time.minus(number, field);
68+
}
69+
70+
/**
71+
* 获取两个日期的差 field参数为ChronoUnit.*
72+
* @param startTime
73+
* @param endTime
74+
* @param field 单位(年月日时分秒)
75+
* @return
76+
*/
77+
public static long betweenTwoTime(LocalDateTime startTime, LocalDateTime endTime, ChronoUnit field) {
78+
Period period = Period.between(LocalDate.from(startTime), LocalDate.from(endTime));
79+
if (field == ChronoUnit.YEARS) {
80+
return period.getYears();
81+
}
82+
if (field == ChronoUnit.MONTHS) {
83+
return period.getYears() * 12 + period.getMonths();
84+
}
85+
return field.between(startTime, endTime);
86+
}
87+
88+
//获取一天的开始时间,2017,7,22 00:00
89+
public static LocalDateTime getDayStart(LocalDateTime time) {
90+
return time.withHour(0)
91+
.withMinute(0)
92+
.withSecond(0)
93+
.withNano(0);
94+
}
95+
96+
//获取一天的结束时间,2017,7,22 23:59:59.999999999
97+
public static LocalDateTime getDayEnd(LocalDateTime time) {
98+
return time.withHour(23)
99+
.withMinute(59)
100+
.withSecond(59)
101+
.withNano(999999999);
102+
}
103+
104+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.kingboy.common.utils.json;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.JSONObject;
5+
import com.alibaba.fastjson.TypeReference;
6+
7+
import java.util.List;
8+
import java.util.Map;
9+
import java.util.Objects;
10+
11+
/**
12+
13+
* @date 2017/7/26 下午12:07
14+
* @desc Json工具.
15+
*/
16+
public final class JsonUtils {
17+
18+
/**
19+
* json串转换为对象
20+
* @param json
21+
* @param clazz
22+
* @param <T>
23+
* @return
24+
*/
25+
public static <T> T jsonToBean(String json, Class<T> clazz) {
26+
return JSON.parseObject(json, clazz);
27+
}
28+
29+
/**
30+
* 对象转换为json
31+
* @param object
32+
* @return
33+
*/
34+
public static String beanToJson(Object object) {
35+
return JSON.toJSONString(object);
36+
}
37+
38+
/**
39+
* 对象转换为json,可以带上date的格式化
40+
* @param object
41+
* @return
42+
*/
43+
public static String beanToJson(Object object, String dateFormat) {
44+
if (Objects.isNull(dateFormat) || "".equals(dateFormat)) {
45+
return JSON.toJSONString(object);
46+
}
47+
return JSON.toJSONStringWithDateFormat(object, dateFormat);
48+
49+
}
50+
51+
/**
52+
* json返回List
53+
* @param arrayJson
54+
* @param clazz
55+
* @param <T>
56+
* @return
57+
*/
58+
public static <T> List<T> jsonToList(String arrayJson, Class<T> clazz, String dateFormat) {
59+
String temp = JSONObject.DEFFAULT_DATE_FORMAT;
60+
if (!"".equals(dateFormat) && dateFormat != null) {
61+
JSONObject.DEFFAULT_DATE_FORMAT = dateFormat;
62+
}
63+
List<T> list = JSON.parseArray(arrayJson, clazz);
64+
JSONObject.DEFFAULT_DATE_FORMAT = temp;
65+
return list;
66+
}
67+
68+
/**
69+
* 反序列化Map
70+
* @param mapJson
71+
* @param <K>
72+
* @param <V>
73+
* @return
74+
*/
75+
public static <K, V> Map jsonMap(String mapJson, Class<K> keyType, Class<V> valueType) {
76+
return JSON.parseObject(mapJson, new TypeReference<Map<K, V>>() { });
77+
}
78+
}

0 commit comments

Comments
 (0)