Skip to content

Commit

Permalink
重构:Sample 模块,以及一些重复依赖的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzhqiang committed Feb 12, 2020
1 parent aca9b17 commit fe8bca0
Show file tree
Hide file tree
Showing 46 changed files with 357 additions and 998 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@


## 简介
- [x] helper 模块:JVM 辅助工具,项目依赖包含 [Guava][1] 库(谷歌开源的辅助工具),[Config][2] 库(加载默认参数常量)。
- [x] helper-jre 模块:JVM 辅助工具,项目依赖包含 [Guava][1] 库(谷歌开源的辅助工具),[Config][2] 库(加载默认参数常量)。
- [ ] helper-javafx 模块:JavaFX 辅助工具,利用 [RxJavaFx][3] 库实现 MVVM 架构更方便。
- [x] data 模块:提供数据相关辅助工具,使用 [Guice][5] 依赖注入实例。
- [x] data-api 模块:定义基本的数据接口,比如 `Repository``Paging` 等。
- [x] data-redis 模块:简化 [Jedis][4] 的使用。
- [x] data-ebean 模块:简化 [EBean][6] 的使用(主要基于 MySQL 数据库)。
- [x] data-cassandra 模块:简化 [Cassandra-driver-core][7] 的使用。
- [x] data-elasticsearch 模块:简化 Elastic Search 客户端 [rest][8] 的使用。
- [x] helper-data 模块:提供数据相关辅助工具,使用 [Guice][5] 依赖注入实例。
- [x] helper-data-api 模块:定义基本的数据接口,比如 `Repository``Paging` 等。
- [x] helper-data-redis 模块:简化 [Jedis][4] 的使用。
- [x] helper-data-ebean 模块:简化 [EBean][6] 的使用(主要基于 MySQL 数据库)。
- [x] helper-data-cassandra 模块:简化 [Cassandra-driver-core][7] 的使用。
- [x] helper-data-elasticsearch 模块:简化 Elastic Search 客户端 [rest][8] 的使用。

## 使用
1. 访问 [jitpack.io][9],添加本仓库的 URL 以获取依赖。
2. 参考 [samples][10] 模块,获取更详细的使用方法。
2. 参考 [helper-sample][10] 模块,获取更详细的使用方法。


# Licenses
Expand Down Expand Up @@ -50,4 +50,4 @@
[7]:https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core
[8]:https://mvnrepository.com/artifact/org.elasticsearch.client/rest
[9]:https://jitpack.io/#mrzhqiang/helper
[10]:https://github.com/mrzhqiang/helper/tree/master/samples
[10]:https://github.com/mrzhqiang/helper/tree/master/helper-sample
17 changes: 16 additions & 1 deletion helper-data/helper-data-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,33 @@

<parent>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<version>2020.1.0</version>
</parent>

<artifactId>helper-data-api</artifactId>
<name>Helper Data API</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-jre</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand Down
3 changes: 2 additions & 1 deletion helper-data/helper-data-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<parent>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<version>2020.1.0</version>
</parent>

Expand All @@ -21,6 +21,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
3 changes: 2 additions & 1 deletion helper-data/helper-data-ebean/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<parent>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<version>2020.1.0</version>
</parent>

Expand All @@ -21,6 +21,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
4 changes: 2 additions & 2 deletions helper-data/helper-data-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<parent>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<version>2020.1.0</version>
</parent>

Expand All @@ -21,6 +21,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -36,7 +37,6 @@
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>rest</artifactId>
<version>${elasticsearch-client.version}</version>
</dependency>
</dependencies>
</project>
3 changes: 2 additions & 1 deletion helper-data/helper-data-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<parent>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<version>2020.1.0</version>
</parent>

Expand All @@ -21,6 +21,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
21 changes: 6 additions & 15 deletions helper-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,18 @@
<version>2020.1.0</version>
</parent>

<artifactId>helper-data-parent</artifactId>
<artifactId>helper-data</artifactId>
<packaging>pom</packaging>
<name>Helper Data</name>

<modules>
<module>api</module>
<module>redis</module>
<module>ebean</module>
<module>cassandra</module>
<module>elasticsearch</module>
<module>helper-data-api</module>
<module>helper-data-redis</module>
<module>helper-data-ebean</module>
<module>helper-data-cassandra</module>
<module>helper-data-elasticsearch</module>
</modules>

<dependencies>
<dependency>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
7 changes: 1 addition & 6 deletions helper-javafx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper</artifactId>
<artifactId>helper-jre</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.reactivex.rxjava2</groupId>
Expand Down
10 changes: 5 additions & 5 deletions helper/READEME.md → helper-jre/READEME.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# helper
[![Release](https://jitpack.io/v/mrzhqiang/helper.svg)](https://jitpack.io/#mrzhqiang/helper)
# helper-jre
[![Release](https://jitpack.io/v/mrzhqiang/helper/helper-jre.svg)](https://jitpack.io/#mrzhqiang/helper/helper-jre)

`helper` 是 JVM 辅助工具。
`helper-jre` 是 JVM 辅助工具。


## 简介
Expand All @@ -13,7 +13,7 @@
- [x] UserNames:账号检测。

## 使用
参考单元测试或 [samples][10] 模块。
参考单元测试或 [sample][10] 模块。


[10]:https://github.com/mrzhqiang/helper/tree/master/samples
[10]:https://github.com/mrzhqiang/helper/tree/master/helper-sample
6 changes: 1 addition & 5 deletions helper/pom.xml → helper-jre/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>2020.1.0</version>
</parent>

<artifactId>helper</artifactId>
<artifactId>helper-jre</artifactId>
<name>Helper JRE</name>

<dependencies>
Expand All @@ -22,10 +22,6 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 15 additions & 19 deletions helper/pom-old.xml → helper-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,48 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.mrzhqiang.helper</groupId>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-parent</artifactId>
<version>2018.1.2</version>
<version>2020.1.0</version>
</parent>

<artifactId>helper</artifactId>
<name>Helper</name>
<url>https://github.com/mrzhqiang/helper</url>
<artifactId>helper-sample</artifactId>
<name>Helper Sample</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>com.github.mrzhqiang</groupId>
<artifactId>helper-javafx</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<artifactId>maven-source-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
65 changes: 65 additions & 0 deletions helper-sample/src/main/java/helper/sample/DatesSample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package helper.sample;

import helper.Dates;
import helper.javafx.Applications;
import helper.javafx.model.Console;
import io.reactivex.Observable;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.rxjavafx.schedulers.JavaFxScheduler;
import io.reactivex.schedulers.Schedulers;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class DatesSample extends Application {

@FXML Label systemTimeLabel;
@FXML Label startTimeLabel;
@FXML Label durationLabel;
@FXML TextArea consoleTextArea;

public static void main(String[] args) {
launch(args);
}

private Date startTime;
private final Console console = new Console();

private final CompositeDisposable disposable = new CompositeDisposable();

@Override
public void start(Stage primaryStage) {
Applications.start(this, primaryStage);
}

@Override public void stop() {
disposable.clear();
Schedulers.shutdown();
}

@FXML void initialize() {
startTime = new Date();
disposable.add(console.observe().subscribe(consoleTextArea::appendText));
disposable.add(Observable.interval(1, 1, TimeUnit.SECONDS)
.map(aLong -> Dates.format(new Date()))
.observeOn(JavaFxScheduler.platform())
.doOnNext(systemTime -> systemTimeLabel.setText(systemTime))
.map(Dates::parse)
.map(date -> String.format("解析启动:%s", date))
.doOnNext(console::log)
.map(s -> String.format("%s | %s",
Dates.formatDate(startTime), Dates.formatTime(startTime)))
.doOnNext(s -> startTimeLabel.setText(s))
.map(s -> Dates.untilNow(startTime))
.doOnNext(s -> durationLabel.setText(s))
.map(s -> startTime.toInstant().minus(1, ChronoUnit.DAYS))
.map(instant -> Dates.display(Date.from(instant)))
.map(s -> String.format("显示昨天:%s%s", s, System.lineSeparator()))
.subscribe(console::log));
}
}
Loading

0 comments on commit fe8bca0

Please sign in to comment.