Skip to content

Commit 8c14c75

Browse files
authored
Merge pull request #20 from jkazama/v3.1
v3.1.1
2 parents fd70d0f + 310d483 commit 8c14c75

100 files changed

Lines changed: 1488 additions & 2301 deletions

File tree

Some content is hidden

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

.devcontainer/compose.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
services:
22
workspace-backend:
3-
build: .
4-
image: jkazama/ddd-java
5-
command: sleep infinity
3+
image: mcr.microsoft.com/vscode/devcontainers/java:17-jdk-bullseye
4+
init: true
5+
command: /bin/sh -c "while sleep 1000; do :; done"
66
extra_hosts:
77
- 'host.docker.internal:host-gateway'
88
volumes:
99
- ..:/home/vscode/workspace:cached
1010
- ~/.ssh:/home/vscode/.ssh
11-
- backend-gradle-cache:/home/vscode/.gradle
12-
- backend-extensions:/home/vscode/.vscode-server/extensions
13-
- backend-extensions-insiders:/home/vscode/.vscode-server/-extensions-insiders
1411
working_dir: /home/vscode/workspace
15-
16-
volumes:
17-
backend-gradle-cache:
18-
backend-extensions:
19-
backend-extensions-insiders:

.devcontainer/devcontainer.json

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,31 @@
66
],
77
"service": "workspace-backend",
88
"shutdownAction": "stopCompose",
9-
"settings": {
10-
"editor.formatOnSave": true,
11-
"editor.codeActionsOnSave": {
12-
"source.organizeImports": true
13-
},
14-
"java.jdt.ls.java.home": "/docker-java-home",
15-
"java.format.settings.profile": "Google",
16-
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
9+
"customizations": {
10+
"vscode": {
11+
"settings": {
12+
"editor.formatOnSave": true,
13+
"editor.codeActionsOnSave": {
14+
"source.organizeImports": true
15+
},
16+
"java.jdt.ls.java.home": "/docker-java-home",
17+
"java.format.settings.profile": "Google",
18+
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml"
19+
},
20+
"extensions": [
21+
"mhutchie.git-graph",
22+
"mikestead.dotenv",
23+
"EditorConfig.EditorConfig",
24+
"vscjava.vscode-lombok",
25+
"vscjava.vscode-java-pack",
26+
"vscjava.vscode-gradle",
27+
"vscjava.vscode-spring-boot-dashboard",
28+
"pivotal.vscode-spring-boot",
29+
"pivotal.vscode-boot-dev-pack"
30+
]
31+
}
1732
},
1833
"workspaceFolder": "/home/vscode/workspace",
19-
"extensions": [
20-
"mhutchie.git-graph",
21-
"eamodio.gitlens",
22-
"mikestead.dotenv",
23-
"EditorConfig.EditorConfig",
24-
"vscjava.vscode-lombok",
25-
"vscjava.vscode-java-pack",
26-
"vscjava.vscode-gradle",
27-
"vscjava.vscode-spring-boot-dashboard",
28-
"pivotal.vscode-spring-boot",
29-
"pivotal.vscode-boot-dev-pack"
30-
],
3134
"forwardPorts": [
3235
8080
3336
],

README.md

Lines changed: 86 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,138 @@
1-
[English Version](https://github.com/jkazama/ddd-java/tree/en)
2-
31
ddd-java
42
---
53

6-
## はじめに
7-
8-
JSUG(日本Springユーザ会)の下記勉強会向けのサンプル実装です。
9-
10-
- 2014/11/27 「SpringBootを用いたドメイン駆動設計」
4+
### Preface
115

12-
> Spring Boot 3 の利用に伴い実装コードを Java17 へ切り替えています。 Java7 での実装コードを確認したいときは 1.x ブランチを参照してください。
6+
It is DDD sample implementation from [Spring Boot](http://projects.spring.io/spring-boot/).
7+
It is not a framework, This is a simple example of the implementation based on Evans's DDD.
138

14-
本サンプルでは[SpringBoot](http://projects.spring.io/spring-boot/)[Lombok](http://projectlombok.org/)を利用してドメインモデリングの実装例を示します。実際に2007年くらいから現在に至るまで現場で利用されている実装アプローチなので、参考例の一つとしてみてもらえればと思います。
15-
※JavaDocに記載をしていますが、サンプルに特化させているので実際の製品コードが含まれているわけではありません。
169

17-
認証含む、より実践的な実装サンプルについては[sample-boot-hibernate](https://github.com/jkazama/sample-boot-hibernate)を参照してください。
18-
またUI側の実装サンプルについては[sample-ui-vue](https://github.com/jkazama/sample-ui-vue) / [sample-ui-react](https://github.com/jkazama/sample-ui-react)を参照してください。
10+
#### Concept of Layering
1911

20-
### レイヤリングの考え方
12+
It is three levels of famous models, but considers the infrastructure layer as cross-sectional interpretation.
2113

22-
オーソドックスな三層モデルですが、横断的な解釈としてインフラ層を考えます。
14+
| Layer | |
15+
| -------------- | ----------------------------------------------------------- |
16+
| UI | Receive use case request |
17+
| Application | Use case processing (including the outside resource access) |
18+
| Domain | Pure domain logic (not depend on the outside resource) |
19+
| Infrastructure | DI container and ORM, various libraries |
2320

24-
- UI層 - ユースケース処理を公開(必要に応じてリモーティングや外部サイトを連携)
25-
- アプリケーション層 - ユースケース処理を集約(外部リソースアクセスも含む)
26-
- ドメイン層 - 純粋なドメイン処理(外部リソースに依存しない)
27-
- インフラ層 - DIコンテナやORM、各種ライブラリ、メッセージリソースの提供
21+
Usually perform public handling of UI layer using Thymeleaf, but this sample assume use of different types of clients and perform only API offer in RESTfulAPI.
2822

29-
UI層の公開処理は通常Thymeleafを用いて行いますが、本サンプルでは異なる種類のクライアント利用を想定してRESTfulAPIでの公開を前提とします。(API利用前提のサーバ解釈)
23+
#### Use policy of Spring Boot
3024

31-
### SpringBootの利用方針
25+
Spring Boot is available for various usage, but uses it in the following policy with this sample.
3226

33-
SpringBootは様々な利用方法が可能ですが、本サンプルでは以下のポリシーを用います。
27+
- Use standard definitions as much as possible, such as DB settings.
28+
- The configuration file uses yml. do not use xml files for Bean definition.
29+
- The exception handling defines it in a endpoint (RestErrorAdvice).
3430

35-
- DBの設定等、なるべく標準定義をそのまま利用する。
36-
- 設定ファイルはymlを用いる。Bean定義にxml等の拡張ファイルは用いない。
37-
- ライブラリ化しないので@Beanによる将来拡張性を考慮せずにクラス単位でBeanベタ登録。
38-
- 例外処理は終端(RestErrorAdvice/RestErrorCotroller)で定義。
39-
- サンプル用途
31+
#### Use policy of Java coding
4032

41-
### Javaコーディング方針
33+
- Java17 over
34+
- Use Lombok positively and remove diffuseness.
35+
- The name as possible briefly.
36+
- Do not abuse the interface.
37+
- DTO becoming a part of the domain defines it in an internal class.
4238

43-
Java17以上を前提としていますが、従来のJavaで推奨される記法と異なっている観点も多いです。
44-
以下は保守性を意識した上で簡潔さを重視した方針となっています。
39+
#### Resource
4540

46-
- Lombokを積極的に利用して冗長さを排除
47-
- 名称も既存クラスと重複しても良いのでなるべく簡潔に
48-
- インターフェースの濫用をしない
49-
- ドメインの一部となるDTOなどは内部クラスで表現
50-
51-
### パッケージ構成
52-
53-
パッケージ/リソース構成については以下を参照してください。
41+
Refer to the following for the package / resource constitution.
5442

5543
```
5644
main
5745
java
5846
sample
59-
context … インフラ層
60-
controller … UI層
61-
model … ドメイン層
62-
usecase … アプリケーション層
63-
util … 汎用ユーティリティ
64-
- Application.java … 実行可能な起動クラス
47+
context … Infrastructure Layer
48+
controller … UI Layer
49+
model … Domain Layer
50+
usecase … Application Layer
51+
util … Utilities
52+
- Application.java … Bootstrap
6553
resources
66-
- application.yml … 設定ファイル
67-
- messages-validation.properties … 例外メッセージリソース
68-
- messages.properties … メッセージリソース
54+
- application.yml … Spring Boot Configuration
55+
- messages-validation.properties … Validation Message Resources
56+
- messages.properties … Label Message Resources
6957
```
7058

71-
## サンプルユースケース
72-
73-
サンプルユースケースとしては以下を想定します。
74-
75-
- **口座残高100万円を持つ顧客**が出金依頼(発生 T, 受渡 T + 3)をする。
76-
- **システム**が営業日を進める。
77-
- **システム**が出金依頼を確定する。(確定させるまでは依頼取消行為を許容)
78-
- **システム**が受渡日を迎えた入出金キャッシュフローを口座残高へ反映する。
79-
80-
## 動作確認
81-
82-
サンプルはGradleを利用しているので、IDEやコンソールで動作確認を行うことができます。
83-
84-
### VSCode
85-
86-
開発IDEである[VSCode](https://code.visualstudio.com)で本サンプルを利用するには、事前に以下の手順を行っておく必要があります。
59+
## Use Case
8760

88-
- Java17以上のインストール
89-
- DevContainer 利用時は不要
90-
- Java / Lombok / Gradle の Extension 追加
61+
Consider the following as a sample use case.
9162

92-
次の手順で本サンプルをプロジェクト化してください。
63+
- A customer with an account balance requests withdrawal. (Event T, Delivery T + 3)
64+
- The system closes the withdrawal request. (Allows cancellation of request until closing)
65+
- The system sets the business day to the forward day.
66+
- The system reflects the cash flow on delivery date to the account balance.
9367

94-
1. ダウンロードした*java-ddd*ディレクトリ直下へコンソールで移動
95-
1. 「code .」で起動
68+
### Getting Started
9669

97-
次の手順で本サンプルを実行してください。
70+
This sample uses [Gradle](https://gradle.org/), you can check the operation without trouble with IDE and a console.
9871

99-
1. 左サイドメニューの「Run And Debug」で *Run ddd-java* を選択肢て実行
100-
1. *DEBUG CONSOLE*タブに「Started Application」という文字列が出力されればポート8080で起動が完了
72+
#### Server Start (VSCode DevContainer)
10173

102-
> Linux や WSL 上で DevContainer を立ち上げて確認することも可能です。 Open Container のダイアログが出たらOKを押下してください。
103-
> DevContainer の起動に失敗する時はポート重複が無いか、vscode-remote-release の [#7303](https://github.com/microsoft/vscode-remote-release/issues/7303) の問題を踏んでいないか確認してください。 #7303 の問題だった時は Extension の DevContainers を `v0.251.0` へ下げることでうまくいくことがあります。
74+
It is necessary to do the following step.
10475

105-
### STS(Eclipse)
76+
- Check Instablled Docker.
77+
- Check Instablled VSCode with DevContainer Extension.
10678

107-
開発IDEである[STS](https://spring.io/tools/sts)で本サンプルを利用するには、事前に以下の手順を行っておく必要があります。
108-
※EclipseにSpringIDEプラグインを入れても可
79+
Do the preparations for this sample in the next step.
10980

110-
- Java17以上のインストール
111-
- [Lombok](http://projectlombok.org/download.html)のパッチ当て(.jarを実行してインストーラの指示通りに実行)
81+
1. You move to the cloned *ddd-java* directory.
82+
1. Run command `code .`.
83+
1. Choose *Open Container*
11284

113-
次の手順で本サンプルをプロジェクト化してください。
114-
※コンパイルエラーになる時は、Javaコンパイラの設定が17以上になっているかを確認してください。
85+
Do the server start in the next step.
11586

116-
1. パッケージエクスプローラから「右クリック -> Import」で*Exsisting Project into Workspace*を選択して*Next*を押下
117-
1. *Root folder:*にダウンロードした*ddd-java*ディレクトリを指定して*Build Model*を押下
118-
1. *Project**ddd-java*を選択後、*Finish*を押下(依存ライブラリダウンロードがここで行われます)
87+
1. Open VSCode "Run And Debug".
88+
1. Choose `Run ddd-java`.
89+
1. If console show "Started Application", start is completed in port 8080.
90+
1. Run command `curl http://localhost:8080/actuator/health`
11991

120-
次の手順で本サンプルを実行してください。
92+
#### Server Start (Console)
12193

122-
1. *Application.java*に対し「右クリック -> Run As -> Java Application」
123-
1. *Console*タブに「Started Application」という文字列が出力されればポート8080で起動が完了
94+
Run application from a console of Windows / Mac in Gradle.
12495

125-
### コンソール
96+
It is necessary to do the following step.
12697

127-
Windows/Macのコンソールから実行するにはGradleのコンソールコマンドで行います。
128-
※事前にJava17以上のインストールが必要です。
98+
- Check Instablled JDK17+.
12999

130-
1. ダウンロードした*java-ddd*ディレクトリ直下へコンソールで移動
131-
1. 「gradlew bootRun」を実行
132-
1. コンソールに「Started Application」という文字列が出力されればポート8080で起動が完了
100+
Do the server start in the next step.
133101

102+
1. You move to the cloned *ddd-java* directory.
103+
1. Run command `gradlew bootRun`.
104+
1. If console show "Started Application", start is completed in port 8080
105+
1. Run command `curl http://localhost:8080/actuator/health`
134106

135-
### ブラウザ
107+
### Check Use Case
136108

137-
STSまたはコンソールで8080ポートでサーバを立ち上げた後、ブラウザから下記URLへアクセスする事でRESTfulAPIの実行テストを実施可能です。
138-
※本来なら情報更新系処理はPOSTで取り扱うべきですが、UIの無いデモ用にGETでのアクセスを許容しています。
139-
※パラメタは?key=valueで繋げて渡してください。
109+
After launching the server on port 8080, you can test execution of RESTful API by accessing the following URL from console.
140110

141-
顧客向けユースケース
111+
#### Customer Use Case
142112

143-
- http://localhost:8080/asset/cio/withdraw
144-
- 振込出金依頼 [accountId: sample, currency: JPY, absAmount: 出金依頼金額]
145-
- http://localhost:8080/asset/cio/unprocessedOut
146-
- 振込出金依頼未処理検索
113+
- `curl -X POST -H "Content-Type: application/json" -d '{"accountId" : "sample" , "currency" : "JPY", "absAmount": 1000}' http://localhost:8080/asset/cio/withdraw`
114+
- Request for withdrawal.
115+
- `curl 'http://localhost:8080/asset/cio/unprocessedOut'`
116+
- Search for outstanding withdrawal requests
147117

148-
社内向けユースケース
118+
#### Internal Use Case
149119

150-
- http://localhost:8080/admin/asset/cio
151-
- 振込入出金依頼検索 [updFromDay: 更新From(yyyyMMdd), updToDay: 更新To(yyyyMMdd)]
120+
- `curl 'http://localhost:8080/admin/asset/cio?updFromDay=yyyy-MM-dd&updToDay=yyyy-MM-dd'`
121+
- Search for deposit and withdrawal requests.
122+
- Please set real date for upd\*Day
152123

153-
バッチ向けユースケース
124+
#### Batch Use Case
154125

155-
- http://localhost:8080/system/job/daily/processDay
156-
- 営業日を進める(単純日回しのみ)
157-
- http://localhost:8080/system/job/daily/closingCashOut
158-
- 当営業日の出金依頼を締める
159-
- http://localhost:8080/system/job/daily/realizeCashflow
160-
- 入出金キャッシュフローを実現する(受渡日に残高へ反映)
126+
- `curl -X POST http://localhost:8080/system/job/daily/closingCashOut`
127+
- Close the withdrawal request.
128+
- `curl -X POST http://localhost:8080/system/job/daily/processDay`
129+
- Set the business day to the next day.
130+
- `curl -X POST http://localhost:8080/system/job/daily/realizeCashflow`
131+
- Realize cash flow. (Reflected to the balance on the delivery date)
161132

133+
> Please execute according to the business day appropriately
162134
163-
## License
135+
### License
164136

165-
本サンプルのライセンスはコード含めて全て*MIT License*です。
166-
Spring Bootを用いたプロジェクト立ち上げ時のベース実装サンプルとして気軽にご利用ください。
137+
The license of this sample includes a code and is all *MIT License*.
138+
Use it as a base implementation at the time of the project start using Spring Boot.

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.0.1'
3+
id 'org.springframework.boot' version '3.1.1'
44
id 'io.spring.dependency-management' version '1.1.0'
55
}
66

7-
version = "3.0.1"
7+
version = "3.1.1"
88

99
javadoc {
1010
options.addBooleanOption('Xdoclint:none', true)
@@ -38,5 +38,5 @@ dependencies {
3838
}
3939

4040
wrapper {
41-
gradleVersion = "7.6"
41+
gradleVersion = "8.1.1"
4242
}

gradle/wrapper/gradle-wrapper.jar

502 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)