@k2works/claude-code-booster 3.5.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +42 -42
- package/bin/claude-code-booster +90 -90
- package/lib/assets/.claude/README.md +239 -239
- package/lib/assets/.claude/scripts/generate-inception-deck.mjs +911 -911
- package/lib/assets/.claude/settings.json +11 -11
- package/lib/assets/.claude/skills/ai-agent-guidelines/SKILL.md +111 -111
- package/lib/assets/.claude/skills/analyzing-architecture/SKILL.md +83 -83
- package/lib/assets/.claude/skills/analyzing-business/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-data-model/SKILL.md +77 -77
- package/lib/assets/.claude/skills/analyzing-domain-model/SKILL.md +117 -88
- package/lib/assets/.claude/skills/analyzing-inception-deck/SKILL.md +84 -84
- package/lib/assets/.claude/skills/analyzing-non-functional/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-operation/SKILL.md +95 -95
- package/lib/assets/.claude/skills/analyzing-requirements/SKILL.md +91 -91
- package/lib/assets/.claude/skills/analyzing-tech-stack/SKILL.md +101 -101
- package/lib/assets/.claude/skills/analyzing-test-strategy/SKILL.md +89 -89
- package/lib/assets/.claude/skills/analyzing-ui-design/SKILL.md +80 -80
- package/lib/assets/.claude/skills/analyzing-usecases/SKILL.md +72 -72
- package/lib/assets/.claude/skills/creating-adr/SKILL.md +113 -113
- package/lib/assets/.claude/skills/developing-backend/SKILL.md +100 -100
- package/lib/assets/.claude/skills/developing-frontend/SKILL.md +93 -93
- package/lib/assets/.claude/skills/developing-release/SKILL.md +120 -120
- package/lib/assets/.claude/skills/generating-slides/SKILL.md +94 -94
- package/lib/assets/.claude/skills/git-commit/SKILL.md +81 -81
- package/lib/assets/.claude/skills/killing-processes/SKILL.md +44 -44
- package/lib/assets/.claude/skills/operating-backup/SKILL.md +59 -59
- package/lib/assets/.claude/skills/operating-cicd/SKILL.md +54 -54
- package/lib/assets/.claude/skills/operating-deploy/SKILL.md +67 -67
- package/lib/assets/.claude/skills/operating-docs/SKILL.md +219 -219
- package/lib/assets/.claude/skills/operating-provision/SKILL.md +77 -77
- package/lib/assets/.claude/skills/operating-setup/SKILL.md +63 -63
- package/lib/assets/.claude/skills/orchestrating-analysis/SKILL.md +104 -104
- package/lib/assets/.claude/skills/orchestrating-development/SKILL.md +162 -161
- package/lib/assets/.claude/skills/orchestrating-operation/SKILL.md +158 -158
- package/lib/assets/.claude/skills/orchestrating-project/SKILL.md +144 -144
- package/lib/assets/.claude/skills/planning-releases/SKILL.md +119 -119
- package/lib/assets/.claude/skills/syncing-github-project/SKILL.md +151 -151
- package/lib/assets/.claude/skills/tracking-progress/SKILL.md +91 -91
- package/lib/assets/.claude/skills/validating-iteration-plan/SKILL.md +215 -215
- package/lib/assets/.devcontainer/devcontainer.json +34 -34
- package/lib/assets/.env.example +17 -17
- package/lib/assets/.gitattributes +4 -4
- package/lib/assets/.github/workflows/docker-publish.yml +77 -77
- package/lib/assets/.github/workflows/mkdocs.yml +39 -39
- package/lib/assets/AGENTS.md +94 -94
- package/lib/assets/CLAUDE.md +183 -183
- package/lib/assets/README.md +254 -254
- package/lib/assets/docker-compose.yml +33 -33
- package/lib/assets/docs/adr/index.md +10 -10
- package/lib/assets/docs/article/functional-desgin-ppp/all/01-immutability-and-data-transformation.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/all/02-function-composition.md +519 -519
- package/lib/assets/docs/article/functional-desgin-ppp/all/03-polymorphism.md +537 -537
- package/lib/assets/docs/article/functional-desgin-ppp/all/04-data-validation.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/all/05-property-based-testing.md +320 -320
- package/lib/assets/docs/article/functional-desgin-ppp/all/06-tdd-and-functional.md +498 -498
- package/lib/assets/docs/article/functional-desgin-ppp/all/07-composite-pattern.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/all/08-decorator-pattern.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/all/09-adapter-pattern.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/all/10-strategy-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/all/11-command-pattern.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/12-visitor-pattern.md +322 -322
- package/lib/assets/docs/article/functional-desgin-ppp/all/13-abstract-factory-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/all/14-abstract-server-pattern.md +365 -365
- package/lib/assets/docs/article/functional-desgin-ppp/all/15-gossiping-bus-drivers.md +156 -156
- package/lib/assets/docs/article/functional-desgin-ppp/all/16-payroll-system.md +178 -178
- package/lib/assets/docs/article/functional-desgin-ppp/all/17-video-rental-system.md +312 -312
- package/lib/assets/docs/article/functional-desgin-ppp/all/18-concurrency-system.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/all/19-wa-tor-simulation.md +286 -286
- package/lib/assets/docs/article/functional-desgin-ppp/all/20-pattern-interactions.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/all/21-best-practices.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/all/22-oo-to-fp-migration.md +337 -337
- package/lib/assets/docs/article/functional-desgin-ppp/all/index.md +388 -388
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/01-immutability-and-data-transformation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/02-function-composition.md +380 -380
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/03-polymorphism.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/04-clojure-spec.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/05-property-based-testing.md +352 -352
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/06-tdd-in-functional.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/07-composite-pattern.md +529 -529
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/08-decorator-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/09-adapter-pattern.md +399 -399
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/10-strategy-pattern.md +485 -485
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/11-command-pattern.md +566 -566
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/12-visitor-pattern.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/13-abstract-factory-pattern.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/14-abstract-server-pattern.md +462 -462
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/15-gossiping-bus-drivers.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/16-payroll-system.md +401 -401
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/17-video-rental-system.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/18-concurrency-system.md +475 -475
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/19-wator-simulation.md +739 -739
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/20-pattern-interactions.md +567 -567
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/21-best-practices.md +518 -518
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/22-oo-to-fp-migration.md +532 -532
- package/lib/assets/docs/article/functional-desgin-ppp/clojure/index.md +241 -241
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/01-immutability-and-data-transformation.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/02-function-composition.md +374 -374
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/03-polymorphism.md +375 -375
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/04-data-validation.md +195 -195
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/05-property-based-testing.md +268 -268
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/06-tdd-and-fp.md +294 -294
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/07-effects-and-pure-functions.md +164 -164
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/08-error-handling-strategies.md +168 -168
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/09-io-and-external-systems.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/10-concurrency-patterns.md +269 -269
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/11-command-pattern.md +148 -148
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/12-visitor-pattern.md +176 -176
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/13-abstract-factory-pattern.md +604 -604
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/14-abstract-server-pattern.md +729 -729
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/15-gossiping-bus-drivers.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/16-payroll-system.md +420 -420
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/17-video-rental-system.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/18-concurrency-system.md +466 -466
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/19-wator-simulation.md +523 -523
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/20-pattern-interactions.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/21-best-practices.md +340 -340
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/22-oo-to-fp-migration.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/elixir/index.md +248 -248
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/01-immutability-and-data-transformation.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/02-function-composition.md +452 -452
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/03-polymorphism.md +495 -495
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/04-data-validation.md +416 -416
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/05-property-based-testing.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/06-tdd-functional.md +687 -687
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/07-composite-pattern.md +442 -442
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/08-decorator-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/09-adapter-pattern.md +479 -479
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/10-strategy-pattern.md +427 -427
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/11-command-pattern.md +428 -428
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/12-visitor-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/13-abstract-factory-pattern.md +309 -309
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/14-abstract-server-pattern.md +596 -596
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/15-gossiping-bus-drivers.md +355 -355
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/16-payroll-system.md +350 -350
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/17-video-rental-system.md +414 -414
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/18-concurrency-system.md +367 -367
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/19-wator-simulation.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/20-pattern-interactions.md +291 -291
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/21-best-practices.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/22-oo-to-fp-migration.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/fsharp/index.md +274 -274
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/01-immutability-and-data-transformation.md +298 -298
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/02-function-composition.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/03-polymorphism.md +362 -362
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/04-data-validation.md +257 -257
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/05-property-based-testing.md +254 -254
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/06-tdd-functional.md +283 -283
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/07-composite-pattern.md +395 -395
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/08-decorator-pattern.md +319 -319
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/09-adapter-pattern.md +382 -382
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/10-strategy-pattern.md +287 -287
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/11-command-pattern.md +303 -303
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/12-visitor-pattern.md +326 -326
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/13-abstract-factory-pattern.md +332 -332
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/14-abstract-server-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/15-gossiping-bus-drivers.md +177 -177
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/16-payroll-system.md +219 -219
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/17-video-rental-system.md +244 -244
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/18-concurrency-system.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/19-wator-simulation.md +438 -438
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/20-pattern-interactions.md +325 -325
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/21-best-practices.md +403 -403
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/22-oo-to-fp-migration.md +469 -469
- package/lib/assets/docs/article/functional-desgin-ppp/haskell/index.md +174 -174
- package/lib/assets/docs/article/functional-desgin-ppp/index.md +90 -90
- package/lib/assets/docs/article/functional-desgin-ppp/rust/01-immutability-and-data-transformation.md +450 -450
- package/lib/assets/docs/article/functional-desgin-ppp/rust/02-function-composition.md +463 -463
- package/lib/assets/docs/article/functional-desgin-ppp/rust/03-polymorphism.md +425 -425
- package/lib/assets/docs/article/functional-desgin-ppp/rust/04-data-validation.md +273 -273
- package/lib/assets/docs/article/functional-desgin-ppp/rust/05-property-based-testing.md +247 -247
- package/lib/assets/docs/article/functional-desgin-ppp/rust/06-tdd-and-functional.md +841 -841
- package/lib/assets/docs/article/functional-desgin-ppp/rust/07-composite-pattern.md +384 -384
- package/lib/assets/docs/article/functional-desgin-ppp/rust/08-decorator-pattern.md +383 -383
- package/lib/assets/docs/article/functional-desgin-ppp/rust/09-adapter-pattern.md +339 -339
- package/lib/assets/docs/article/functional-desgin-ppp/rust/10-strategy-pattern.md +331 -331
- package/lib/assets/docs/article/functional-desgin-ppp/rust/11-command-pattern.md +356 -356
- package/lib/assets/docs/article/functional-desgin-ppp/rust/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/rust/13-abstract-factory-pattern.md +361 -361
- package/lib/assets/docs/article/functional-desgin-ppp/rust/14-abstract-server-pattern.md +392 -392
- package/lib/assets/docs/article/functional-desgin-ppp/rust/15-gossiping-bus-drivers.md +300 -300
- package/lib/assets/docs/article/functional-desgin-ppp/rust/16-payroll-system.md +297 -297
- package/lib/assets/docs/article/functional-desgin-ppp/rust/17-video-rental-system.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/18-concurrency-system.md +315 -315
- package/lib/assets/docs/article/functional-desgin-ppp/rust/19-wator-simulation.md +311 -311
- package/lib/assets/docs/article/functional-desgin-ppp/rust/20-pattern-interactions.md +304 -304
- package/lib/assets/docs/article/functional-desgin-ppp/rust/21-best-practices.md +336 -336
- package/lib/assets/docs/article/functional-desgin-ppp/rust/22-oo-to-fp-migration.md +349 -349
- package/lib/assets/docs/article/functional-desgin-ppp/rust/index.md +243 -243
- package/lib/assets/docs/article/functional-desgin-ppp/scala/01-immutability-and-data-transformation.md +328 -328
- package/lib/assets/docs/article/functional-desgin-ppp/scala/02-function-composition.md +348 -348
- package/lib/assets/docs/article/functional-desgin-ppp/scala/03-polymorphism.md +357 -357
- package/lib/assets/docs/article/functional-desgin-ppp/scala/04-data-validation.md +364 -364
- package/lib/assets/docs/article/functional-desgin-ppp/scala/05-property-based-testing.md +515 -515
- package/lib/assets/docs/article/functional-desgin-ppp/scala/06-tdd-functional.md +557 -557
- package/lib/assets/docs/article/functional-desgin-ppp/scala/07-composite-pattern.md +363 -363
- package/lib/assets/docs/article/functional-desgin-ppp/scala/08-decorator-pattern.md +327 -327
- package/lib/assets/docs/article/functional-desgin-ppp/scala/09-adapter-pattern.md +517 -517
- package/lib/assets/docs/article/functional-desgin-ppp/scala/10-strategy-pattern.md +441 -441
- package/lib/assets/docs/article/functional-desgin-ppp/scala/11-command-pattern.md +407 -407
- package/lib/assets/docs/article/functional-desgin-ppp/scala/12-visitor-pattern.md +379 -379
- package/lib/assets/docs/article/functional-desgin-ppp/scala/13-abstract-factory-pattern.md +398 -398
- package/lib/assets/docs/article/functional-desgin-ppp/scala/14-abstract-server-pattern.md +476 -476
- package/lib/assets/docs/article/functional-desgin-ppp/scala/15-gossiping-bus-drivers.md +391 -391
- package/lib/assets/docs/article/functional-desgin-ppp/scala/16-payroll-system.md +342 -342
- package/lib/assets/docs/article/functional-desgin-ppp/scala/17-video-rental-system.md +324 -324
- package/lib/assets/docs/article/functional-desgin-ppp/scala/18-concurrency-system.md +730 -730
- package/lib/assets/docs/article/functional-desgin-ppp/scala/19-wator-simulation.md +624 -624
- package/lib/assets/docs/article/functional-desgin-ppp/scala/20-pattern-interactions.md +512 -512
- package/lib/assets/docs/article/functional-desgin-ppp/scala/21-best-practices.md +433 -433
- package/lib/assets/docs/article/functional-desgin-ppp/scala/22-oo-to-fp-migration.md +688 -688
- package/lib/assets/docs/article/functional-desgin-ppp/scala/index.md +243 -243
- package/lib/assets/docs/article/getting-start-tdd/clojure/01-todo-list-and-first-test.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/clojure/02-fake-it-and-triangulation.md +162 -162
- package/lib/assets/docs/article/getting-start-tdd/clojure/03-obvious-implementation-and-refactoring.md +135 -135
- package/lib/assets/docs/article/getting-start-tdd/clojure/04-version-control-and-conventional-commits.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/clojure/05-package-management-and-static-analysis.md +299 -299
- package/lib/assets/docs/article/getting-start-tdd/clojure/06-task-runner-and-ci-cd.md +241 -241
- package/lib/assets/docs/article/getting-start-tdd/clojure/07-protocols-and-records.md +131 -131
- package/lib/assets/docs/article/getting-start-tdd/clojure/08-multimethods-and-design-patterns.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/clojure/09-namespaces-and-module-design.md +127 -127
- package/lib/assets/docs/article/getting-start-tdd/clojure/10-higher-order-functions-and-composition.md +114 -114
- package/lib/assets/docs/article/getting-start-tdd/clojure/11-persistent-data-and-pipeline.md +138 -138
- package/lib/assets/docs/article/getting-start-tdd/clojure/12-error-handling-and-spec.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/clojure/index.md +65 -65
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter01.md +232 -232
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter02.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter03.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter04.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter05.md +256 -256
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter06.md +195 -195
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter07.md +214 -214
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter08.md +249 -249
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter09.md +174 -174
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter10.md +166 -166
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter11.md +192 -192
- package/lib/assets/docs/article/getting-start-tdd/csharp/chapter12.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/csharp/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/elixir/01-todo-list-and-first-test.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/elixir/02-fake-it-and-triangulation.md +95 -95
- package/lib/assets/docs/article/getting-start-tdd/elixir/03-obvious-implementation-and-refactoring.md +109 -109
- package/lib/assets/docs/article/getting-start-tdd/elixir/04-version-control-and-conventional-commits.md +96 -96
- package/lib/assets/docs/article/getting-start-tdd/elixir/05-package-management-and-static-analysis.md +88 -88
- package/lib/assets/docs/article/getting-start-tdd/elixir/06-task-runner-and-ci-cd.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/elixir/07-structs-and-protocols.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/elixir/08-pattern-matching-and-guards.md +108 -108
- package/lib/assets/docs/article/getting-start-tdd/elixir/09-module-design-and-behaviours.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/elixir/10-higher-order-functions-and-pipeline.md +178 -178
- package/lib/assets/docs/article/getting-start-tdd/elixir/11-stream-and-lazy-evaluation.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/elixir/12-error-handling-and-with.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/elixir/index.md +35 -35
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter01.md +202 -202
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter02.md +246 -246
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter03.md +218 -218
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter04.md +179 -179
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter05.md +267 -267
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter06.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter07.md +161 -161
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter08.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter09.md +222 -222
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter10.md +189 -189
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter11.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/fsharp/chapter12.md +215 -215
- package/lib/assets/docs/article/getting-start-tdd/fsharp/index.md +71 -71
- package/lib/assets/docs/article/getting-start-tdd/go/01-todo-list-and-first-test.md +213 -213
- package/lib/assets/docs/article/getting-start-tdd/go/02-fake-it-and-triangulation.md +302 -302
- package/lib/assets/docs/article/getting-start-tdd/go/03-obvious-implementation-and-refactoring.md +339 -339
- package/lib/assets/docs/article/getting-start-tdd/go/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/go/05-package-management-and-static-analysis.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/go/06-task-runner-and-ci-cd.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/go/07-encapsulation-and-polymorphism.md +394 -394
- package/lib/assets/docs/article/getting-start-tdd/go/08-design-patterns.md +422 -422
- package/lib/assets/docs/article/getting-start-tdd/go/09-solid-principles-and-module-design.md +400 -400
- package/lib/assets/docs/article/getting-start-tdd/go/10-higher-order-functions-and-composition.md +226 -226
- package/lib/assets/docs/article/getting-start-tdd/go/11-immutable-data-and-pipeline.md +296 -296
- package/lib/assets/docs/article/getting-start-tdd/go/12-error-handling-and-type-safety.md +411 -411
- package/lib/assets/docs/article/getting-start-tdd/go/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/haskell/01-todo-list-and-first-test.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/haskell/02-fake-it-and-triangulation.md +337 -337
- package/lib/assets/docs/article/getting-start-tdd/haskell/03-obvious-implementation-and-refactoring.md +257 -257
- package/lib/assets/docs/article/getting-start-tdd/haskell/04-version-control-and-conventional-commits.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/haskell/05-package-management-and-static-analysis.md +313 -313
- package/lib/assets/docs/article/getting-start-tdd/haskell/06-task-runner-and-ci-cd.md +309 -309
- package/lib/assets/docs/article/getting-start-tdd/haskell/07-algebraic-data-types-and-type-classes.md +412 -412
- package/lib/assets/docs/article/getting-start-tdd/haskell/08-pattern-matching-and-guards.md +390 -390
- package/lib/assets/docs/article/getting-start-tdd/haskell/09-module-design-and-smart-constructors.md +461 -461
- package/lib/assets/docs/article/getting-start-tdd/haskell/10-higher-order-functions-and-currying.md +434 -434
- package/lib/assets/docs/article/getting-start-tdd/haskell/11-function-composition-and-point-free.md +392 -392
- package/lib/assets/docs/article/getting-start-tdd/haskell/12-monad-and-error-handling.md +631 -631
- package/lib/assets/docs/article/getting-start-tdd/haskell/index.md +49 -49
- package/lib/assets/docs/article/getting-start-tdd/index.md +93 -93
- package/lib/assets/docs/article/getting-start-tdd/integration/01-language-overview.md +375 -375
- package/lib/assets/docs/article/getting-start-tdd/integration/02-test-framework-comparison.md +349 -349
- package/lib/assets/docs/article/getting-start-tdd/integration/03-tdd-pattern-comparison.md +445 -445
- package/lib/assets/docs/article/getting-start-tdd/integration/04-type-system-comparison.md +409 -409
- package/lib/assets/docs/article/getting-start-tdd/integration/05-dev-environment-comparison.md +330 -330
- package/lib/assets/docs/article/getting-start-tdd/integration/06-learning-roadmap.md +290 -290
- package/lib/assets/docs/article/getting-start-tdd/integration/index.md +69 -69
- package/lib/assets/docs/article/getting-start-tdd/java/01-todo-list-and-first-test.md +234 -234
- package/lib/assets/docs/article/getting-start-tdd/java/02-fake-it-and-triangulation.md +261 -261
- package/lib/assets/docs/article/getting-start-tdd/java/03-obvious-implementation-and-refactoring.md +185 -185
- package/lib/assets/docs/article/getting-start-tdd/java/04-version-control-and-conventional-commits.md +115 -115
- package/lib/assets/docs/article/getting-start-tdd/java/05-package-management-and-static-analysis.md +382 -382
- package/lib/assets/docs/article/getting-start-tdd/java/06-task-runner-and-ci-cd.md +272 -272
- package/lib/assets/docs/article/getting-start-tdd/java/07-encapsulation-and-polymorphism.md +626 -626
- package/lib/assets/docs/article/getting-start-tdd/java/08-design-patterns.md +393 -393
- package/lib/assets/docs/article/getting-start-tdd/java/09-solid-principles-and-module-design.md +310 -310
- package/lib/assets/docs/article/getting-start-tdd/java/10-higher-order-functions-and-composition.md +188 -188
- package/lib/assets/docs/article/getting-start-tdd/java/11-immutable-data-and-pipeline.md +167 -167
- package/lib/assets/docs/article/getting-start-tdd/java/12-error-handling-and-type-safety.md +205 -205
- package/lib/assets/docs/article/getting-start-tdd/java/index.md +61 -61
- package/lib/assets/docs/article/getting-start-tdd/node/01-todo-list-and-first-test.md +244 -244
- package/lib/assets/docs/article/getting-start-tdd/node/02-fake-it-and-triangulation.md +262 -262
- package/lib/assets/docs/article/getting-start-tdd/node/03-obvious-implementation-and-refactoring.md +169 -169
- package/lib/assets/docs/article/getting-start-tdd/node/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/node/05-package-management-and-static-analysis.md +314 -314
- package/lib/assets/docs/article/getting-start-tdd/node/06-task-runner-and-ci-cd.md +235 -235
- package/lib/assets/docs/article/getting-start-tdd/node/07-encapsulation-and-polymorphism.md +327 -327
- package/lib/assets/docs/article/getting-start-tdd/node/08-design-patterns.md +322 -322
- package/lib/assets/docs/article/getting-start-tdd/node/09-solid-principles-and-module-design.md +285 -285
- package/lib/assets/docs/article/getting-start-tdd/node/10-higher-order-functions-and-composition.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/node/11-immutable-data-and-pipeline.md +207 -207
- package/lib/assets/docs/article/getting-start-tdd/node/12-error-handling-and-type-safety.md +295 -295
- package/lib/assets/docs/article/getting-start-tdd/node/index.md +56 -56
- package/lib/assets/docs/article/getting-start-tdd/php/01-todo-list-and-first-test.md +259 -259
- package/lib/assets/docs/article/getting-start-tdd/php/02-fake-it-and-triangulation.md +200 -200
- package/lib/assets/docs/article/getting-start-tdd/php/03-obvious-implementation-and-refactoring.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/php/04-version-control-and-conventional-commits.md +141 -141
- package/lib/assets/docs/article/getting-start-tdd/php/05-package-management-and-static-analysis.md +410 -410
- package/lib/assets/docs/article/getting-start-tdd/php/06-task-runner-and-ci-cd.md +321 -321
- package/lib/assets/docs/article/getting-start-tdd/php/07-encapsulation-and-polymorphism.md +372 -372
- package/lib/assets/docs/article/getting-start-tdd/php/08-design-patterns.md +453 -453
- package/lib/assets/docs/article/getting-start-tdd/php/09-solid-principles-and-module-design.md +460 -460
- package/lib/assets/docs/article/getting-start-tdd/php/10-higher-order-functions-and-composition.md +182 -182
- package/lib/assets/docs/article/getting-start-tdd/php/11-immutable-data-and-pipeline.md +266 -266
- package/lib/assets/docs/article/getting-start-tdd/php/12-error-handling-and-type-safety.md +308 -308
- package/lib/assets/docs/article/getting-start-tdd/php/index.md +84 -84
- package/lib/assets/docs/article/getting-start-tdd/python/01-todo-list-and-first-test.md +201 -201
- package/lib/assets/docs/article/getting-start-tdd/python/02-fake-it-and-triangulation.md +247 -247
- package/lib/assets/docs/article/getting-start-tdd/python/03-obvious-implementation-and-refactoring.md +199 -199
- package/lib/assets/docs/article/getting-start-tdd/python/04-version-control-and-conventional-commits.md +87 -87
- package/lib/assets/docs/article/getting-start-tdd/python/05-package-management-and-static-analysis.md +274 -274
- package/lib/assets/docs/article/getting-start-tdd/python/06-task-runner-and-ci-cd.md +190 -190
- package/lib/assets/docs/article/getting-start-tdd/python/07-encapsulation-and-polymorphism.md +208 -208
- package/lib/assets/docs/article/getting-start-tdd/python/08-design-patterns.md +172 -172
- package/lib/assets/docs/article/getting-start-tdd/python/09-solid-principles-and-module-design.md +130 -130
- package/lib/assets/docs/article/getting-start-tdd/python/10-higher-order-functions-and-composition.md +122 -122
- package/lib/assets/docs/article/getting-start-tdd/python/11-immutable-data-and-pipeline.md +116 -116
- package/lib/assets/docs/article/getting-start-tdd/python/12-error-handling-and-type-safety.md +126 -126
- package/lib/assets/docs/article/getting-start-tdd/python/index.md +55 -55
- package/lib/assets/docs/article/getting-start-tdd/ruby/01-todo-list-and-first-test.md +231 -231
- package/lib/assets/docs/article/getting-start-tdd/ruby/02-fake-it-and-triangulation.md +238 -238
- package/lib/assets/docs/article/getting-start-tdd/ruby/03-obvious-implementation-and-refactoring.md +228 -228
- package/lib/assets/docs/article/getting-start-tdd/ruby/04-version-control-and-conventional-commits.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/ruby/05-package-management-and-static-analysis.md +287 -287
- package/lib/assets/docs/article/getting-start-tdd/ruby/06-task-runner-and-ci-cd.md +248 -248
- package/lib/assets/docs/article/getting-start-tdd/ruby/07-encapsulation-and-polymorphism.md +279 -279
- package/lib/assets/docs/article/getting-start-tdd/ruby/08-design-patterns.md +329 -329
- package/lib/assets/docs/article/getting-start-tdd/ruby/09-solid-principles-and-module-design.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/ruby/10-higher-order-functions-and-composition.md +175 -175
- package/lib/assets/docs/article/getting-start-tdd/ruby/11-immutable-data-and-pipeline.md +237 -237
- package/lib/assets/docs/article/getting-start-tdd/ruby/12-error-handling-and-type-safety.md +398 -398
- package/lib/assets/docs/article/getting-start-tdd/ruby/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/rust/01-todo-list-and-first-test.md +211 -211
- package/lib/assets/docs/article/getting-start-tdd/rust/02-fake-it-and-triangulation.md +264 -264
- package/lib/assets/docs/article/getting-start-tdd/rust/03-obvious-implementation-and-refactoring.md +233 -233
- package/lib/assets/docs/article/getting-start-tdd/rust/04-version-control-and-conventional-commits.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/rust/05-package-management-and-static-analysis.md +212 -212
- package/lib/assets/docs/article/getting-start-tdd/rust/06-task-runner-and-ci-cd.md +164 -164
- package/lib/assets/docs/article/getting-start-tdd/rust/07-encapsulation-and-polymorphism.md +142 -142
- package/lib/assets/docs/article/getting-start-tdd/rust/08-design-patterns.md +145 -145
- package/lib/assets/docs/article/getting-start-tdd/rust/09-solid-principles-and-module-design.md +110 -110
- package/lib/assets/docs/article/getting-start-tdd/rust/10-higher-order-functions-and-composition.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/rust/11-immutable-data-and-pipeline.md +105 -105
- package/lib/assets/docs/article/getting-start-tdd/rust/12-error-handling-and-type-safety.md +112 -112
- package/lib/assets/docs/article/getting-start-tdd/rust/index.md +83 -83
- package/lib/assets/docs/article/getting-start-tdd/scala/01-todo-list-and-first-test.md +111 -111
- package/lib/assets/docs/article/getting-start-tdd/scala/02-fake-it-and-triangulation.md +107 -107
- package/lib/assets/docs/article/getting-start-tdd/scala/03-obvious-implementation-and-refactoring.md +99 -99
- package/lib/assets/docs/article/getting-start-tdd/scala/04-version-control-and-conventional-commits.md +123 -123
- package/lib/assets/docs/article/getting-start-tdd/scala/05-package-management-and-static-analysis.md +196 -196
- package/lib/assets/docs/article/getting-start-tdd/scala/06-task-runner-and-ci-cd.md +186 -186
- package/lib/assets/docs/article/getting-start-tdd/scala/07-case-classes-and-traits.md +139 -139
- package/lib/assets/docs/article/getting-start-tdd/scala/08-pattern-matching-and-sealed-traits.md +106 -106
- package/lib/assets/docs/article/getting-start-tdd/scala/09-packages-and-module-design.md +75 -75
- package/lib/assets/docs/article/getting-start-tdd/scala/10-higher-order-functions-and-composition.md +104 -104
- package/lib/assets/docs/article/getting-start-tdd/scala/11-collections-and-lazy-evaluation.md +94 -94
- package/lib/assets/docs/article/getting-start-tdd/scala/12-error-handling-and-type-safety.md +92 -92
- package/lib/assets/docs/article/getting-start-tdd/scala/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/all/index.md +404 -404
- package/lib/assets/docs/article/grokking-concurrency/all/part-1-ch02-sequential.md +554 -554
- package/lib/assets/docs/article/grokking-concurrency/all/part-2-ch04-05-threads.md +469 -469
- package/lib/assets/docs/article/grokking-concurrency/all/part-3-ch06-multitasking.md +520 -520
- package/lib/assets/docs/article/grokking-concurrency/all/part-4-ch07-parallel-patterns.md +420 -420
- package/lib/assets/docs/article/grokking-concurrency/all/part-5-ch08-09-synchronization.md +510 -510
- package/lib/assets/docs/article/grokking-concurrency/all/part-6-ch10-11-nonblocking-io.md +435 -435
- package/lib/assets/docs/article/grokking-concurrency/all/part-7-ch12-async.md +465 -465
- package/lib/assets/docs/article/grokking-concurrency/all/part-8-ch13-mapreduce.md +377 -377
- package/lib/assets/docs/article/grokking-concurrency/clojure/index.md +116 -116
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-2.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-3.md +122 -122
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-4.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-5.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-6.md +89 -89
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-7.md +100 -100
- package/lib/assets/docs/article/grokking-concurrency/clojure/part-8.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/csharp/index.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-1.md +97 -97
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-2.md +123 -123
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-3.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-4.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-6.md +61 -61
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-7.md +84 -84
- package/lib/assets/docs/article/grokking-concurrency/csharp/part-8.md +92 -92
- package/lib/assets/docs/article/grokking-concurrency/fsharp/index.md +65 -65
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-1.md +80 -80
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-2.md +103 -103
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-3.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-5.md +104 -104
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-6.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-7.md +121 -121
- package/lib/assets/docs/article/grokking-concurrency/fsharp/part-8.md +107 -107
- package/lib/assets/docs/article/grokking-concurrency/haskell/index.md +248 -248
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-1.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-2.md +96 -96
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-3.md +91 -91
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-4.md +106 -106
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-5.md +99 -99
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-6.md +95 -95
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-7.md +111 -111
- package/lib/assets/docs/article/grokking-concurrency/haskell/part-8.md +118 -118
- package/lib/assets/docs/article/grokking-concurrency/index.md +66 -66
- package/lib/assets/docs/article/grokking-concurrency/java/index.md +102 -102
- package/lib/assets/docs/article/grokking-concurrency/java/part-1.md +308 -308
- package/lib/assets/docs/article/grokking-concurrency/java/part-2.md +334 -334
- package/lib/assets/docs/article/grokking-concurrency/java/part-3.md +221 -221
- package/lib/assets/docs/article/grokking-concurrency/java/part-4.md +213 -213
- package/lib/assets/docs/article/grokking-concurrency/java/part-5.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/java/part-6.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/java/part-7.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/java/part-8.md +101 -101
- package/lib/assets/docs/article/grokking-concurrency/python/index.md +313 -313
- package/lib/assets/docs/article/grokking-concurrency/python/part-1.md +239 -239
- package/lib/assets/docs/article/grokking-concurrency/python/part-2.md +418 -418
- package/lib/assets/docs/article/grokking-concurrency/python/part-3.md +227 -227
- package/lib/assets/docs/article/grokking-concurrency/python/part-4.md +299 -299
- package/lib/assets/docs/article/grokking-concurrency/python/part-5.md +315 -315
- package/lib/assets/docs/article/grokking-concurrency/python/part-6.md +297 -297
- package/lib/assets/docs/article/grokking-concurrency/python/part-7.md +314 -314
- package/lib/assets/docs/article/grokking-concurrency/python/part-8.md +360 -360
- package/lib/assets/docs/article/grokking-concurrency/rust/index.md +270 -270
- package/lib/assets/docs/article/grokking-concurrency/rust/part-1.md +108 -108
- package/lib/assets/docs/article/grokking-concurrency/rust/part-2.md +120 -120
- package/lib/assets/docs/article/grokking-concurrency/rust/part-3.md +126 -126
- package/lib/assets/docs/article/grokking-concurrency/rust/part-4.md +175 -175
- package/lib/assets/docs/article/grokking-concurrency/rust/part-5.md +158 -158
- package/lib/assets/docs/article/grokking-concurrency/rust/part-6.md +94 -94
- package/lib/assets/docs/article/grokking-concurrency/rust/part-7.md +133 -133
- package/lib/assets/docs/article/grokking-concurrency/rust/part-8.md +155 -155
- package/lib/assets/docs/article/grokking-concurrency/scala/index.md +69 -69
- package/lib/assets/docs/article/grokking-concurrency/scala/part-1.md +78 -78
- package/lib/assets/docs/article/grokking-concurrency/scala/part-2.md +112 -112
- package/lib/assets/docs/article/grokking-concurrency/scala/part-3.md +93 -93
- package/lib/assets/docs/article/grokking-concurrency/scala/part-4.md +110 -110
- package/lib/assets/docs/article/grokking-concurrency/scala/part-5.md +119 -119
- package/lib/assets/docs/article/grokking-concurrency/scala/part-6.md +83 -83
- package/lib/assets/docs/article/grokking-concurrency/scala/part-7.md +131 -131
- package/lib/assets/docs/article/grokking-concurrency/scala/part-8.md +129 -129
- package/lib/assets/docs/article/grokkingfp/all/index.md +368 -368
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch01-fp-introduction.md +530 -530
- package/lib/assets/docs/article/grokkingfp/all/part-1-ch02-pure-functions.md +923 -923
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch03-immutable-data.md +1128 -1128
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch04-higher-order-functions.md +1104 -1104
- package/lib/assets/docs/article/grokkingfp/all/part-2-ch05-flatmap.md +1026 -1026
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch06-option.md +785 -785
- package/lib/assets/docs/article/grokkingfp/all/part-3-ch07-either-adt.md +871 -871
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch08-io-monad.md +972 -972
- package/lib/assets/docs/article/grokkingfp/all/part-4-ch09-streams.md +926 -926
- package/lib/assets/docs/article/grokkingfp/all/part-5-ch10-concurrency.md +870 -870
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch11-application.md +715 -715
- package/lib/assets/docs/article/grokkingfp/all/part-6-ch12-testing.md +626 -626
- package/lib/assets/docs/article/grokkingfp/all/writing-plan.md +712 -712
- package/lib/assets/docs/article/grokkingfp/clojure/index.md +276 -276
- package/lib/assets/docs/article/grokkingfp/clojure/part-1.md +667 -667
- package/lib/assets/docs/article/grokkingfp/clojure/part-2.md +643 -643
- package/lib/assets/docs/article/grokkingfp/clojure/part-3.md +620 -620
- package/lib/assets/docs/article/grokkingfp/clojure/part-4.md +697 -697
- package/lib/assets/docs/article/grokkingfp/clojure/part-5.md +751 -751
- package/lib/assets/docs/article/grokkingfp/clojure/part-6.md +721 -721
- package/lib/assets/docs/article/grokkingfp/csharp/index.md +246 -246
- package/lib/assets/docs/article/grokkingfp/csharp/part-1.md +811 -811
- package/lib/assets/docs/article/grokkingfp/csharp/part-2.md +971 -971
- package/lib/assets/docs/article/grokkingfp/csharp/part-3.md +981 -981
- package/lib/assets/docs/article/grokkingfp/csharp/part-4.md +949 -949
- package/lib/assets/docs/article/grokkingfp/csharp/part-5.md +947 -947
- package/lib/assets/docs/article/grokkingfp/csharp/part-6.md +739 -739
- package/lib/assets/docs/article/grokkingfp/elixir/index.md +203 -203
- package/lib/assets/docs/article/grokkingfp/elixir/part-1.md +712 -712
- package/lib/assets/docs/article/grokkingfp/elixir/part-2.md +838 -838
- package/lib/assets/docs/article/grokkingfp/elixir/part-3.md +985 -985
- package/lib/assets/docs/article/grokkingfp/elixir/part-4.md +974 -974
- package/lib/assets/docs/article/grokkingfp/elixir/part-5.md +1286 -1286
- package/lib/assets/docs/article/grokkingfp/elixir/part-6.md +1049 -1049
- package/lib/assets/docs/article/grokkingfp/fsharp/index.md +210 -210
- package/lib/assets/docs/article/grokkingfp/fsharp/part-1.md +714 -714
- package/lib/assets/docs/article/grokkingfp/fsharp/part-2.md +961 -961
- package/lib/assets/docs/article/grokkingfp/fsharp/part-3.md +972 -972
- package/lib/assets/docs/article/grokkingfp/fsharp/part-4.md +832 -832
- package/lib/assets/docs/article/grokkingfp/fsharp/part-5.md +911 -911
- package/lib/assets/docs/article/grokkingfp/fsharp/part-6.md +922 -922
- package/lib/assets/docs/article/grokkingfp/haskell/index.md +234 -234
- package/lib/assets/docs/article/grokkingfp/haskell/part-1.md +591 -591
- package/lib/assets/docs/article/grokkingfp/haskell/part-2.md +866 -866
- package/lib/assets/docs/article/grokkingfp/haskell/part-3.md +915 -915
- package/lib/assets/docs/article/grokkingfp/haskell/part-4.md +878 -878
- package/lib/assets/docs/article/grokkingfp/haskell/part-5.md +845 -845
- package/lib/assets/docs/article/grokkingfp/haskell/part-6.md +844 -844
- package/lib/assets/docs/article/grokkingfp/index.md +143 -143
- package/lib/assets/docs/article/grokkingfp/java/index.md +211 -211
- package/lib/assets/docs/article/grokkingfp/java/part-1.md +648 -648
- package/lib/assets/docs/article/grokkingfp/java/part-2.md +675 -675
- package/lib/assets/docs/article/grokkingfp/java/part-3.md +672 -672
- package/lib/assets/docs/article/grokkingfp/java/part-4.md +771 -771
- package/lib/assets/docs/article/grokkingfp/java/part-5.md +959 -959
- package/lib/assets/docs/article/grokkingfp/java/part-6.md +1328 -1328
- package/lib/assets/docs/article/grokkingfp/python/index.md +258 -258
- package/lib/assets/docs/article/grokkingfp/python/part-1.md +443 -443
- package/lib/assets/docs/article/grokkingfp/python/part-2.md +958 -958
- package/lib/assets/docs/article/grokkingfp/python/part-3.md +1004 -1004
- package/lib/assets/docs/article/grokkingfp/python/part-4.md +765 -765
- package/lib/assets/docs/article/grokkingfp/python/part-5.md +747 -747
- package/lib/assets/docs/article/grokkingfp/python/part-6.md +861 -861
- package/lib/assets/docs/article/grokkingfp/ruby/index.md +330 -330
- package/lib/assets/docs/article/grokkingfp/ruby/part-1.md +755 -755
- package/lib/assets/docs/article/grokkingfp/ruby/part-2.md +938 -938
- package/lib/assets/docs/article/grokkingfp/ruby/part-3.md +946 -946
- package/lib/assets/docs/article/grokkingfp/ruby/part-4.md +921 -921
- package/lib/assets/docs/article/grokkingfp/ruby/part-5.md +908 -908
- package/lib/assets/docs/article/grokkingfp/ruby/part-6.md +1412 -1412
- package/lib/assets/docs/article/grokkingfp/rust/index.md +242 -242
- package/lib/assets/docs/article/grokkingfp/rust/part-1.md +634 -634
- package/lib/assets/docs/article/grokkingfp/rust/part-2.md +1060 -1060
- package/lib/assets/docs/article/grokkingfp/rust/part-3.md +994 -994
- package/lib/assets/docs/article/grokkingfp/rust/part-4.md +573 -573
- package/lib/assets/docs/article/grokkingfp/rust/part-5.md +705 -705
- package/lib/assets/docs/article/grokkingfp/rust/part-6.md +508 -508
- package/lib/assets/docs/article/grokkingfp/scala/index.md +171 -171
- package/lib/assets/docs/article/grokkingfp/scala/part-1.md +543 -543
- package/lib/assets/docs/article/grokkingfp/scala/part-2.md +946 -946
- package/lib/assets/docs/article/grokkingfp/scala/part-3.md +919 -919
- package/lib/assets/docs/article/grokkingfp/scala/part-4.md +742 -742
- package/lib/assets/docs/article/grokkingfp/scala/part-5.md +722 -722
- package/lib/assets/docs/article/grokkingfp/scala/part-6.md +867 -867
- package/lib/assets/docs/article/grokkingfp/typescript/index.md +273 -273
- package/lib/assets/docs/article/grokkingfp/typescript/part-1.md +561 -561
- package/lib/assets/docs/article/grokkingfp/typescript/part-2.md +1129 -1129
- package/lib/assets/docs/article/grokkingfp/typescript/part-3.md +842 -842
- package/lib/assets/docs/article/grokkingfp/typescript/part-4.md +1087 -1087
- package/lib/assets/docs/article/grokkingfp/typescript/part-5.md +717 -717
- package/lib/assets/docs/article/grokkingfp/typescript/part-6.md +982 -982
- package/lib/assets/docs/article/practical-database-design/index.md +121 -121
- package/lib/assets/docs/article/practical-database-design/part1/chapter01.md +288 -288
- package/lib/assets/docs/article/practical-database-design/part1/chapter02.md +518 -518
- package/lib/assets/docs/article/practical-database-design/part1/chapter03.md +557 -557
- package/lib/assets/docs/article/practical-database-design/part2/chapter04.md +924 -924
- package/lib/assets/docs/article/practical-database-design/part2/chapter05.md +1627 -1627
- package/lib/assets/docs/article/practical-database-design/part2/chapter06.md +2716 -2716
- package/lib/assets/docs/article/practical-database-design/part2/chapter07.md +2082 -2082
- package/lib/assets/docs/article/practical-database-design/part2/chapter08.md +2105 -2105
- package/lib/assets/docs/article/practical-database-design/part2/chapter09.md +2031 -2031
- package/lib/assets/docs/article/practical-database-design/part2/chapter10.md +1387 -1387
- package/lib/assets/docs/article/practical-database-design/part2/chapter11.md +1677 -1677
- package/lib/assets/docs/article/practical-database-design/part2/chapter12.md +1417 -1417
- package/lib/assets/docs/article/practical-database-design/part2/chapter13.md +1434 -1434
- package/lib/assets/docs/article/practical-database-design/part3/chapter14.md +667 -667
- package/lib/assets/docs/article/practical-database-design/part3/chapter15.md +1625 -1625
- package/lib/assets/docs/article/practical-database-design/part3/chapter16.md +1915 -1915
- package/lib/assets/docs/article/practical-database-design/part3/chapter17.md +1708 -1708
- package/lib/assets/docs/article/practical-database-design/part3/chapter18.md +2095 -2095
- package/lib/assets/docs/article/practical-database-design/part3/chapter19.md +1123 -1123
- package/lib/assets/docs/article/practical-database-design/part3/chapter20.md +1031 -1031
- package/lib/assets/docs/article/practical-database-design/part3/chapter21.md +1382 -1382
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter14-orm.md +991 -991
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter15-orm.md +1300 -1300
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter16-orm.md +1166 -1166
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter17-orm.md +1584 -1584
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter18-orm.md +1183 -1183
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter19-orm.md +1016 -1016
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter20-orm.md +1753 -1753
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter21-orm.md +1447 -1447
- package/lib/assets/docs/article/practical-database-design/part3-orm/chapter22-orm.md +1878 -1878
- package/lib/assets/docs/article/practical-database-design/part4/chapter22.md +965 -965
- package/lib/assets/docs/article/practical-database-design/part4/chapter23.md +2069 -2069
- package/lib/assets/docs/article/practical-database-design/part4/chapter24.md +2439 -2439
- package/lib/assets/docs/article/practical-database-design/part4/chapter25.md +3661 -3661
- package/lib/assets/docs/article/practical-database-design/part4/chapter26.md +2916 -2916
- package/lib/assets/docs/article/practical-database-design/part4/chapter27.md +3105 -3105
- package/lib/assets/docs/article/practical-database-design/part4/chapter28.md +2697 -2697
- package/lib/assets/docs/article/practical-database-design/part4/chapter29.md +2544 -2544
- package/lib/assets/docs/article/practical-database-design/part4/chapter30.md +2180 -2180
- package/lib/assets/docs/article/practical-database-design/part4/chapter31.md +1192 -1192
- package/lib/assets/docs/article/practical-database-design/part4/chapter32.md +2101 -2101
- package/lib/assets/docs/article/practical-database-design/part5/chapter33.md +1032 -1032
- package/lib/assets/docs/article/practical-database-design/part5/chapter34.md +1609 -1609
- package/lib/assets/docs/article/practical-database-design/part5/chapter35.md +1453 -1453
- package/lib/assets/docs/article/practical-database-design/part5/chapter36.md +1292 -1292
- package/lib/assets/docs/article/practical-database-design/part5/chapter37.md +1470 -1470
- package/lib/assets/docs/article/practical-database-design/part5/chapter38.md +1698 -1698
- package/lib/assets/docs/article/practical-database-design/part5/chapter39.md +2334 -2334
- package/lib/assets/docs/article/practical-database-design/study/study2-1.md +1693 -1693
- package/lib/assets/docs/article/practical-database-design/study/study2-2.md +1347 -1347
- package/lib/assets/docs/article/practical-database-design/study/study2-3.md +2044 -2044
- package/lib/assets/docs/article/practical-database-design/study/study2-4.md +2229 -2229
- package/lib/assets/docs/article/practical-database-design/study/study2-5.md +2418 -2418
- package/lib/assets/docs/article/practical-database-design/study/study3-1.md +2205 -2205
- package/lib/assets/docs/article/practical-database-design/study/study3-2.md +2221 -2221
- package/lib/assets/docs/article/practical-database-design/study/study3-3.md +2253 -2253
- package/lib/assets/docs/article/practical-database-design/study/study3-4.md +2106 -2106
- package/lib/assets/docs/article/practical-database-design/study/study3-5.md +2507 -2507
- package/lib/assets/docs/article/practical-database-design/study/study4-1.md +2587 -2587
- package/lib/assets/docs/article/practical-database-design/study/study4-2.md +2075 -2075
- package/lib/assets/docs/article/practical-database-design/study/study4-3.md +1805 -1805
- package/lib/assets/docs/article/practical-database-design/study/study4-4.md +1895 -1895
- package/lib/assets/docs/article/practical-database-design/study/study4-5.md +2878 -2878
- package/lib/assets/docs/assets/css/extra.css +29 -29
- package/lib/assets/docs/assets/js/extra.js +44 -44
- package/lib/assets/docs/development/index.md +39 -39
- package/lib/assets/docs/operation/index.md +11 -11
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/343/203/225/343/203/255/343/203/274.md +532 -532
- package/lib/assets/docs/reference/CodexCLIMCP/343/202/265/343/203/274/343/203/220/343/203/274/350/250/255/345/256/232/346/211/213/351/240/206.md +341 -341
- package/lib/assets/docs/reference/Java/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +581 -580
- package/lib/assets/docs/reference/SonarQube/343/203/255/343/203/274/343/202/253/343/203/253/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +642 -642
- package/lib/assets/docs/reference/TypeScript/343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/346/247/213/347/257/211/343/202/254/343/202/244/343/203/211.md +465 -465
- package/lib/assets/docs/reference/UI/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +450 -450
- package/lib/assets/docs/reference/images/Ansoff.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandBasicStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandCategorization.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandRecurutementStrategy.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BrandValue.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/BusinessActivitiy.svg +3 -3
- package/lib/assets/docs/reference/images/HRM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/MarketingStructure.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/OrganizationElemnts.svg +3 -3
- package/lib/assets/docs/reference/images/PPM.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/PositioningMap.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductLayer.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ProductMix.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/SWOT.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/TargetMarket.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ThreeGenericStrategies.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/VRIO.drawio.svg +3 -3
- package/lib/assets/docs/reference/images/ValueChain.drawio.svg +3 -3
- package/lib/assets/docs/reference/index.md +52 -52
- package/lib/assets/docs/reference//343/202/210/343/201/204/343/202/275/343/203/225/343/203/210/343/202/246/343/202/247/343/202/242/343/201/250/343/201/257.md +250 -242
- package/lib/assets/docs/reference//343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +2216 -2216
- package/lib/assets/docs/reference//343/202/244/343/203/263/343/203/225/343/203/251/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +1878 -1878
- package/lib/assets/docs/reference//343/202/250/343/202/257/343/202/271/343/203/210/343/203/252/343/203/274/343/203/240/343/203/227/343/203/255/343/202/260/343/203/251/343/203/237/343/203/263/343/202/260.md +550 -544
- package/lib/assets/docs/reference//343/202/263/343/203/274/343/203/207/343/202/243/343/203/263/343/202/260/343/201/250/343/203/206/343/202/271/343/203/210/343/202/254/343/202/244/343/203/211.md +705 -705
- package/lib/assets/docs/reference//343/203/206/343/202/271/343/203/210/346/210/246/347/225/245/343/202/254/343/202/244/343/203/211.md +1313 -1313
- package/lib/assets/docs/reference//343/203/207/343/203/274/343/202/277/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +311 -311
- package/lib/assets/docs/reference//343/203/211/343/203/241/343/202/244/343/203/263/343/203/242/343/203/207/343/203/253/350/250/255/350/250/210/343/202/254/343/202/244/343/203/211.md +599 -599
- package/lib/assets/docs/reference//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243/345/210/206/346/236/220/343/202/254/343/202/244/343/203/211.md +528 -528
- package/lib/assets/docs/reference//343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +689 -682
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/202/254/343/202/244/343/203/211.md +461 -461
- package/lib/assets/docs/reference//343/203/252/343/203/252/343/203/274/343/202/271/343/203/273/343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/350/250/210/347/224/273/343/202/254/343/202/244/343/203/211.md +580 -560
- package/lib/assets/docs/reference//343/203/255/343/202/270/343/202/253/343/203/253/343/202/267/343/203/263/343/202/255/343/203/263/343/202/260.md +1367 -1367
- package/lib/assets/docs/reference//344/274/201/346/245/255/347/265/214/345/226/266/350/253/226.md +2637 -2636
- package/lib/assets/docs/reference//347/222/260/345/242/203/345/244/211/346/225/260/347/256/241/347/220/206/343/202/254/343/202/244/343/203/211.md +665 -663
- package/lib/assets/docs/reference//350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1248 -1248
- package/lib/assets/docs/reference//350/250/200/350/252/236/345/210/245/351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +28 -0
- package/lib/assets/docs/reference//351/201/213/345/226/266/347/256/241/347/220/206.md +1482 -1482
- package/lib/assets/docs/reference//351/201/213/347/224/250/343/202/271/343/202/257/343/203/252/343/203/227/343/203/210/344/275/234/346/210/220/343/202/254/343/202/244/343/203/211.md +421 -421
- package/lib/assets/docs/reference//351/201/213/347/224/250/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +392 -392
- package/lib/assets/docs/reference//351/226/213/347/231/272/343/202/254/343/202/244/343/203/211.md +299 -299
- package/lib/assets/docs/reference//351/235/236/346/251/237/350/203/275/350/246/201/344/273/266/345/256/232/347/276/251/343/202/254/343/202/244/343/203/211.md +1236 -1236
- package/lib/assets/docs/review/index.md +5 -5
- package/lib/assets/docs/strategy/index.md +1 -1
- package/lib/assets/docs/template/ADR.md +30 -30
- package/lib/assets/docs/template/AWS/343/202/271/343/203/206/343/203/274/343/202/270/343/203/263/343/202/260/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +1366 -1366
- package/lib/assets/docs/template/AWS/343/203/227/343/203/255/343/203/200/343/202/257/343/202/267/343/203/247/343/203/263/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +634 -634
- package/lib/assets/docs/template/README.md +50 -50
- package/lib/assets/docs/template/index.md +23 -23
- package/lib/assets/docs/template//343/201/276/343/201/232/343/201/223/343/202/214/343/202/222/350/252/255/343/202/202/343/201/206/343/203/252/343/202/271/343/203/210.md +12 -12
- package/lib/assets/docs/template//343/202/242/343/203/227/343/203/252/343/202/261/343/203/274/343/202/267/343/203/247/343/203/263/351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +547 -547
- package/lib/assets/docs/template//343/202/244/343/203/206/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263/345/256/214/344/272/206/345/240/261/345/221/212/346/233/270.md +58 -58
- package/lib/assets/docs/template//343/202/244/343/203/263/343/202/273/343/203/227/343/202/267/343/203/247/343/203/263/343/203/207/343/203/203/343/202/255.md +13 -13
- package/lib/assets/docs/template//343/203/223/343/202/270/343/203/215/343/202/271/343/202/242/343/203/274/343/202/255/343/203/206/343/202/257/343/203/201/343/203/243.md +379 -379
- package/lib/assets/docs/template//344/274/201/346/245/255/345/210/206/346/236/220.md +573 -573
- package/lib/assets/docs/template//345/256/214/345/205/250/345/275/242/345/274/217/343/201/256/343/203/246/343/203/274/343/202/271/343/202/261/343/203/274/343/202/271.md +69 -68
- package/lib/assets/docs/template//350/246/201/344/273/266/345/256/232/347/276/251.md +669 -669
- package/lib/assets/docs/template//350/250/255/350/250/210.md +173 -173
- package/lib/assets/docs/template//351/226/213/347/231/272/347/222/260/345/242/203/343/202/273/343/203/203/343/203/210/343/202/242/343/203/203/343/203/227/346/211/213/351/240/206/346/233/270.md +688 -688
- package/lib/assets/gulpfile.js +25 -25
- package/lib/assets/mkdocs.yml +136 -135
- package/lib/assets/ops/docker/mkdoc/Dockerfile +19 -19
- package/lib/assets/ops/scripts/journal.js +180 -180
- package/lib/assets/ops/scripts/mkdocs.js +82 -82
- package/lib/assets/ops/scripts/release.js +431 -431
- package/lib/assets/ops/scripts/sonar_local.js +726 -726
- package/lib/assets/ops/scripts/ssh.js +190 -190
- package/lib/assets/ops/scripts/vault.js +299 -299
- package/lib/assets/package-lock.json +1653 -1653
- package/lib/assets/package.json +40 -40
- package/lib/gulpfile.js +37 -37
- package/package.json +41 -41
- package/lib/assets/.claude/agent-memory/xp-programmer/MEMORY.md +0 -6
- package/lib/assets/.claude/agent-memory/xp-programmer/project_cargo_tracker.md +0 -11
- package/lib/assets/.claude/agent-memory/xp-programmer/project_ddd_patterns.md +0 -27
- package/lib/assets/.claude/agent-memory/xp-programmer/project_us07_route_assignment.md +0 -19
|
@@ -1,1447 +1,1447 @@
|
|
|
1
|
-
# 第21章:APIサービスの実装【ORM版】
|
|
2
|
-
|
|
3
|
-
本章では、財務会計システムの API サービスを TDD で実装します。ヘキサゴナルアーキテクチャに基づき、Spring Data JPA を使用した勘定科目マスタ API、仕訳 API、残高照会 API を構築します。
|
|
4
|
-
|
|
5
|
-
## 21.1 ヘキサゴナルアーキテクチャ
|
|
6
|
-
|
|
7
|
-
### 21.1.1 Ports and Adapters パターン
|
|
8
|
-
|
|
9
|
-
ヘキサゴナルアーキテクチャは、ドメインロジックを外部の技術的関心事から分離するアーキテクチャパターンです。
|
|
10
|
-
|
|
11
|
-
```plantuml
|
|
12
|
-
@startuml
|
|
13
|
-
|
|
14
|
-
title ヘキサゴナルアーキテクチャ(JPA版)
|
|
15
|
-
|
|
16
|
-
skinparam hexagon {
|
|
17
|
-
BackgroundColor #E8F5E9
|
|
18
|
-
BorderColor #4CAF50
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
rectangle "Infrastructure (Outside)" #F5F5F5 {
|
|
22
|
-
rectangle "Web Adapter\n(REST API)" as web #BBDEFB
|
|
23
|
-
rectangle "DB Adapter\n(Spring Data JPA)" as db #BBDEFB
|
|
24
|
-
rectangle "External API\n(外部連携)" as ext #BBDEFB
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
hexagon "Application Core" as core {
|
|
28
|
-
rectangle "Domain\n(ビジネスロジック)" as domain #C8E6C9
|
|
29
|
-
rectangle "Application\n(ユースケース)" as app #C8E6C9
|
|
30
|
-
|
|
31
|
-
rectangle "Input Port\n(UseCase IF)" as inport #FFF9C4
|
|
32
|
-
rectangle "Output Port\n(Repository IF)" as outport #FFF9C4
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
web --> inport : Controller
|
|
36
|
-
inport --> app
|
|
37
|
-
app --> domain
|
|
38
|
-
app --> outport
|
|
39
|
-
outport --> db : JpaRepository
|
|
40
|
-
ext --> inport
|
|
41
|
-
|
|
42
|
-
note bottom of core
|
|
43
|
-
ドメインロジックは
|
|
44
|
-
外部技術から独立
|
|
45
|
-
(JPA/MyBatis に非依存)
|
|
46
|
-
end note
|
|
47
|
-
|
|
48
|
-
@enduml
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### 21.1.2 アーキテクチャの利点
|
|
52
|
-
|
|
53
|
-
| 利点 | 説明 |
|
|
54
|
-
|------|------|
|
|
55
|
-
| **テスト容易性** | ドメインロジックを単独でテスト可能 |
|
|
56
|
-
| **技術独立性** | DB、フレームワークの変更が容易 |
|
|
57
|
-
| **可読性** | 責務が明確に分離される |
|
|
58
|
-
| **保守性** | 変更の影響範囲が限定される |
|
|
59
|
-
|
|
60
|
-
## 21.2 アーキテクチャ構造(JPA版)
|
|
61
|
-
|
|
62
|
-
### 21.2.1 パッケージ構成
|
|
63
|
-
|
|
64
|
-
```plantuml
|
|
65
|
-
@startuml
|
|
66
|
-
|
|
67
|
-
title パッケージ構成(JPA版)
|
|
68
|
-
|
|
69
|
-
package "com.example.accounting" {
|
|
70
|
-
|
|
71
|
-
package "domain" {
|
|
72
|
-
package "model" {
|
|
73
|
-
class Account
|
|
74
|
-
class Journal
|
|
75
|
-
class Balance
|
|
76
|
-
}
|
|
77
|
-
package "service" {
|
|
78
|
-
class JournalDomainService
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
package "application" {
|
|
83
|
-
package "port.in" {
|
|
84
|
-
interface AccountUseCase
|
|
85
|
-
interface JournalUseCase
|
|
86
|
-
}
|
|
87
|
-
package "port.out" {
|
|
88
|
-
interface AccountRepository
|
|
89
|
-
interface JournalRepository
|
|
90
|
-
}
|
|
91
|
-
package "service" {
|
|
92
|
-
class AccountApplicationService
|
|
93
|
-
class JournalApplicationService
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
package "infrastructure" {
|
|
98
|
-
package "adapter.in.web" {
|
|
99
|
-
class AccountController
|
|
100
|
-
class JournalController
|
|
101
|
-
}
|
|
102
|
-
package "adapter.out.persistence" {
|
|
103
|
-
class AccountJpaRepository
|
|
104
|
-
class JournalJpaRepository
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
AccountUseCase <|.. AccountApplicationService
|
|
110
|
-
AccountRepository <|.. AccountJpaRepository
|
|
111
|
-
AccountController --> AccountUseCase
|
|
112
|
-
AccountApplicationService --> AccountRepository
|
|
113
|
-
|
|
114
|
-
note right of AccountJpaRepository
|
|
115
|
-
extends JpaRepository<Account, String>
|
|
116
|
-
Spring Data JPA により自動実装
|
|
117
|
-
end note
|
|
118
|
-
|
|
119
|
-
@enduml
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### 21.2.2 各レイヤーの責務
|
|
123
|
-
|
|
124
|
-
```plantuml
|
|
125
|
-
@startuml
|
|
126
|
-
|
|
127
|
-
title 各層の責務(JPA版)
|
|
128
|
-
|
|
129
|
-
rectangle "Infrastructure Layer (Adapter)" #BBDEFB {
|
|
130
|
-
card "**入力アダプター**\n・REST Controller\n・リクエスト変換\n・レスポンス生成\n・@Valid バリデーション" as in_adapter
|
|
131
|
-
|
|
132
|
-
card "**出力アダプター**\n・JpaRepository 実装\n・@Query カスタムクエリ\n・Specification 動的クエリ\n・@EntityGraph N+1対策" as out_adapter
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
rectangle "Application Layer (Port + UseCase)" #FFF9C4 {
|
|
136
|
-
card "**入力ポート**\n・UseCase インターフェース\n・DTO定義\n・コマンド/クエリ" as in_port
|
|
137
|
-
|
|
138
|
-
card "**出力ポート**\n・Repository インターフェース\n・永続化抽象\n・外部連携抽象" as out_port
|
|
139
|
-
|
|
140
|
-
card "**アプリケーションサービス**\n・ユースケース実装\n・@Transactional 制御\n・ドメイン調整" as app_service
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
rectangle "Domain Layer" #C8E6C9 {
|
|
144
|
-
card "**エンティティ**\n・@Entity アノテーション\n・ビジネスルール\n・状態管理" as entity
|
|
145
|
-
|
|
146
|
-
card "**値オブジェクト**\n・@Embeddable\n・不変性\n・同値性" as vo
|
|
147
|
-
|
|
148
|
-
card "**ドメインサービス**\n・複数エンティティ操作\n・ドメインロジック" as domain_service
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
in_adapter --> in_port
|
|
152
|
-
app_service --> out_port
|
|
153
|
-
out_port --> out_adapter
|
|
154
|
-
app_service --> entity
|
|
155
|
-
app_service --> domain_service
|
|
156
|
-
|
|
157
|
-
@enduml
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## 21.3 マスタ API の実装
|
|
161
|
-
|
|
162
|
-
### 21.3.1 API エンドポイント設計
|
|
163
|
-
|
|
164
|
-
| メソッド | パス | 説明 |
|
|
165
|
-
|---------|------|------|
|
|
166
|
-
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
167
|
-
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
168
|
-
| GET | /api/accounts/{accountCode}/hierarchy | 科目階層取得 |
|
|
169
|
-
| POST | /api/accounts | 勘定科目登録 |
|
|
170
|
-
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
171
|
-
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
172
|
-
|
|
173
|
-
### 21.3.2 Output Port(リポジトリインターフェース)
|
|
174
|
-
|
|
175
|
-
<details>
|
|
176
|
-
<summary>AccountRepository(Output Port)</summary>
|
|
177
|
-
|
|
178
|
-
```java
|
|
179
|
-
// src/main/java/com/example/accounting/application/port/out/AccountRepository.java
|
|
180
|
-
package com.example.accounting.application.port.out;
|
|
181
|
-
|
|
182
|
-
import com.example.accounting.domain.model.account.Account;
|
|
183
|
-
|
|
184
|
-
import java.util.List;
|
|
185
|
-
import java.util.Optional;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 勘定科目リポジトリ(Output Port)
|
|
189
|
-
*
|
|
190
|
-
* ヘキサゴナルアーキテクチャにおける出力ポート。
|
|
191
|
-
* アプリケーション層から永続化層への依存を抽象化する。
|
|
192
|
-
*/
|
|
193
|
-
public interface AccountRepository {
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* 勘定科目コードで検索
|
|
197
|
-
*/
|
|
198
|
-
Optional<Account> findByCode(String accountCode);
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 全件取得
|
|
202
|
-
*/
|
|
203
|
-
List<Account> findAll();
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* BSPL区分で検索
|
|
207
|
-
*/
|
|
208
|
-
List<Account> findByBsPlType(String bsPlType);
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* 科目パスで検索(チルダ連結方式)
|
|
212
|
-
*/
|
|
213
|
-
List<Account> findByPathLike(String pathPattern);
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* 計上科目のみ取得
|
|
217
|
-
*/
|
|
218
|
-
List<Account> findPostingAccounts();
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* 保存(新規・更新)
|
|
222
|
-
*/
|
|
223
|
-
Account save(Account account);
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 削除
|
|
227
|
-
*/
|
|
228
|
-
void delete(String accountCode);
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* 存在確認
|
|
232
|
-
*/
|
|
233
|
-
boolean exists(String accountCode);
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
</details>
|
|
238
|
-
|
|
239
|
-
### 21.3.3 JPA Repository 実装
|
|
240
|
-
|
|
241
|
-
<details>
|
|
242
|
-
<summary>AccountJpaRepository</summary>
|
|
243
|
-
|
|
244
|
-
```java
|
|
245
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/out/persistence/AccountJpaRepository.java
|
|
246
|
-
package com.example.accounting.infrastructure.adapter.out.persistence;
|
|
247
|
-
|
|
248
|
-
import com.example.accounting.domain.model.account.Account;
|
|
249
|
-
import com.example.accounting.domain.model.account.BsPlType;
|
|
250
|
-
import com.example.accounting.domain.model.account.SummaryType;
|
|
251
|
-
import org.springframework.data.jpa.repository.JpaRepository;
|
|
252
|
-
import org.springframework.data.jpa.repository.Query;
|
|
253
|
-
import org.springframework.data.repository.query.Param;
|
|
254
|
-
import org.springframework.stereotype.Repository;
|
|
255
|
-
|
|
256
|
-
import java.util.List;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* 勘定科目 JPA リポジトリ
|
|
260
|
-
*
|
|
261
|
-
* Spring Data JPA により基本的な CRUD 操作は自動生成される。
|
|
262
|
-
* カスタムクエリは @Query アノテーションで定義。
|
|
263
|
-
*/
|
|
264
|
-
@Repository
|
|
265
|
-
public interface AccountJpaRepository extends JpaRepository<Account, String> {
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* BSPL区分で検索
|
|
269
|
-
*/
|
|
270
|
-
List<Account> findByBsPlType(BsPlType bsPlType);
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* 科目パスで前方一致検索(勘定科目構成マスタ経由)
|
|
274
|
-
*/
|
|
275
|
-
@Query("SELECT a FROM Account a JOIN AccountStructure s ON a.accountCode = s.accountCode " +
|
|
276
|
-
"WHERE s.accountPath LIKE CONCAT(:pathPrefix, '%') ORDER BY a.accountCode")
|
|
277
|
-
List<Account> findByAccountPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* 計上科目のみ取得
|
|
281
|
-
*/
|
|
282
|
-
List<Account> findBySummaryType(SummaryType summaryType);
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* 計上科目のみ取得(便利メソッド)
|
|
286
|
-
*/
|
|
287
|
-
default List<Account> findPostingAccounts() {
|
|
288
|
-
return findBySummaryType(SummaryType.POSTING);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* 勘定科目コード順で全件取得
|
|
293
|
-
*/
|
|
294
|
-
List<Account> findAllByOrderByAccountCodeAsc();
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
</details>
|
|
299
|
-
|
|
300
|
-
### 21.3.4 Repository アダプター
|
|
301
|
-
|
|
302
|
-
<details>
|
|
303
|
-
<summary>AccountRepositoryAdapter</summary>
|
|
304
|
-
|
|
305
|
-
```java
|
|
306
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/out/persistence/AccountRepositoryAdapter.java
|
|
307
|
-
package com.example.accounting.infrastructure.adapter.out.persistence;
|
|
308
|
-
|
|
309
|
-
import com.example.accounting.application.port.out.AccountRepository;
|
|
310
|
-
import com.example.accounting.domain.model.account.Account;
|
|
311
|
-
import com.example.accounting.domain.model.account.BsPlType;
|
|
312
|
-
import lombok.RequiredArgsConstructor;
|
|
313
|
-
import org.springframework.stereotype.Component;
|
|
314
|
-
|
|
315
|
-
import java.util.List;
|
|
316
|
-
import java.util.Optional;
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* 勘定科目リポジトリアダプター
|
|
320
|
-
*
|
|
321
|
-
* Output Port(AccountRepository)の実装。
|
|
322
|
-
* JpaRepository をラップしてドメインのインターフェースに適合させる。
|
|
323
|
-
*/
|
|
324
|
-
@Component
|
|
325
|
-
@RequiredArgsConstructor
|
|
326
|
-
public class AccountRepositoryAdapter implements AccountRepository {
|
|
327
|
-
|
|
328
|
-
private final AccountJpaRepository jpaRepository;
|
|
329
|
-
|
|
330
|
-
@Override
|
|
331
|
-
public Optional<Account> findByCode(String accountCode) {
|
|
332
|
-
return jpaRepository.findById(accountCode);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
@Override
|
|
336
|
-
public List<Account> findAll() {
|
|
337
|
-
return jpaRepository.findAllByOrderByAccountCodeAsc();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
@Override
|
|
341
|
-
public List<Account> findByBsPlType(String bsPlType) {
|
|
342
|
-
return jpaRepository.findByBsPlType(BsPlType.valueOf(bsPlType));
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
@Override
|
|
346
|
-
public List<Account> findByPathLike(String pathPattern) {
|
|
347
|
-
String prefix = pathPattern.replace("%", "");
|
|
348
|
-
return jpaRepository.findByAccountPathStartsWith(prefix);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
@Override
|
|
352
|
-
public List<Account> findPostingAccounts() {
|
|
353
|
-
return jpaRepository.findPostingAccounts();
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
@Override
|
|
357
|
-
public Account save(Account account) {
|
|
358
|
-
return jpaRepository.save(account);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
@Override
|
|
362
|
-
public void delete(String accountCode) {
|
|
363
|
-
jpaRepository.deleteById(accountCode);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
@Override
|
|
367
|
-
public boolean exists(String accountCode) {
|
|
368
|
-
return jpaRepository.existsById(accountCode);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
</details>
|
|
374
|
-
|
|
375
|
-
### 21.3.5 Input Port(ユースケースインターフェース)
|
|
376
|
-
|
|
377
|
-
<details>
|
|
378
|
-
<summary>AccountUseCase(Input Port)</summary>
|
|
379
|
-
|
|
380
|
-
```java
|
|
381
|
-
// src/main/java/com/example/accounting/application/port/in/AccountUseCase.java
|
|
382
|
-
package com.example.accounting.application.port.in;
|
|
383
|
-
|
|
384
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
385
|
-
|
|
386
|
-
import java.util.List;
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* 勘定科目ユースケース(Input Port)
|
|
390
|
-
*/
|
|
391
|
-
public interface AccountUseCase {
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* 勘定科目を取得
|
|
395
|
-
*/
|
|
396
|
-
AccountResponse getAccount(String accountCode);
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* 全勘定科目を取得
|
|
400
|
-
*/
|
|
401
|
-
List<AccountResponse> getAllAccounts();
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* BS/PL区分で勘定科目を取得
|
|
405
|
-
*/
|
|
406
|
-
List<AccountResponse> getAccountsByBsPlType(String bsPlType);
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* 科目階層を取得(親科目以下の全科目)
|
|
410
|
-
*/
|
|
411
|
-
List<AccountResponse> getAccountHierarchy(String parentAccountCode);
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* 計上科目のみ取得
|
|
415
|
-
*/
|
|
416
|
-
List<AccountResponse> getPostingAccounts();
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* 勘定科目を登録
|
|
420
|
-
*/
|
|
421
|
-
AccountResponse createAccount(CreateAccountCommand command);
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* 勘定科目を更新
|
|
425
|
-
*/
|
|
426
|
-
AccountResponse updateAccount(String accountCode, UpdateAccountCommand command);
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* 勘定科目を削除
|
|
430
|
-
*/
|
|
431
|
-
void deleteAccount(String accountCode);
|
|
432
|
-
}
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
</details>
|
|
436
|
-
|
|
437
|
-
### 21.3.6 コマンド・レスポンス DTO
|
|
438
|
-
|
|
439
|
-
<details>
|
|
440
|
-
<summary>CreateAccountCommand</summary>
|
|
441
|
-
|
|
442
|
-
```java
|
|
443
|
-
// src/main/java/com/example/accounting/application/port/in/dto/CreateAccountCommand.java
|
|
444
|
-
package com.example.accounting.application.port.in.dto;
|
|
445
|
-
|
|
446
|
-
import jakarta.validation.constraints.*;
|
|
447
|
-
import lombok.Builder;
|
|
448
|
-
import lombok.Data;
|
|
449
|
-
|
|
450
|
-
@Data
|
|
451
|
-
@Builder
|
|
452
|
-
public class CreateAccountCommand {
|
|
453
|
-
|
|
454
|
-
@NotBlank(message = "勘定科目コードは必須です")
|
|
455
|
-
@Size(max = 5, message = "勘定科目コードは5文字以内です")
|
|
456
|
-
private String accountCode;
|
|
457
|
-
|
|
458
|
-
@NotBlank(message = "勘定科目名は必須です")
|
|
459
|
-
@Size(max = 40, message = "勘定科目名は40文字以内です")
|
|
460
|
-
private String accountName;
|
|
461
|
-
|
|
462
|
-
@Size(max = 10, message = "勘定科目略名は10文字以内です")
|
|
463
|
-
private String accountShortName;
|
|
464
|
-
|
|
465
|
-
@NotBlank(message = "BSPL区分は必須です")
|
|
466
|
-
@Pattern(regexp = "BS|PL", message = "BSPL区分はBS/PLのいずれかです")
|
|
467
|
-
private String bsPlType;
|
|
468
|
-
|
|
469
|
-
@NotBlank(message = "貸借区分は必須です")
|
|
470
|
-
@Pattern(regexp = "借方|貸方", message = "貸借区分は借方/貸方のいずれかです")
|
|
471
|
-
private String dcType;
|
|
472
|
-
|
|
473
|
-
@NotBlank(message = "取引要素区分は必須です")
|
|
474
|
-
private String elementType;
|
|
475
|
-
|
|
476
|
-
@NotBlank(message = "集計区分は必須です")
|
|
477
|
-
private String summaryType;
|
|
478
|
-
|
|
479
|
-
private String managementType;
|
|
480
|
-
private String expenseType;
|
|
481
|
-
private String taxCalculationType;
|
|
482
|
-
private String taxCode;
|
|
483
|
-
private String parentAccountCode;
|
|
484
|
-
}
|
|
485
|
-
```
|
|
486
|
-
|
|
487
|
-
</details>
|
|
488
|
-
|
|
489
|
-
<details>
|
|
490
|
-
<summary>AccountResponse</summary>
|
|
491
|
-
|
|
492
|
-
```java
|
|
493
|
-
// src/main/java/com/example/accounting/application/port/in/dto/AccountResponse.java
|
|
494
|
-
package com.example.accounting.application.port.in.dto;
|
|
495
|
-
|
|
496
|
-
import com.example.accounting.domain.model.account.Account;
|
|
497
|
-
import lombok.Builder;
|
|
498
|
-
import lombok.Data;
|
|
499
|
-
|
|
500
|
-
@Data
|
|
501
|
-
@Builder
|
|
502
|
-
public class AccountResponse {
|
|
503
|
-
private String accountCode;
|
|
504
|
-
private String accountName;
|
|
505
|
-
private String accountShortName;
|
|
506
|
-
private String accountKana;
|
|
507
|
-
private String bsPlType;
|
|
508
|
-
private String dcType;
|
|
509
|
-
private String elementType;
|
|
510
|
-
private String summaryType;
|
|
511
|
-
private String managementType;
|
|
512
|
-
private String expenseType;
|
|
513
|
-
private String taxCalculationType;
|
|
514
|
-
private String taxCode;
|
|
515
|
-
private String accountPath;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* エンティティからレスポンスDTOを生成
|
|
519
|
-
*/
|
|
520
|
-
public static AccountResponse from(Account account) {
|
|
521
|
-
return AccountResponse.builder()
|
|
522
|
-
.accountCode(account.getAccountCode())
|
|
523
|
-
.accountName(account.getAccountName())
|
|
524
|
-
.accountShortName(account.getAccountShortName())
|
|
525
|
-
.accountKana(account.getAccountKana())
|
|
526
|
-
.bsPlType(account.getBsPlType() != null ? account.getBsPlType().name() : null)
|
|
527
|
-
.dcType(account.getDcType() != null ? account.getDcType().getDisplayName() : null)
|
|
528
|
-
.elementType(account.getElementType() != null ? account.getElementType().getDisplayName() : null)
|
|
529
|
-
.summaryType(account.getSummaryType() != null ? account.getSummaryType().getDisplayName() : null)
|
|
530
|
-
.managementType(account.getManagementType() != null ? account.getManagementType().getDisplayName() : null)
|
|
531
|
-
.expenseType(account.getExpenseType() != null ? account.getExpenseType().getDisplayName() : null)
|
|
532
|
-
.taxCalculationType(account.getTaxCalculationType() != null ? account.getTaxCalculationType().getDisplayName() : null)
|
|
533
|
-
.taxCode(account.getTaxCode())
|
|
534
|
-
.build();
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
```
|
|
538
|
-
|
|
539
|
-
</details>
|
|
540
|
-
|
|
541
|
-
## 21.4 TDD による実装
|
|
542
|
-
|
|
543
|
-
### 21.4.1 Red: Controller テスト
|
|
544
|
-
|
|
545
|
-
<details>
|
|
546
|
-
<summary>AccountControllerTest</summary>
|
|
547
|
-
|
|
548
|
-
```java
|
|
549
|
-
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerTest.java
|
|
550
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
551
|
-
|
|
552
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
553
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
554
|
-
import com.example.accounting.domain.exception.AccountNotFoundException;
|
|
555
|
-
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
556
|
-
import org.junit.jupiter.api.*;
|
|
557
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
558
|
-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|
559
|
-
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
560
|
-
import org.springframework.http.MediaType;
|
|
561
|
-
import org.springframework.test.web.servlet.MockMvc;
|
|
562
|
-
|
|
563
|
-
import java.util.List;
|
|
564
|
-
|
|
565
|
-
import static org.mockito.ArgumentMatchers.*;
|
|
566
|
-
import static org.mockito.BDDMockito.*;
|
|
567
|
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
568
|
-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
569
|
-
|
|
570
|
-
@WebMvcTest(AccountController.class)
|
|
571
|
-
@DisplayName("勘定科目マスタ API")
|
|
572
|
-
class AccountControllerTest {
|
|
573
|
-
|
|
574
|
-
@Autowired
|
|
575
|
-
private MockMvc mockMvc;
|
|
576
|
-
|
|
577
|
-
@Autowired
|
|
578
|
-
private ObjectMapper objectMapper;
|
|
579
|
-
|
|
580
|
-
@MockBean
|
|
581
|
-
private AccountUseCase accountUseCase;
|
|
582
|
-
|
|
583
|
-
@Nested
|
|
584
|
-
@DisplayName("GET /api/accounts/{accountCode}")
|
|
585
|
-
class GetAccount {
|
|
586
|
-
|
|
587
|
-
@Test
|
|
588
|
-
@DisplayName("勘定科目を取得できる")
|
|
589
|
-
void canGetAccount() throws Exception {
|
|
590
|
-
// Given
|
|
591
|
-
AccountResponse response = AccountResponse.builder()
|
|
592
|
-
.accountCode("11110")
|
|
593
|
-
.accountName("現金")
|
|
594
|
-
.accountShortName("現金")
|
|
595
|
-
.bsPlType("BS")
|
|
596
|
-
.dcType("借方")
|
|
597
|
-
.elementType("資産")
|
|
598
|
-
.summaryType("計上科目")
|
|
599
|
-
.build();
|
|
600
|
-
|
|
601
|
-
given(accountUseCase.getAccount("11110")).willReturn(response);
|
|
602
|
-
|
|
603
|
-
// When & Then
|
|
604
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "11110"))
|
|
605
|
-
.andExpect(status().isOk())
|
|
606
|
-
.andExpect(jsonPath("$.accountCode").value("11110"))
|
|
607
|
-
.andExpect(jsonPath("$.accountName").value("現金"))
|
|
608
|
-
.andExpect(jsonPath("$.bsPlType").value("BS"));
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
@Test
|
|
612
|
-
@DisplayName("存在しない勘定科目は404を返す")
|
|
613
|
-
void notFoundForNonExistent() throws Exception {
|
|
614
|
-
// Given
|
|
615
|
-
given(accountUseCase.getAccount("99999")).willThrow(
|
|
616
|
-
new AccountNotFoundException("99999"));
|
|
617
|
-
|
|
618
|
-
// When & Then
|
|
619
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
620
|
-
.andExpect(status().isNotFound());
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
@Nested
|
|
625
|
-
@DisplayName("POST /api/accounts")
|
|
626
|
-
class CreateAccount {
|
|
627
|
-
|
|
628
|
-
@Test
|
|
629
|
-
@DisplayName("勘定科目を登録できる")
|
|
630
|
-
void canCreateAccount() throws Exception {
|
|
631
|
-
// Given
|
|
632
|
-
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
633
|
-
.accountCode("11150")
|
|
634
|
-
.accountName("手許現金")
|
|
635
|
-
.accountShortName("手許現金")
|
|
636
|
-
.bsPlType("BS")
|
|
637
|
-
.dcType("借方")
|
|
638
|
-
.elementType("資産")
|
|
639
|
-
.summaryType("計上科目")
|
|
640
|
-
.build();
|
|
641
|
-
|
|
642
|
-
AccountResponse response = AccountResponse.builder()
|
|
643
|
-
.accountCode("11150")
|
|
644
|
-
.accountName("手許現金")
|
|
645
|
-
.accountShortName("手許現金")
|
|
646
|
-
.bsPlType("BS")
|
|
647
|
-
.dcType("借方")
|
|
648
|
-
.build();
|
|
649
|
-
|
|
650
|
-
given(accountUseCase.createAccount(any())).willReturn(response);
|
|
651
|
-
|
|
652
|
-
// When & Then
|
|
653
|
-
mockMvc.perform(post("/api/accounts")
|
|
654
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
655
|
-
.content(objectMapper.writeValueAsString(command)))
|
|
656
|
-
.andExpect(status().isCreated())
|
|
657
|
-
.andExpect(jsonPath("$.accountCode").value("11150"))
|
|
658
|
-
.andExpect(jsonPath("$.accountName").value("手許現金"));
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
@Test
|
|
662
|
-
@DisplayName("バリデーションエラーで400を返す")
|
|
663
|
-
void badRequestForValidationError() throws Exception {
|
|
664
|
-
// Given
|
|
665
|
-
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
666
|
-
.accountCode("") // 必須項目が空
|
|
667
|
-
.accountName("")
|
|
668
|
-
.build();
|
|
669
|
-
|
|
670
|
-
// When & Then
|
|
671
|
-
mockMvc.perform(post("/api/accounts")
|
|
672
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
673
|
-
.content(objectMapper.writeValueAsString(command)))
|
|
674
|
-
.andExpect(status().isBadRequest());
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
</details>
|
|
681
|
-
|
|
682
|
-
### 21.4.2 Green: Controller 実装
|
|
683
|
-
|
|
684
|
-
<details>
|
|
685
|
-
<summary>AccountController</summary>
|
|
686
|
-
|
|
687
|
-
```java
|
|
688
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/AccountController.java
|
|
689
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
690
|
-
|
|
691
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
692
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
693
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
694
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
695
|
-
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
696
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
697
|
-
import jakarta.validation.Valid;
|
|
698
|
-
import lombok.RequiredArgsConstructor;
|
|
699
|
-
import org.springframework.http.HttpStatus;
|
|
700
|
-
import org.springframework.http.ResponseEntity;
|
|
701
|
-
import org.springframework.web.bind.annotation.*;
|
|
702
|
-
|
|
703
|
-
import java.util.List;
|
|
704
|
-
|
|
705
|
-
@RestController
|
|
706
|
-
@RequestMapping("/api/accounts")
|
|
707
|
-
@RequiredArgsConstructor
|
|
708
|
-
@Tag(name = "勘定科目マスタ", description = "勘定科目マスタの管理API")
|
|
709
|
-
public class AccountController {
|
|
710
|
-
|
|
711
|
-
private final AccountUseCase accountUseCase;
|
|
712
|
-
|
|
713
|
-
@GetMapping("/{accountCode}")
|
|
714
|
-
@Operation(summary = "勘定科目取得", description = "勘定科目コードで勘定科目を取得します")
|
|
715
|
-
@ApiResponse(responseCode = "200", description = "取得成功")
|
|
716
|
-
@ApiResponse(responseCode = "404", description = "勘定科目が存在しない")
|
|
717
|
-
public ResponseEntity<AccountResponse> getAccount(
|
|
718
|
-
@Parameter(description = "勘定科目コード")
|
|
719
|
-
@PathVariable String accountCode) {
|
|
720
|
-
return ResponseEntity.ok(accountUseCase.getAccount(accountCode));
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
@GetMapping
|
|
724
|
-
@Operation(summary = "勘定科目一覧取得", description = "勘定科目の一覧を取得します")
|
|
725
|
-
public ResponseEntity<List<AccountResponse>> getAccounts(
|
|
726
|
-
@Parameter(description = "BSPL区分(BS/PL)")
|
|
727
|
-
@RequestParam(required = false) String bsPlType,
|
|
728
|
-
@Parameter(description = "計上科目のみ")
|
|
729
|
-
@RequestParam(required = false, defaultValue = "false") boolean postingOnly) {
|
|
730
|
-
|
|
731
|
-
List<AccountResponse> accounts;
|
|
732
|
-
if (bsPlType != null) {
|
|
733
|
-
accounts = accountUseCase.getAccountsByBsPlType(bsPlType);
|
|
734
|
-
} else if (postingOnly) {
|
|
735
|
-
accounts = accountUseCase.getPostingAccounts();
|
|
736
|
-
} else {
|
|
737
|
-
accounts = accountUseCase.getAllAccounts();
|
|
738
|
-
}
|
|
739
|
-
return ResponseEntity.ok(accounts);
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
@PostMapping
|
|
743
|
-
@Operation(summary = "勘定科目登録", description = "新規勘定科目を登録します")
|
|
744
|
-
@ApiResponse(responseCode = "201", description = "登録成功")
|
|
745
|
-
@ApiResponse(responseCode = "400", description = "バリデーションエラー")
|
|
746
|
-
public ResponseEntity<AccountResponse> createAccount(
|
|
747
|
-
@Valid @RequestBody CreateAccountCommand command) {
|
|
748
|
-
AccountResponse response = accountUseCase.createAccount(command);
|
|
749
|
-
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
@PutMapping("/{accountCode}")
|
|
753
|
-
@Operation(summary = "勘定科目更新", description = "勘定科目を更新します")
|
|
754
|
-
public ResponseEntity<AccountResponse> updateAccount(
|
|
755
|
-
@PathVariable String accountCode,
|
|
756
|
-
@Valid @RequestBody UpdateAccountCommand command) {
|
|
757
|
-
return ResponseEntity.ok(accountUseCase.updateAccount(accountCode, command));
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
@DeleteMapping("/{accountCode}")
|
|
761
|
-
@Operation(summary = "勘定科目削除", description = "勘定科目を削除します")
|
|
762
|
-
@ApiResponse(responseCode = "204", description = "削除成功")
|
|
763
|
-
public ResponseEntity<Void> deleteAccount(@PathVariable String accountCode) {
|
|
764
|
-
accountUseCase.deleteAccount(accountCode);
|
|
765
|
-
return ResponseEntity.noContent().build();
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
```
|
|
769
|
-
|
|
770
|
-
</details>
|
|
771
|
-
|
|
772
|
-
### 21.4.3 Refactor: Application Service 実装
|
|
773
|
-
|
|
774
|
-
<details>
|
|
775
|
-
<summary>AccountApplicationService</summary>
|
|
776
|
-
|
|
777
|
-
```java
|
|
778
|
-
// src/main/java/com/example/accounting/application/service/AccountApplicationService.java
|
|
779
|
-
package com.example.accounting.application.service;
|
|
780
|
-
|
|
781
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
782
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
783
|
-
import com.example.accounting.application.port.out.AccountRepository;
|
|
784
|
-
import com.example.accounting.application.port.out.AccountStructureRepository;
|
|
785
|
-
import com.example.accounting.domain.exception.*;
|
|
786
|
-
import com.example.accounting.domain.model.account.*;
|
|
787
|
-
import lombok.RequiredArgsConstructor;
|
|
788
|
-
import org.springframework.stereotype.Service;
|
|
789
|
-
import org.springframework.transaction.annotation.Transactional;
|
|
790
|
-
|
|
791
|
-
import java.util.List;
|
|
792
|
-
import java.util.stream.Collectors;
|
|
793
|
-
|
|
794
|
-
@Service
|
|
795
|
-
@RequiredArgsConstructor
|
|
796
|
-
@Transactional(readOnly = true)
|
|
797
|
-
public class AccountApplicationService implements AccountUseCase {
|
|
798
|
-
|
|
799
|
-
private final AccountRepository accountRepository;
|
|
800
|
-
private final AccountStructureRepository accountStructureRepository;
|
|
801
|
-
|
|
802
|
-
@Override
|
|
803
|
-
public AccountResponse getAccount(String accountCode) {
|
|
804
|
-
Account account = accountRepository.findByCode(accountCode)
|
|
805
|
-
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
806
|
-
return AccountResponse.from(account);
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
@Override
|
|
810
|
-
public List<AccountResponse> getAllAccounts() {
|
|
811
|
-
return accountRepository.findAll().stream()
|
|
812
|
-
.map(AccountResponse::from)
|
|
813
|
-
.collect(Collectors.toList());
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
@Override
|
|
817
|
-
public List<AccountResponse> getAccountsByBsPlType(String bsPlType) {
|
|
818
|
-
return accountRepository.findByBsPlType(bsPlType).stream()
|
|
819
|
-
.map(AccountResponse::from)
|
|
820
|
-
.collect(Collectors.toList());
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
@Override
|
|
824
|
-
public List<AccountResponse> getAccountHierarchy(String parentAccountCode) {
|
|
825
|
-
String pathPattern = "%" + parentAccountCode + "%";
|
|
826
|
-
return accountRepository.findByPathLike(pathPattern).stream()
|
|
827
|
-
.map(AccountResponse::from)
|
|
828
|
-
.collect(Collectors.toList());
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
@Override
|
|
832
|
-
public List<AccountResponse> getPostingAccounts() {
|
|
833
|
-
return accountRepository.findPostingAccounts().stream()
|
|
834
|
-
.map(AccountResponse::from)
|
|
835
|
-
.collect(Collectors.toList());
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
@Override
|
|
839
|
-
@Transactional
|
|
840
|
-
public AccountResponse createAccount(CreateAccountCommand command) {
|
|
841
|
-
if (accountRepository.exists(command.getAccountCode())) {
|
|
842
|
-
throw new AccountAlreadyExistsException(command.getAccountCode());
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
Account account = Account.builder()
|
|
846
|
-
.accountCode(command.getAccountCode())
|
|
847
|
-
.accountName(command.getAccountName())
|
|
848
|
-
.accountShortName(command.getAccountShortName())
|
|
849
|
-
.bsPlType(BsPlType.valueOf(command.getBsPlType()))
|
|
850
|
-
.dcType(AccountDcType.fromDisplayName(command.getDcType()))
|
|
851
|
-
.elementType(ElementType.fromDisplayName(command.getElementType()))
|
|
852
|
-
.summaryType(SummaryType.fromDisplayName(command.getSummaryType()))
|
|
853
|
-
.taxCode(command.getTaxCode())
|
|
854
|
-
.build();
|
|
855
|
-
|
|
856
|
-
accountRepository.save(account);
|
|
857
|
-
|
|
858
|
-
String accountPath = generateAccountPath(command.getAccountCode(), command.getParentAccountCode());
|
|
859
|
-
AccountStructure structure = AccountStructure.builder()
|
|
860
|
-
.accountCode(command.getAccountCode())
|
|
861
|
-
.accountPath(accountPath)
|
|
862
|
-
.account(account)
|
|
863
|
-
.build();
|
|
864
|
-
accountStructureRepository.save(structure);
|
|
865
|
-
|
|
866
|
-
return AccountResponse.from(account);
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
@Override
|
|
870
|
-
@Transactional
|
|
871
|
-
public AccountResponse updateAccount(String accountCode, UpdateAccountCommand command) {
|
|
872
|
-
Account account = accountRepository.findByCode(accountCode)
|
|
873
|
-
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
874
|
-
|
|
875
|
-
if (command.getAccountName() != null) {
|
|
876
|
-
account.setAccountName(command.getAccountName());
|
|
877
|
-
}
|
|
878
|
-
if (command.getAccountShortName() != null) {
|
|
879
|
-
account.setAccountShortName(command.getAccountShortName());
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
accountRepository.save(account);
|
|
883
|
-
return AccountResponse.from(account);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
@Override
|
|
887
|
-
@Transactional
|
|
888
|
-
public void deleteAccount(String accountCode) {
|
|
889
|
-
if (!accountRepository.exists(accountCode)) {
|
|
890
|
-
throw new AccountNotFoundException(accountCode);
|
|
891
|
-
}
|
|
892
|
-
accountStructureRepository.delete(accountCode);
|
|
893
|
-
accountRepository.delete(accountCode);
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
private String generateAccountPath(String accountCode, String parentAccountCode) {
|
|
897
|
-
if (parentAccountCode == null || parentAccountCode.isEmpty()) {
|
|
898
|
-
return accountCode;
|
|
899
|
-
}
|
|
900
|
-
return accountStructureRepository.findByCode(parentAccountCode)
|
|
901
|
-
.map(parent -> parent.getAccountPath() + "~" + accountCode)
|
|
902
|
-
.orElse(accountCode);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
```
|
|
906
|
-
|
|
907
|
-
</details>
|
|
908
|
-
|
|
909
|
-
## 21.5 トランザクション API
|
|
910
|
-
|
|
911
|
-
### 21.5.1 仕訳 API エンドポイント
|
|
912
|
-
|
|
913
|
-
| メソッド | パス | 説明 |
|
|
914
|
-
|---------|------|------|
|
|
915
|
-
| GET | /api/journals | 仕訳一覧取得 |
|
|
916
|
-
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
917
|
-
| POST | /api/journals | 仕訳登録 |
|
|
918
|
-
| POST | /api/journals/check-balance | 貸借バランスチェック |
|
|
919
|
-
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消(赤黒処理) |
|
|
920
|
-
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正(赤黒処理) |
|
|
921
|
-
|
|
922
|
-
<details>
|
|
923
|
-
<summary>JournalController</summary>
|
|
924
|
-
|
|
925
|
-
```java
|
|
926
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/JournalController.java
|
|
927
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
928
|
-
|
|
929
|
-
import com.example.accounting.application.port.in.JournalUseCase;
|
|
930
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
931
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
932
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
933
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
934
|
-
import jakarta.validation.Valid;
|
|
935
|
-
import lombok.RequiredArgsConstructor;
|
|
936
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
937
|
-
import org.springframework.http.HttpStatus;
|
|
938
|
-
import org.springframework.http.ResponseEntity;
|
|
939
|
-
import org.springframework.web.bind.annotation.*;
|
|
940
|
-
|
|
941
|
-
import java.time.LocalDate;
|
|
942
|
-
import java.util.List;
|
|
943
|
-
|
|
944
|
-
@RestController
|
|
945
|
-
@RequestMapping("/api/journals")
|
|
946
|
-
@RequiredArgsConstructor
|
|
947
|
-
@Tag(name = "仕訳", description = "仕訳の管理API")
|
|
948
|
-
public class JournalController {
|
|
949
|
-
|
|
950
|
-
private final JournalUseCase journalUseCase;
|
|
951
|
-
|
|
952
|
-
@GetMapping("/{journalNumber}")
|
|
953
|
-
@Operation(summary = "仕訳取得", description = "仕訳伝票番号で仕訳を取得します")
|
|
954
|
-
public ResponseEntity<JournalResponse> getJournal(
|
|
955
|
-
@Parameter(description = "仕訳伝票番号")
|
|
956
|
-
@PathVariable String journalNumber) {
|
|
957
|
-
return ResponseEntity.ok(journalUseCase.getJournal(journalNumber));
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
@GetMapping
|
|
961
|
-
@Operation(summary = "仕訳一覧取得", description = "条件を指定して仕訳を検索します")
|
|
962
|
-
public ResponseEntity<List<JournalResponse>> getJournals(
|
|
963
|
-
@Parameter(description = "開始日")
|
|
964
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
965
|
-
@Parameter(description = "終了日")
|
|
966
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
|
|
967
|
-
@Parameter(description = "部門コード")
|
|
968
|
-
@RequestParam(required = false) String departmentCode) {
|
|
969
|
-
|
|
970
|
-
List<JournalResponse> journals;
|
|
971
|
-
if (departmentCode != null) {
|
|
972
|
-
journals = journalUseCase.getJournalsByDepartment(departmentCode, fromDate, toDate);
|
|
973
|
-
} else {
|
|
974
|
-
journals = journalUseCase.getJournalsByDateRange(fromDate, toDate);
|
|
975
|
-
}
|
|
976
|
-
return ResponseEntity.ok(journals);
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
@PostMapping
|
|
980
|
-
@Operation(summary = "仕訳登録", description = "新規仕訳を登録します")
|
|
981
|
-
public ResponseEntity<JournalResponse> createJournal(
|
|
982
|
-
@Valid @RequestBody CreateJournalCommand command) {
|
|
983
|
-
JournalResponse response = journalUseCase.createJournal(command);
|
|
984
|
-
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
@PostMapping("/check-balance")
|
|
988
|
-
@Operation(summary = "貸借バランスチェック", description = "仕訳の貸借バランスをチェックします")
|
|
989
|
-
public ResponseEntity<BalanceCheckResult> checkBalance(
|
|
990
|
-
@Valid @RequestBody CreateJournalCommand command) {
|
|
991
|
-
return ResponseEntity.ok(journalUseCase.checkBalance(command));
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
@PostMapping("/{journalNumber}/cancel")
|
|
995
|
-
@Operation(summary = "仕訳取消", description = "仕訳を赤黒処理で取消します")
|
|
996
|
-
public ResponseEntity<JournalCancellationResult> cancelJournal(
|
|
997
|
-
@PathVariable String journalNumber,
|
|
998
|
-
@RequestParam String reason) {
|
|
999
|
-
return ResponseEntity.ok(journalUseCase.cancelJournal(journalNumber, reason));
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
@PostMapping("/{journalNumber}/correct")
|
|
1003
|
-
@Operation(summary = "仕訳訂正", description = "仕訳を赤黒処理で訂正します")
|
|
1004
|
-
public ResponseEntity<JournalCorrectionResult> correctJournal(
|
|
1005
|
-
@PathVariable String journalNumber,
|
|
1006
|
-
@RequestParam String reason,
|
|
1007
|
-
@Valid @RequestBody CreateJournalCommand correctedData) {
|
|
1008
|
-
return ResponseEntity.ok(journalUseCase.correctJournal(journalNumber, correctedData, reason));
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
```
|
|
1012
|
-
|
|
1013
|
-
</details>
|
|
1014
|
-
|
|
1015
|
-
### 21.5.2 残高照会 API
|
|
1016
|
-
|
|
1017
|
-
<details>
|
|
1018
|
-
<summary>BalanceController</summary>
|
|
1019
|
-
|
|
1020
|
-
```java
|
|
1021
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/BalanceController.java
|
|
1022
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1023
|
-
|
|
1024
|
-
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
1025
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
1026
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
1027
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
1028
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
1029
|
-
import lombok.RequiredArgsConstructor;
|
|
1030
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
1031
|
-
import org.springframework.http.ResponseEntity;
|
|
1032
|
-
import org.springframework.web.bind.annotation.*;
|
|
1033
|
-
|
|
1034
|
-
import java.time.LocalDate;
|
|
1035
|
-
import java.util.List;
|
|
1036
|
-
|
|
1037
|
-
@RestController
|
|
1038
|
-
@RequestMapping("/api/balances")
|
|
1039
|
-
@RequiredArgsConstructor
|
|
1040
|
-
@Tag(name = "残高照会", description = "勘定科目残高の照会API")
|
|
1041
|
-
public class BalanceController {
|
|
1042
|
-
|
|
1043
|
-
private final BalanceUseCase balanceUseCase;
|
|
1044
|
-
|
|
1045
|
-
@GetMapping("/daily")
|
|
1046
|
-
@Operation(summary = "日次残高取得", description = "指定日の勘定科目残高を取得します")
|
|
1047
|
-
public ResponseEntity<List<DailyBalanceResponse>> getDailyBalances(
|
|
1048
|
-
@Parameter(description = "対象日")
|
|
1049
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
|
|
1050
|
-
@Parameter(description = "勘定科目コード(省略時は全科目)")
|
|
1051
|
-
@RequestParam(required = false) String accountCode) {
|
|
1052
|
-
return ResponseEntity.ok(balanceUseCase.getDailyBalances(date, accountCode));
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
@GetMapping("/monthly")
|
|
1056
|
-
@Operation(summary = "月次残高取得", description = "指定月の勘定科目残高を取得します")
|
|
1057
|
-
public ResponseEntity<List<MonthlyBalanceResponse>> getMonthlyBalances(
|
|
1058
|
-
@Parameter(description = "決算期")
|
|
1059
|
-
@RequestParam int fiscalYear,
|
|
1060
|
-
@Parameter(description = "月度")
|
|
1061
|
-
@RequestParam int month) {
|
|
1062
|
-
return ResponseEntity.ok(balanceUseCase.getMonthlyBalances(fiscalYear, month));
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
@GetMapping("/accounts/{accountCode}")
|
|
1066
|
-
@Operation(summary = "勘定科目別残高取得", description = "勘定科目の期間別残高を取得します")
|
|
1067
|
-
public ResponseEntity<AccountBalanceSummary> getAccountBalanceSummary(
|
|
1068
|
-
@PathVariable String accountCode,
|
|
1069
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
1070
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate) {
|
|
1071
|
-
return ResponseEntity.ok(balanceUseCase.getAccountBalanceSummary(accountCode, fromDate, toDate));
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
```
|
|
1075
|
-
|
|
1076
|
-
</details>
|
|
1077
|
-
|
|
1078
|
-
## 21.6 エラーハンドリング
|
|
1079
|
-
|
|
1080
|
-
### 21.6.1 ドメイン例外
|
|
1081
|
-
|
|
1082
|
-
<details>
|
|
1083
|
-
<summary>ドメイン例外クラス</summary>
|
|
1084
|
-
|
|
1085
|
-
```java
|
|
1086
|
-
// src/main/java/com/example/accounting/domain/exception/AccountingException.java
|
|
1087
|
-
package com.example.accounting.domain.exception;
|
|
1088
|
-
|
|
1089
|
-
import lombok.Getter;
|
|
1090
|
-
|
|
1091
|
-
@Getter
|
|
1092
|
-
public abstract class AccountingException extends RuntimeException {
|
|
1093
|
-
private final String errorCode;
|
|
1094
|
-
|
|
1095
|
-
protected AccountingException(String errorCode, String message) {
|
|
1096
|
-
super(message);
|
|
1097
|
-
this.errorCode = errorCode;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
// AccountNotFoundException.java
|
|
1102
|
-
package com.example.accounting.domain.exception;
|
|
1103
|
-
|
|
1104
|
-
public class AccountNotFoundException extends AccountingException {
|
|
1105
|
-
public AccountNotFoundException(String accountCode) {
|
|
1106
|
-
super("ACC001", "勘定科目が見つかりません: " + accountCode);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
// JournalBalanceException.java
|
|
1111
|
-
package com.example.accounting.domain.exception;
|
|
1112
|
-
|
|
1113
|
-
import java.math.BigDecimal;
|
|
1114
|
-
|
|
1115
|
-
public class JournalBalanceException extends AccountingException {
|
|
1116
|
-
public JournalBalanceException(BigDecimal debit, BigDecimal credit) {
|
|
1117
|
-
super("JNL001", String.format("貸借が一致しません。借方合計: %s, 貸方合計: %s", debit, credit));
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
|
-
// AccountAlreadyExistsException.java
|
|
1122
|
-
package com.example.accounting.domain.exception;
|
|
1123
|
-
|
|
1124
|
-
public class AccountAlreadyExistsException extends AccountingException {
|
|
1125
|
-
public AccountAlreadyExistsException(String accountCode) {
|
|
1126
|
-
super("ACC002", "勘定科目は既に存在します: " + accountCode);
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
```
|
|
1130
|
-
|
|
1131
|
-
</details>
|
|
1132
|
-
|
|
1133
|
-
### 21.6.2 グローバル例外ハンドラー
|
|
1134
|
-
|
|
1135
|
-
<details>
|
|
1136
|
-
<summary>GlobalExceptionHandler</summary>
|
|
1137
|
-
|
|
1138
|
-
```java
|
|
1139
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/GlobalExceptionHandler.java
|
|
1140
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1141
|
-
|
|
1142
|
-
import com.example.accounting.domain.exception.*;
|
|
1143
|
-
import lombok.Builder;
|
|
1144
|
-
import lombok.Data;
|
|
1145
|
-
import lombok.extern.slf4j.Slf4j;
|
|
1146
|
-
import org.springframework.http.HttpStatus;
|
|
1147
|
-
import org.springframework.http.ResponseEntity;
|
|
1148
|
-
import org.springframework.validation.FieldError;
|
|
1149
|
-
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
1150
|
-
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
1151
|
-
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
1152
|
-
|
|
1153
|
-
import java.time.LocalDateTime;
|
|
1154
|
-
import java.util.HashMap;
|
|
1155
|
-
import java.util.Map;
|
|
1156
|
-
|
|
1157
|
-
@RestControllerAdvice
|
|
1158
|
-
@Slf4j
|
|
1159
|
-
public class GlobalExceptionHandler {
|
|
1160
|
-
|
|
1161
|
-
@ExceptionHandler(AccountNotFoundException.class)
|
|
1162
|
-
public ResponseEntity<ErrorResponse> handleAccountNotFoundException(AccountNotFoundException e) {
|
|
1163
|
-
log.warn("Account not found: {}", e.getMessage());
|
|
1164
|
-
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1165
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
@ExceptionHandler(AccountAlreadyExistsException.class)
|
|
1169
|
-
public ResponseEntity<ErrorResponse> handleAccountAlreadyExistsException(AccountAlreadyExistsException e) {
|
|
1170
|
-
log.warn("Account already exists: {}", e.getMessage());
|
|
1171
|
-
return ResponseEntity.status(HttpStatus.CONFLICT)
|
|
1172
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
@ExceptionHandler(JournalBalanceException.class)
|
|
1176
|
-
public ResponseEntity<ErrorResponse> handleJournalBalanceException(JournalBalanceException e) {
|
|
1177
|
-
log.warn("Journal balance error: {}", e.getMessage());
|
|
1178
|
-
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1179
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
1183
|
-
public ResponseEntity<ValidationErrorResponse> handleValidationException(MethodArgumentNotValidException e) {
|
|
1184
|
-
log.warn("Validation error: {}", e.getMessage());
|
|
1185
|
-
|
|
1186
|
-
Map<String, String> errors = new HashMap<>();
|
|
1187
|
-
e.getBindingResult().getAllErrors().forEach(error -> {
|
|
1188
|
-
String fieldName = ((FieldError) error).getField();
|
|
1189
|
-
String errorMessage = error.getDefaultMessage();
|
|
1190
|
-
errors.put(fieldName, errorMessage);
|
|
1191
|
-
});
|
|
1192
|
-
|
|
1193
|
-
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1194
|
-
.body(ValidationErrorResponse.builder()
|
|
1195
|
-
.errorCode("VAL001")
|
|
1196
|
-
.message("入力値が不正です")
|
|
1197
|
-
.timestamp(LocalDateTime.now())
|
|
1198
|
-
.errors(errors)
|
|
1199
|
-
.build());
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
@ExceptionHandler(Exception.class)
|
|
1203
|
-
public ResponseEntity<ErrorResponse> handleGenericException(Exception e) {
|
|
1204
|
-
log.error("Unexpected error", e);
|
|
1205
|
-
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
1206
|
-
.body(createErrorResponse("SYS001", "システムエラーが発生しました"));
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
|
-
private ErrorResponse createErrorResponse(String errorCode, String message) {
|
|
1210
|
-
return ErrorResponse.builder()
|
|
1211
|
-
.errorCode(errorCode)
|
|
1212
|
-
.message(message)
|
|
1213
|
-
.timestamp(LocalDateTime.now())
|
|
1214
|
-
.build();
|
|
1215
|
-
}
|
|
1216
|
-
|
|
1217
|
-
@Data
|
|
1218
|
-
@Builder
|
|
1219
|
-
public static class ErrorResponse {
|
|
1220
|
-
private String errorCode;
|
|
1221
|
-
private String message;
|
|
1222
|
-
private LocalDateTime timestamp;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
@Data
|
|
1226
|
-
@Builder
|
|
1227
|
-
public static class ValidationErrorResponse {
|
|
1228
|
-
private String errorCode;
|
|
1229
|
-
private String message;
|
|
1230
|
-
private LocalDateTime timestamp;
|
|
1231
|
-
private Map<String, String> errors;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
```
|
|
1235
|
-
|
|
1236
|
-
</details>
|
|
1237
|
-
|
|
1238
|
-
## 21.7 統合テスト
|
|
1239
|
-
|
|
1240
|
-
<details>
|
|
1241
|
-
<summary>AccountControllerIntegrationTest</summary>
|
|
1242
|
-
|
|
1243
|
-
```java
|
|
1244
|
-
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerIntegrationTest.java
|
|
1245
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1246
|
-
|
|
1247
|
-
import com.example.accounting.application.port.in.dto.CreateAccountCommand;
|
|
1248
|
-
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
1249
|
-
import org.junit.jupiter.api.*;
|
|
1250
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
1251
|
-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
1252
|
-
import org.springframework.boot.test.context.SpringBootTest;
|
|
1253
|
-
import org.springframework.http.MediaType;
|
|
1254
|
-
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1255
|
-
import org.springframework.test.context.DynamicPropertySource;
|
|
1256
|
-
import org.springframework.test.web.servlet.MockMvc;
|
|
1257
|
-
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1258
|
-
import org.testcontainers.junit.jupiter.Container;
|
|
1259
|
-
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1260
|
-
|
|
1261
|
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
1262
|
-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
1263
|
-
|
|
1264
|
-
@SpringBootTest
|
|
1265
|
-
@AutoConfigureMockMvc
|
|
1266
|
-
@Testcontainers
|
|
1267
|
-
@DisplayName("勘定科目 API 統合テスト")
|
|
1268
|
-
class AccountControllerIntegrationTest {
|
|
1269
|
-
|
|
1270
|
-
@Container
|
|
1271
|
-
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1272
|
-
.withDatabaseName("testdb")
|
|
1273
|
-
.withUsername("testuser")
|
|
1274
|
-
.withPassword("testpass");
|
|
1275
|
-
|
|
1276
|
-
@DynamicPropertySource
|
|
1277
|
-
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1278
|
-
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1279
|
-
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1280
|
-
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
@Autowired
|
|
1284
|
-
private MockMvc mockMvc;
|
|
1285
|
-
|
|
1286
|
-
@Autowired
|
|
1287
|
-
private ObjectMapper objectMapper;
|
|
1288
|
-
|
|
1289
|
-
@Nested
|
|
1290
|
-
@DisplayName("勘定科目 CRUD")
|
|
1291
|
-
class AccountCrud {
|
|
1292
|
-
|
|
1293
|
-
@Test
|
|
1294
|
-
@DisplayName("勘定科目の登録・取得・更新・削除が正常に動作する")
|
|
1295
|
-
void crudOperationsWork() throws Exception {
|
|
1296
|
-
// Create
|
|
1297
|
-
CreateAccountCommand createCommand = CreateAccountCommand.builder()
|
|
1298
|
-
.accountCode("99999")
|
|
1299
|
-
.accountName("テスト科目")
|
|
1300
|
-
.accountShortName("テスト")
|
|
1301
|
-
.bsPlType("BS")
|
|
1302
|
-
.dcType("借方")
|
|
1303
|
-
.elementType("資産")
|
|
1304
|
-
.summaryType("計上科目")
|
|
1305
|
-
.build();
|
|
1306
|
-
|
|
1307
|
-
mockMvc.perform(post("/api/accounts")
|
|
1308
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
1309
|
-
.content(objectMapper.writeValueAsString(createCommand)))
|
|
1310
|
-
.andExpect(status().isCreated())
|
|
1311
|
-
.andExpect(jsonPath("$.accountCode").value("99999"))
|
|
1312
|
-
.andExpect(jsonPath("$.accountName").value("テスト科目"));
|
|
1313
|
-
|
|
1314
|
-
// Read
|
|
1315
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1316
|
-
.andExpect(status().isOk())
|
|
1317
|
-
.andExpect(jsonPath("$.accountCode").value("99999"));
|
|
1318
|
-
|
|
1319
|
-
// Delete
|
|
1320
|
-
mockMvc.perform(delete("/api/accounts/{accountCode}", "99999"))
|
|
1321
|
-
.andExpect(status().isNoContent());
|
|
1322
|
-
|
|
1323
|
-
// Verify deleted
|
|
1324
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1325
|
-
.andExpect(status().isNotFound());
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
```
|
|
1330
|
-
|
|
1331
|
-
</details>
|
|
1332
|
-
|
|
1333
|
-
## 21.8 OpenAPI 設定
|
|
1334
|
-
|
|
1335
|
-
<details>
|
|
1336
|
-
<summary>OpenApiConfig</summary>
|
|
1337
|
-
|
|
1338
|
-
```java
|
|
1339
|
-
// src/main/java/com/example/accounting/infrastructure/config/OpenApiConfig.java
|
|
1340
|
-
package com.example.accounting.infrastructure.config;
|
|
1341
|
-
|
|
1342
|
-
import io.swagger.v3.oas.models.OpenAPI;
|
|
1343
|
-
import io.swagger.v3.oas.models.info.Contact;
|
|
1344
|
-
import io.swagger.v3.oas.models.info.Info;
|
|
1345
|
-
import io.swagger.v3.oas.models.info.License;
|
|
1346
|
-
import io.swagger.v3.oas.models.servers.Server;
|
|
1347
|
-
import org.springframework.context.annotation.Bean;
|
|
1348
|
-
import org.springframework.context.annotation.Configuration;
|
|
1349
|
-
|
|
1350
|
-
import java.util.List;
|
|
1351
|
-
|
|
1352
|
-
@Configuration
|
|
1353
|
-
public class OpenApiConfig {
|
|
1354
|
-
|
|
1355
|
-
@Bean
|
|
1356
|
-
public OpenAPI customOpenAPI() {
|
|
1357
|
-
return new OpenAPI()
|
|
1358
|
-
.info(new Info()
|
|
1359
|
-
.title("財務会計システム API")
|
|
1360
|
-
.description("財務会計システムのREST API仕様書(JPA版)")
|
|
1361
|
-
.version("1.0.0")
|
|
1362
|
-
.contact(new Contact()
|
|
1363
|
-
.name("開発チーム")
|
|
1364
|
-
.email("dev@example.com"))
|
|
1365
|
-
.license(new License()
|
|
1366
|
-
.name("MIT License")
|
|
1367
|
-
.url("https://opensource.org/licenses/MIT")))
|
|
1368
|
-
.servers(List.of(
|
|
1369
|
-
new Server().url("http://localhost:8080").description("開発環境"),
|
|
1370
|
-
new Server().url("https://api.example.com").description("本番環境")
|
|
1371
|
-
));
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
```
|
|
1375
|
-
|
|
1376
|
-
</details>
|
|
1377
|
-
|
|
1378
|
-
API ドキュメントへのアクセス:
|
|
1379
|
-
- **Swagger UI**: http://localhost:8080/swagger-ui.html
|
|
1380
|
-
- **OpenAPI JSON**: http://localhost:8080/api-docs
|
|
1381
|
-
|
|
1382
|
-
## まとめ
|
|
1383
|
-
|
|
1384
|
-
### MyBatis 版との違い
|
|
1385
|
-
|
|
1386
|
-
| 観点 | MyBatis 版 | JPA 版 |
|
|
1387
|
-
|------|-----------|--------|
|
|
1388
|
-
| Output Port 実装 | Mapper + XML | JpaRepository + Adapter |
|
|
1389
|
-
| クエリ定義 | XML に SQL | @Query or メソッド名規約 |
|
|
1390
|
-
| トランザクション | @Transactional | @Transactional(同一) |
|
|
1391
|
-
| N+1 対策 | JOIN を XML で記述 | @EntityGraph |
|
|
1392
|
-
| 動的クエリ | `<if>` タグ | Specification |
|
|
1393
|
-
| テスト | @MybatisTest | @DataJpaTest |
|
|
1394
|
-
|
|
1395
|
-
### JPA 固有の実装ポイント
|
|
1396
|
-
|
|
1397
|
-
1. **Repository Adapter パターン**
|
|
1398
|
-
```java
|
|
1399
|
-
@Component
|
|
1400
|
-
@RequiredArgsConstructor
|
|
1401
|
-
public class AccountRepositoryAdapter implements AccountRepository {
|
|
1402
|
-
private final AccountJpaRepository jpaRepository;
|
|
1403
|
-
|
|
1404
|
-
@Override
|
|
1405
|
-
public Optional<Account> findByCode(String accountCode) {
|
|
1406
|
-
return jpaRepository.findById(accountCode);
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
```
|
|
1410
|
-
|
|
1411
|
-
2. **@Query によるカスタムクエリ**
|
|
1412
|
-
```java
|
|
1413
|
-
@Query("SELECT a FROM Account a JOIN AccountStructure s ON a.accountCode = s.accountCode " +
|
|
1414
|
-
"WHERE s.accountPath LIKE CONCAT(:pathPrefix, '%') ORDER BY a.accountCode")
|
|
1415
|
-
List<Account> findByAccountPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
1416
|
-
```
|
|
1417
|
-
|
|
1418
|
-
3. **existsById() による存在確認**
|
|
1419
|
-
```java
|
|
1420
|
-
@Override
|
|
1421
|
-
public boolean exists(String accountCode) {
|
|
1422
|
-
return jpaRepository.existsById(accountCode);
|
|
1423
|
-
}
|
|
1424
|
-
```
|
|
1425
|
-
|
|
1426
|
-
### API エンドポイント一覧
|
|
1427
|
-
|
|
1428
|
-
| メソッド | パス | 説明 |
|
|
1429
|
-
|---------|------|------|
|
|
1430
|
-
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
1431
|
-
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
1432
|
-
| POST | /api/accounts | 勘定科目登録 |
|
|
1433
|
-
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
1434
|
-
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
1435
|
-
| GET | /api/journals | 仕訳一覧取得 |
|
|
1436
|
-
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
1437
|
-
| POST | /api/journals | 仕訳登録 |
|
|
1438
|
-
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消 |
|
|
1439
|
-
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正 |
|
|
1440
|
-
| GET | /api/balances/daily | 日次残高取得 |
|
|
1441
|
-
| GET | /api/balances/monthly | 月次残高取得 |
|
|
1442
|
-
| GET | /api/reports/daily-report | 日計表取得 |
|
|
1443
|
-
| GET | /api/reports/trial-balance | 合計残高試算表取得 |
|
|
1444
|
-
|
|
1445
|
-
---
|
|
1446
|
-
|
|
1447
|
-
[← 第20章:財務会計データ設計(D社事例)【ORM版】](./chapter20-orm.md) | [第22章:生産管理システムの全体像 →](../part4/chapter22.md)
|
|
1
|
+
# 第21章:APIサービスの実装【ORM版】
|
|
2
|
+
|
|
3
|
+
本章では、財務会計システムの API サービスを TDD で実装します。ヘキサゴナルアーキテクチャに基づき、Spring Data JPA を使用した勘定科目マスタ API、仕訳 API、残高照会 API を構築します。
|
|
4
|
+
|
|
5
|
+
## 21.1 ヘキサゴナルアーキテクチャ
|
|
6
|
+
|
|
7
|
+
### 21.1.1 Ports and Adapters パターン
|
|
8
|
+
|
|
9
|
+
ヘキサゴナルアーキテクチャは、ドメインロジックを外部の技術的関心事から分離するアーキテクチャパターンです。
|
|
10
|
+
|
|
11
|
+
```plantuml
|
|
12
|
+
@startuml
|
|
13
|
+
|
|
14
|
+
title ヘキサゴナルアーキテクチャ(JPA版)
|
|
15
|
+
|
|
16
|
+
skinparam hexagon {
|
|
17
|
+
BackgroundColor #E8F5E9
|
|
18
|
+
BorderColor #4CAF50
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
rectangle "Infrastructure (Outside)" #F5F5F5 {
|
|
22
|
+
rectangle "Web Adapter\n(REST API)" as web #BBDEFB
|
|
23
|
+
rectangle "DB Adapter\n(Spring Data JPA)" as db #BBDEFB
|
|
24
|
+
rectangle "External API\n(外部連携)" as ext #BBDEFB
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
hexagon "Application Core" as core {
|
|
28
|
+
rectangle "Domain\n(ビジネスロジック)" as domain #C8E6C9
|
|
29
|
+
rectangle "Application\n(ユースケース)" as app #C8E6C9
|
|
30
|
+
|
|
31
|
+
rectangle "Input Port\n(UseCase IF)" as inport #FFF9C4
|
|
32
|
+
rectangle "Output Port\n(Repository IF)" as outport #FFF9C4
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
web --> inport : Controller
|
|
36
|
+
inport --> app
|
|
37
|
+
app --> domain
|
|
38
|
+
app --> outport
|
|
39
|
+
outport --> db : JpaRepository
|
|
40
|
+
ext --> inport
|
|
41
|
+
|
|
42
|
+
note bottom of core
|
|
43
|
+
ドメインロジックは
|
|
44
|
+
外部技術から独立
|
|
45
|
+
(JPA/MyBatis に非依存)
|
|
46
|
+
end note
|
|
47
|
+
|
|
48
|
+
@enduml
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 21.1.2 アーキテクチャの利点
|
|
52
|
+
|
|
53
|
+
| 利点 | 説明 |
|
|
54
|
+
|------|------|
|
|
55
|
+
| **テスト容易性** | ドメインロジックを単独でテスト可能 |
|
|
56
|
+
| **技術独立性** | DB、フレームワークの変更が容易 |
|
|
57
|
+
| **可読性** | 責務が明確に分離される |
|
|
58
|
+
| **保守性** | 変更の影響範囲が限定される |
|
|
59
|
+
|
|
60
|
+
## 21.2 アーキテクチャ構造(JPA版)
|
|
61
|
+
|
|
62
|
+
### 21.2.1 パッケージ構成
|
|
63
|
+
|
|
64
|
+
```plantuml
|
|
65
|
+
@startuml
|
|
66
|
+
|
|
67
|
+
title パッケージ構成(JPA版)
|
|
68
|
+
|
|
69
|
+
package "com.example.accounting" {
|
|
70
|
+
|
|
71
|
+
package "domain" {
|
|
72
|
+
package "model" {
|
|
73
|
+
class Account
|
|
74
|
+
class Journal
|
|
75
|
+
class Balance
|
|
76
|
+
}
|
|
77
|
+
package "service" {
|
|
78
|
+
class JournalDomainService
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
package "application" {
|
|
83
|
+
package "port.in" {
|
|
84
|
+
interface AccountUseCase
|
|
85
|
+
interface JournalUseCase
|
|
86
|
+
}
|
|
87
|
+
package "port.out" {
|
|
88
|
+
interface AccountRepository
|
|
89
|
+
interface JournalRepository
|
|
90
|
+
}
|
|
91
|
+
package "service" {
|
|
92
|
+
class AccountApplicationService
|
|
93
|
+
class JournalApplicationService
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
package "infrastructure" {
|
|
98
|
+
package "adapter.in.web" {
|
|
99
|
+
class AccountController
|
|
100
|
+
class JournalController
|
|
101
|
+
}
|
|
102
|
+
package "adapter.out.persistence" {
|
|
103
|
+
class AccountJpaRepository
|
|
104
|
+
class JournalJpaRepository
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
AccountUseCase <|.. AccountApplicationService
|
|
110
|
+
AccountRepository <|.. AccountJpaRepository
|
|
111
|
+
AccountController --> AccountUseCase
|
|
112
|
+
AccountApplicationService --> AccountRepository
|
|
113
|
+
|
|
114
|
+
note right of AccountJpaRepository
|
|
115
|
+
extends JpaRepository<Account, String>
|
|
116
|
+
Spring Data JPA により自動実装
|
|
117
|
+
end note
|
|
118
|
+
|
|
119
|
+
@enduml
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 21.2.2 各レイヤーの責務
|
|
123
|
+
|
|
124
|
+
```plantuml
|
|
125
|
+
@startuml
|
|
126
|
+
|
|
127
|
+
title 各層の責務(JPA版)
|
|
128
|
+
|
|
129
|
+
rectangle "Infrastructure Layer (Adapter)" #BBDEFB {
|
|
130
|
+
card "**入力アダプター**\n・REST Controller\n・リクエスト変換\n・レスポンス生成\n・@Valid バリデーション" as in_adapter
|
|
131
|
+
|
|
132
|
+
card "**出力アダプター**\n・JpaRepository 実装\n・@Query カスタムクエリ\n・Specification 動的クエリ\n・@EntityGraph N+1対策" as out_adapter
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
rectangle "Application Layer (Port + UseCase)" #FFF9C4 {
|
|
136
|
+
card "**入力ポート**\n・UseCase インターフェース\n・DTO定義\n・コマンド/クエリ" as in_port
|
|
137
|
+
|
|
138
|
+
card "**出力ポート**\n・Repository インターフェース\n・永続化抽象\n・外部連携抽象" as out_port
|
|
139
|
+
|
|
140
|
+
card "**アプリケーションサービス**\n・ユースケース実装\n・@Transactional 制御\n・ドメイン調整" as app_service
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
rectangle "Domain Layer" #C8E6C9 {
|
|
144
|
+
card "**エンティティ**\n・@Entity アノテーション\n・ビジネスルール\n・状態管理" as entity
|
|
145
|
+
|
|
146
|
+
card "**値オブジェクト**\n・@Embeddable\n・不変性\n・同値性" as vo
|
|
147
|
+
|
|
148
|
+
card "**ドメインサービス**\n・複数エンティティ操作\n・ドメインロジック" as domain_service
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
in_adapter --> in_port
|
|
152
|
+
app_service --> out_port
|
|
153
|
+
out_port --> out_adapter
|
|
154
|
+
app_service --> entity
|
|
155
|
+
app_service --> domain_service
|
|
156
|
+
|
|
157
|
+
@enduml
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## 21.3 マスタ API の実装
|
|
161
|
+
|
|
162
|
+
### 21.3.1 API エンドポイント設計
|
|
163
|
+
|
|
164
|
+
| メソッド | パス | 説明 |
|
|
165
|
+
|---------|------|------|
|
|
166
|
+
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
167
|
+
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
168
|
+
| GET | /api/accounts/{accountCode}/hierarchy | 科目階層取得 |
|
|
169
|
+
| POST | /api/accounts | 勘定科目登録 |
|
|
170
|
+
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
171
|
+
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
172
|
+
|
|
173
|
+
### 21.3.2 Output Port(リポジトリインターフェース)
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary>AccountRepository(Output Port)</summary>
|
|
177
|
+
|
|
178
|
+
```java
|
|
179
|
+
// src/main/java/com/example/accounting/application/port/out/AccountRepository.java
|
|
180
|
+
package com.example.accounting.application.port.out;
|
|
181
|
+
|
|
182
|
+
import com.example.accounting.domain.model.account.Account;
|
|
183
|
+
|
|
184
|
+
import java.util.List;
|
|
185
|
+
import java.util.Optional;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* 勘定科目リポジトリ(Output Port)
|
|
189
|
+
*
|
|
190
|
+
* ヘキサゴナルアーキテクチャにおける出力ポート。
|
|
191
|
+
* アプリケーション層から永続化層への依存を抽象化する。
|
|
192
|
+
*/
|
|
193
|
+
public interface AccountRepository {
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 勘定科目コードで検索
|
|
197
|
+
*/
|
|
198
|
+
Optional<Account> findByCode(String accountCode);
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 全件取得
|
|
202
|
+
*/
|
|
203
|
+
List<Account> findAll();
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* BSPL区分で検索
|
|
207
|
+
*/
|
|
208
|
+
List<Account> findByBsPlType(String bsPlType);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* 科目パスで検索(チルダ連結方式)
|
|
212
|
+
*/
|
|
213
|
+
List<Account> findByPathLike(String pathPattern);
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* 計上科目のみ取得
|
|
217
|
+
*/
|
|
218
|
+
List<Account> findPostingAccounts();
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 保存(新規・更新)
|
|
222
|
+
*/
|
|
223
|
+
Account save(Account account);
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* 削除
|
|
227
|
+
*/
|
|
228
|
+
void delete(String accountCode);
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 存在確認
|
|
232
|
+
*/
|
|
233
|
+
boolean exists(String accountCode);
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
</details>
|
|
238
|
+
|
|
239
|
+
### 21.3.3 JPA Repository 実装
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
<summary>AccountJpaRepository</summary>
|
|
243
|
+
|
|
244
|
+
```java
|
|
245
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/out/persistence/AccountJpaRepository.java
|
|
246
|
+
package com.example.accounting.infrastructure.adapter.out.persistence;
|
|
247
|
+
|
|
248
|
+
import com.example.accounting.domain.model.account.Account;
|
|
249
|
+
import com.example.accounting.domain.model.account.BsPlType;
|
|
250
|
+
import com.example.accounting.domain.model.account.SummaryType;
|
|
251
|
+
import org.springframework.data.jpa.repository.JpaRepository;
|
|
252
|
+
import org.springframework.data.jpa.repository.Query;
|
|
253
|
+
import org.springframework.data.repository.query.Param;
|
|
254
|
+
import org.springframework.stereotype.Repository;
|
|
255
|
+
|
|
256
|
+
import java.util.List;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 勘定科目 JPA リポジトリ
|
|
260
|
+
*
|
|
261
|
+
* Spring Data JPA により基本的な CRUD 操作は自動生成される。
|
|
262
|
+
* カスタムクエリは @Query アノテーションで定義。
|
|
263
|
+
*/
|
|
264
|
+
@Repository
|
|
265
|
+
public interface AccountJpaRepository extends JpaRepository<Account, String> {
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* BSPL区分で検索
|
|
269
|
+
*/
|
|
270
|
+
List<Account> findByBsPlType(BsPlType bsPlType);
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 科目パスで前方一致検索(勘定科目構成マスタ経由)
|
|
274
|
+
*/
|
|
275
|
+
@Query("SELECT a FROM Account a JOIN AccountStructure s ON a.accountCode = s.accountCode " +
|
|
276
|
+
"WHERE s.accountPath LIKE CONCAT(:pathPrefix, '%') ORDER BY a.accountCode")
|
|
277
|
+
List<Account> findByAccountPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 計上科目のみ取得
|
|
281
|
+
*/
|
|
282
|
+
List<Account> findBySummaryType(SummaryType summaryType);
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 計上科目のみ取得(便利メソッド)
|
|
286
|
+
*/
|
|
287
|
+
default List<Account> findPostingAccounts() {
|
|
288
|
+
return findBySummaryType(SummaryType.POSTING);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 勘定科目コード順で全件取得
|
|
293
|
+
*/
|
|
294
|
+
List<Account> findAllByOrderByAccountCodeAsc();
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
</details>
|
|
299
|
+
|
|
300
|
+
### 21.3.4 Repository アダプター
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary>AccountRepositoryAdapter</summary>
|
|
304
|
+
|
|
305
|
+
```java
|
|
306
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/out/persistence/AccountRepositoryAdapter.java
|
|
307
|
+
package com.example.accounting.infrastructure.adapter.out.persistence;
|
|
308
|
+
|
|
309
|
+
import com.example.accounting.application.port.out.AccountRepository;
|
|
310
|
+
import com.example.accounting.domain.model.account.Account;
|
|
311
|
+
import com.example.accounting.domain.model.account.BsPlType;
|
|
312
|
+
import lombok.RequiredArgsConstructor;
|
|
313
|
+
import org.springframework.stereotype.Component;
|
|
314
|
+
|
|
315
|
+
import java.util.List;
|
|
316
|
+
import java.util.Optional;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 勘定科目リポジトリアダプター
|
|
320
|
+
*
|
|
321
|
+
* Output Port(AccountRepository)の実装。
|
|
322
|
+
* JpaRepository をラップしてドメインのインターフェースに適合させる。
|
|
323
|
+
*/
|
|
324
|
+
@Component
|
|
325
|
+
@RequiredArgsConstructor
|
|
326
|
+
public class AccountRepositoryAdapter implements AccountRepository {
|
|
327
|
+
|
|
328
|
+
private final AccountJpaRepository jpaRepository;
|
|
329
|
+
|
|
330
|
+
@Override
|
|
331
|
+
public Optional<Account> findByCode(String accountCode) {
|
|
332
|
+
return jpaRepository.findById(accountCode);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@Override
|
|
336
|
+
public List<Account> findAll() {
|
|
337
|
+
return jpaRepository.findAllByOrderByAccountCodeAsc();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@Override
|
|
341
|
+
public List<Account> findByBsPlType(String bsPlType) {
|
|
342
|
+
return jpaRepository.findByBsPlType(BsPlType.valueOf(bsPlType));
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@Override
|
|
346
|
+
public List<Account> findByPathLike(String pathPattern) {
|
|
347
|
+
String prefix = pathPattern.replace("%", "");
|
|
348
|
+
return jpaRepository.findByAccountPathStartsWith(prefix);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
@Override
|
|
352
|
+
public List<Account> findPostingAccounts() {
|
|
353
|
+
return jpaRepository.findPostingAccounts();
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@Override
|
|
357
|
+
public Account save(Account account) {
|
|
358
|
+
return jpaRepository.save(account);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@Override
|
|
362
|
+
public void delete(String accountCode) {
|
|
363
|
+
jpaRepository.deleteById(accountCode);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
@Override
|
|
367
|
+
public boolean exists(String accountCode) {
|
|
368
|
+
return jpaRepository.existsById(accountCode);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
</details>
|
|
374
|
+
|
|
375
|
+
### 21.3.5 Input Port(ユースケースインターフェース)
|
|
376
|
+
|
|
377
|
+
<details>
|
|
378
|
+
<summary>AccountUseCase(Input Port)</summary>
|
|
379
|
+
|
|
380
|
+
```java
|
|
381
|
+
// src/main/java/com/example/accounting/application/port/in/AccountUseCase.java
|
|
382
|
+
package com.example.accounting.application.port.in;
|
|
383
|
+
|
|
384
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
385
|
+
|
|
386
|
+
import java.util.List;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 勘定科目ユースケース(Input Port)
|
|
390
|
+
*/
|
|
391
|
+
public interface AccountUseCase {
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* 勘定科目を取得
|
|
395
|
+
*/
|
|
396
|
+
AccountResponse getAccount(String accountCode);
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* 全勘定科目を取得
|
|
400
|
+
*/
|
|
401
|
+
List<AccountResponse> getAllAccounts();
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* BS/PL区分で勘定科目を取得
|
|
405
|
+
*/
|
|
406
|
+
List<AccountResponse> getAccountsByBsPlType(String bsPlType);
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* 科目階層を取得(親科目以下の全科目)
|
|
410
|
+
*/
|
|
411
|
+
List<AccountResponse> getAccountHierarchy(String parentAccountCode);
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* 計上科目のみ取得
|
|
415
|
+
*/
|
|
416
|
+
List<AccountResponse> getPostingAccounts();
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* 勘定科目を登録
|
|
420
|
+
*/
|
|
421
|
+
AccountResponse createAccount(CreateAccountCommand command);
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* 勘定科目を更新
|
|
425
|
+
*/
|
|
426
|
+
AccountResponse updateAccount(String accountCode, UpdateAccountCommand command);
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* 勘定科目を削除
|
|
430
|
+
*/
|
|
431
|
+
void deleteAccount(String accountCode);
|
|
432
|
+
}
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
</details>
|
|
436
|
+
|
|
437
|
+
### 21.3.6 コマンド・レスポンス DTO
|
|
438
|
+
|
|
439
|
+
<details>
|
|
440
|
+
<summary>CreateAccountCommand</summary>
|
|
441
|
+
|
|
442
|
+
```java
|
|
443
|
+
// src/main/java/com/example/accounting/application/port/in/dto/CreateAccountCommand.java
|
|
444
|
+
package com.example.accounting.application.port.in.dto;
|
|
445
|
+
|
|
446
|
+
import jakarta.validation.constraints.*;
|
|
447
|
+
import lombok.Builder;
|
|
448
|
+
import lombok.Data;
|
|
449
|
+
|
|
450
|
+
@Data
|
|
451
|
+
@Builder
|
|
452
|
+
public class CreateAccountCommand {
|
|
453
|
+
|
|
454
|
+
@NotBlank(message = "勘定科目コードは必須です")
|
|
455
|
+
@Size(max = 5, message = "勘定科目コードは5文字以内です")
|
|
456
|
+
private String accountCode;
|
|
457
|
+
|
|
458
|
+
@NotBlank(message = "勘定科目名は必須です")
|
|
459
|
+
@Size(max = 40, message = "勘定科目名は40文字以内です")
|
|
460
|
+
private String accountName;
|
|
461
|
+
|
|
462
|
+
@Size(max = 10, message = "勘定科目略名は10文字以内です")
|
|
463
|
+
private String accountShortName;
|
|
464
|
+
|
|
465
|
+
@NotBlank(message = "BSPL区分は必須です")
|
|
466
|
+
@Pattern(regexp = "BS|PL", message = "BSPL区分はBS/PLのいずれかです")
|
|
467
|
+
private String bsPlType;
|
|
468
|
+
|
|
469
|
+
@NotBlank(message = "貸借区分は必須です")
|
|
470
|
+
@Pattern(regexp = "借方|貸方", message = "貸借区分は借方/貸方のいずれかです")
|
|
471
|
+
private String dcType;
|
|
472
|
+
|
|
473
|
+
@NotBlank(message = "取引要素区分は必須です")
|
|
474
|
+
private String elementType;
|
|
475
|
+
|
|
476
|
+
@NotBlank(message = "集計区分は必須です")
|
|
477
|
+
private String summaryType;
|
|
478
|
+
|
|
479
|
+
private String managementType;
|
|
480
|
+
private String expenseType;
|
|
481
|
+
private String taxCalculationType;
|
|
482
|
+
private String taxCode;
|
|
483
|
+
private String parentAccountCode;
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
</details>
|
|
488
|
+
|
|
489
|
+
<details>
|
|
490
|
+
<summary>AccountResponse</summary>
|
|
491
|
+
|
|
492
|
+
```java
|
|
493
|
+
// src/main/java/com/example/accounting/application/port/in/dto/AccountResponse.java
|
|
494
|
+
package com.example.accounting.application.port.in.dto;
|
|
495
|
+
|
|
496
|
+
import com.example.accounting.domain.model.account.Account;
|
|
497
|
+
import lombok.Builder;
|
|
498
|
+
import lombok.Data;
|
|
499
|
+
|
|
500
|
+
@Data
|
|
501
|
+
@Builder
|
|
502
|
+
public class AccountResponse {
|
|
503
|
+
private String accountCode;
|
|
504
|
+
private String accountName;
|
|
505
|
+
private String accountShortName;
|
|
506
|
+
private String accountKana;
|
|
507
|
+
private String bsPlType;
|
|
508
|
+
private String dcType;
|
|
509
|
+
private String elementType;
|
|
510
|
+
private String summaryType;
|
|
511
|
+
private String managementType;
|
|
512
|
+
private String expenseType;
|
|
513
|
+
private String taxCalculationType;
|
|
514
|
+
private String taxCode;
|
|
515
|
+
private String accountPath;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* エンティティからレスポンスDTOを生成
|
|
519
|
+
*/
|
|
520
|
+
public static AccountResponse from(Account account) {
|
|
521
|
+
return AccountResponse.builder()
|
|
522
|
+
.accountCode(account.getAccountCode())
|
|
523
|
+
.accountName(account.getAccountName())
|
|
524
|
+
.accountShortName(account.getAccountShortName())
|
|
525
|
+
.accountKana(account.getAccountKana())
|
|
526
|
+
.bsPlType(account.getBsPlType() != null ? account.getBsPlType().name() : null)
|
|
527
|
+
.dcType(account.getDcType() != null ? account.getDcType().getDisplayName() : null)
|
|
528
|
+
.elementType(account.getElementType() != null ? account.getElementType().getDisplayName() : null)
|
|
529
|
+
.summaryType(account.getSummaryType() != null ? account.getSummaryType().getDisplayName() : null)
|
|
530
|
+
.managementType(account.getManagementType() != null ? account.getManagementType().getDisplayName() : null)
|
|
531
|
+
.expenseType(account.getExpenseType() != null ? account.getExpenseType().getDisplayName() : null)
|
|
532
|
+
.taxCalculationType(account.getTaxCalculationType() != null ? account.getTaxCalculationType().getDisplayName() : null)
|
|
533
|
+
.taxCode(account.getTaxCode())
|
|
534
|
+
.build();
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
</details>
|
|
540
|
+
|
|
541
|
+
## 21.4 TDD による実装
|
|
542
|
+
|
|
543
|
+
### 21.4.1 Red: Controller テスト
|
|
544
|
+
|
|
545
|
+
<details>
|
|
546
|
+
<summary>AccountControllerTest</summary>
|
|
547
|
+
|
|
548
|
+
```java
|
|
549
|
+
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerTest.java
|
|
550
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
551
|
+
|
|
552
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
553
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
554
|
+
import com.example.accounting.domain.exception.AccountNotFoundException;
|
|
555
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
556
|
+
import org.junit.jupiter.api.*;
|
|
557
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
558
|
+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|
559
|
+
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
560
|
+
import org.springframework.http.MediaType;
|
|
561
|
+
import org.springframework.test.web.servlet.MockMvc;
|
|
562
|
+
|
|
563
|
+
import java.util.List;
|
|
564
|
+
|
|
565
|
+
import static org.mockito.ArgumentMatchers.*;
|
|
566
|
+
import static org.mockito.BDDMockito.*;
|
|
567
|
+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
568
|
+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
569
|
+
|
|
570
|
+
@WebMvcTest(AccountController.class)
|
|
571
|
+
@DisplayName("勘定科目マスタ API")
|
|
572
|
+
class AccountControllerTest {
|
|
573
|
+
|
|
574
|
+
@Autowired
|
|
575
|
+
private MockMvc mockMvc;
|
|
576
|
+
|
|
577
|
+
@Autowired
|
|
578
|
+
private ObjectMapper objectMapper;
|
|
579
|
+
|
|
580
|
+
@MockBean
|
|
581
|
+
private AccountUseCase accountUseCase;
|
|
582
|
+
|
|
583
|
+
@Nested
|
|
584
|
+
@DisplayName("GET /api/accounts/{accountCode}")
|
|
585
|
+
class GetAccount {
|
|
586
|
+
|
|
587
|
+
@Test
|
|
588
|
+
@DisplayName("勘定科目を取得できる")
|
|
589
|
+
void canGetAccount() throws Exception {
|
|
590
|
+
// Given
|
|
591
|
+
AccountResponse response = AccountResponse.builder()
|
|
592
|
+
.accountCode("11110")
|
|
593
|
+
.accountName("現金")
|
|
594
|
+
.accountShortName("現金")
|
|
595
|
+
.bsPlType("BS")
|
|
596
|
+
.dcType("借方")
|
|
597
|
+
.elementType("資産")
|
|
598
|
+
.summaryType("計上科目")
|
|
599
|
+
.build();
|
|
600
|
+
|
|
601
|
+
given(accountUseCase.getAccount("11110")).willReturn(response);
|
|
602
|
+
|
|
603
|
+
// When & Then
|
|
604
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "11110"))
|
|
605
|
+
.andExpect(status().isOk())
|
|
606
|
+
.andExpect(jsonPath("$.accountCode").value("11110"))
|
|
607
|
+
.andExpect(jsonPath("$.accountName").value("現金"))
|
|
608
|
+
.andExpect(jsonPath("$.bsPlType").value("BS"));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
@Test
|
|
612
|
+
@DisplayName("存在しない勘定科目は404を返す")
|
|
613
|
+
void notFoundForNonExistent() throws Exception {
|
|
614
|
+
// Given
|
|
615
|
+
given(accountUseCase.getAccount("99999")).willThrow(
|
|
616
|
+
new AccountNotFoundException("99999"));
|
|
617
|
+
|
|
618
|
+
// When & Then
|
|
619
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
620
|
+
.andExpect(status().isNotFound());
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
@Nested
|
|
625
|
+
@DisplayName("POST /api/accounts")
|
|
626
|
+
class CreateAccount {
|
|
627
|
+
|
|
628
|
+
@Test
|
|
629
|
+
@DisplayName("勘定科目を登録できる")
|
|
630
|
+
void canCreateAccount() throws Exception {
|
|
631
|
+
// Given
|
|
632
|
+
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
633
|
+
.accountCode("11150")
|
|
634
|
+
.accountName("手許現金")
|
|
635
|
+
.accountShortName("手許現金")
|
|
636
|
+
.bsPlType("BS")
|
|
637
|
+
.dcType("借方")
|
|
638
|
+
.elementType("資産")
|
|
639
|
+
.summaryType("計上科目")
|
|
640
|
+
.build();
|
|
641
|
+
|
|
642
|
+
AccountResponse response = AccountResponse.builder()
|
|
643
|
+
.accountCode("11150")
|
|
644
|
+
.accountName("手許現金")
|
|
645
|
+
.accountShortName("手許現金")
|
|
646
|
+
.bsPlType("BS")
|
|
647
|
+
.dcType("借方")
|
|
648
|
+
.build();
|
|
649
|
+
|
|
650
|
+
given(accountUseCase.createAccount(any())).willReturn(response);
|
|
651
|
+
|
|
652
|
+
// When & Then
|
|
653
|
+
mockMvc.perform(post("/api/accounts")
|
|
654
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
655
|
+
.content(objectMapper.writeValueAsString(command)))
|
|
656
|
+
.andExpect(status().isCreated())
|
|
657
|
+
.andExpect(jsonPath("$.accountCode").value("11150"))
|
|
658
|
+
.andExpect(jsonPath("$.accountName").value("手許現金"));
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
@Test
|
|
662
|
+
@DisplayName("バリデーションエラーで400を返す")
|
|
663
|
+
void badRequestForValidationError() throws Exception {
|
|
664
|
+
// Given
|
|
665
|
+
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
666
|
+
.accountCode("") // 必須項目が空
|
|
667
|
+
.accountName("")
|
|
668
|
+
.build();
|
|
669
|
+
|
|
670
|
+
// When & Then
|
|
671
|
+
mockMvc.perform(post("/api/accounts")
|
|
672
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
673
|
+
.content(objectMapper.writeValueAsString(command)))
|
|
674
|
+
.andExpect(status().isBadRequest());
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
</details>
|
|
681
|
+
|
|
682
|
+
### 21.4.2 Green: Controller 実装
|
|
683
|
+
|
|
684
|
+
<details>
|
|
685
|
+
<summary>AccountController</summary>
|
|
686
|
+
|
|
687
|
+
```java
|
|
688
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/AccountController.java
|
|
689
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
690
|
+
|
|
691
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
692
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
693
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
694
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
695
|
+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
696
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
697
|
+
import jakarta.validation.Valid;
|
|
698
|
+
import lombok.RequiredArgsConstructor;
|
|
699
|
+
import org.springframework.http.HttpStatus;
|
|
700
|
+
import org.springframework.http.ResponseEntity;
|
|
701
|
+
import org.springframework.web.bind.annotation.*;
|
|
702
|
+
|
|
703
|
+
import java.util.List;
|
|
704
|
+
|
|
705
|
+
@RestController
|
|
706
|
+
@RequestMapping("/api/accounts")
|
|
707
|
+
@RequiredArgsConstructor
|
|
708
|
+
@Tag(name = "勘定科目マスタ", description = "勘定科目マスタの管理API")
|
|
709
|
+
public class AccountController {
|
|
710
|
+
|
|
711
|
+
private final AccountUseCase accountUseCase;
|
|
712
|
+
|
|
713
|
+
@GetMapping("/{accountCode}")
|
|
714
|
+
@Operation(summary = "勘定科目取得", description = "勘定科目コードで勘定科目を取得します")
|
|
715
|
+
@ApiResponse(responseCode = "200", description = "取得成功")
|
|
716
|
+
@ApiResponse(responseCode = "404", description = "勘定科目が存在しない")
|
|
717
|
+
public ResponseEntity<AccountResponse> getAccount(
|
|
718
|
+
@Parameter(description = "勘定科目コード")
|
|
719
|
+
@PathVariable String accountCode) {
|
|
720
|
+
return ResponseEntity.ok(accountUseCase.getAccount(accountCode));
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
@GetMapping
|
|
724
|
+
@Operation(summary = "勘定科目一覧取得", description = "勘定科目の一覧を取得します")
|
|
725
|
+
public ResponseEntity<List<AccountResponse>> getAccounts(
|
|
726
|
+
@Parameter(description = "BSPL区分(BS/PL)")
|
|
727
|
+
@RequestParam(required = false) String bsPlType,
|
|
728
|
+
@Parameter(description = "計上科目のみ")
|
|
729
|
+
@RequestParam(required = false, defaultValue = "false") boolean postingOnly) {
|
|
730
|
+
|
|
731
|
+
List<AccountResponse> accounts;
|
|
732
|
+
if (bsPlType != null) {
|
|
733
|
+
accounts = accountUseCase.getAccountsByBsPlType(bsPlType);
|
|
734
|
+
} else if (postingOnly) {
|
|
735
|
+
accounts = accountUseCase.getPostingAccounts();
|
|
736
|
+
} else {
|
|
737
|
+
accounts = accountUseCase.getAllAccounts();
|
|
738
|
+
}
|
|
739
|
+
return ResponseEntity.ok(accounts);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
@PostMapping
|
|
743
|
+
@Operation(summary = "勘定科目登録", description = "新規勘定科目を登録します")
|
|
744
|
+
@ApiResponse(responseCode = "201", description = "登録成功")
|
|
745
|
+
@ApiResponse(responseCode = "400", description = "バリデーションエラー")
|
|
746
|
+
public ResponseEntity<AccountResponse> createAccount(
|
|
747
|
+
@Valid @RequestBody CreateAccountCommand command) {
|
|
748
|
+
AccountResponse response = accountUseCase.createAccount(command);
|
|
749
|
+
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
@PutMapping("/{accountCode}")
|
|
753
|
+
@Operation(summary = "勘定科目更新", description = "勘定科目を更新します")
|
|
754
|
+
public ResponseEntity<AccountResponse> updateAccount(
|
|
755
|
+
@PathVariable String accountCode,
|
|
756
|
+
@Valid @RequestBody UpdateAccountCommand command) {
|
|
757
|
+
return ResponseEntity.ok(accountUseCase.updateAccount(accountCode, command));
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
@DeleteMapping("/{accountCode}")
|
|
761
|
+
@Operation(summary = "勘定科目削除", description = "勘定科目を削除します")
|
|
762
|
+
@ApiResponse(responseCode = "204", description = "削除成功")
|
|
763
|
+
public ResponseEntity<Void> deleteAccount(@PathVariable String accountCode) {
|
|
764
|
+
accountUseCase.deleteAccount(accountCode);
|
|
765
|
+
return ResponseEntity.noContent().build();
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
</details>
|
|
771
|
+
|
|
772
|
+
### 21.4.3 Refactor: Application Service 実装
|
|
773
|
+
|
|
774
|
+
<details>
|
|
775
|
+
<summary>AccountApplicationService</summary>
|
|
776
|
+
|
|
777
|
+
```java
|
|
778
|
+
// src/main/java/com/example/accounting/application/service/AccountApplicationService.java
|
|
779
|
+
package com.example.accounting.application.service;
|
|
780
|
+
|
|
781
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
782
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
783
|
+
import com.example.accounting.application.port.out.AccountRepository;
|
|
784
|
+
import com.example.accounting.application.port.out.AccountStructureRepository;
|
|
785
|
+
import com.example.accounting.domain.exception.*;
|
|
786
|
+
import com.example.accounting.domain.model.account.*;
|
|
787
|
+
import lombok.RequiredArgsConstructor;
|
|
788
|
+
import org.springframework.stereotype.Service;
|
|
789
|
+
import org.springframework.transaction.annotation.Transactional;
|
|
790
|
+
|
|
791
|
+
import java.util.List;
|
|
792
|
+
import java.util.stream.Collectors;
|
|
793
|
+
|
|
794
|
+
@Service
|
|
795
|
+
@RequiredArgsConstructor
|
|
796
|
+
@Transactional(readOnly = true)
|
|
797
|
+
public class AccountApplicationService implements AccountUseCase {
|
|
798
|
+
|
|
799
|
+
private final AccountRepository accountRepository;
|
|
800
|
+
private final AccountStructureRepository accountStructureRepository;
|
|
801
|
+
|
|
802
|
+
@Override
|
|
803
|
+
public AccountResponse getAccount(String accountCode) {
|
|
804
|
+
Account account = accountRepository.findByCode(accountCode)
|
|
805
|
+
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
806
|
+
return AccountResponse.from(account);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
@Override
|
|
810
|
+
public List<AccountResponse> getAllAccounts() {
|
|
811
|
+
return accountRepository.findAll().stream()
|
|
812
|
+
.map(AccountResponse::from)
|
|
813
|
+
.collect(Collectors.toList());
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
@Override
|
|
817
|
+
public List<AccountResponse> getAccountsByBsPlType(String bsPlType) {
|
|
818
|
+
return accountRepository.findByBsPlType(bsPlType).stream()
|
|
819
|
+
.map(AccountResponse::from)
|
|
820
|
+
.collect(Collectors.toList());
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
@Override
|
|
824
|
+
public List<AccountResponse> getAccountHierarchy(String parentAccountCode) {
|
|
825
|
+
String pathPattern = "%" + parentAccountCode + "%";
|
|
826
|
+
return accountRepository.findByPathLike(pathPattern).stream()
|
|
827
|
+
.map(AccountResponse::from)
|
|
828
|
+
.collect(Collectors.toList());
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
@Override
|
|
832
|
+
public List<AccountResponse> getPostingAccounts() {
|
|
833
|
+
return accountRepository.findPostingAccounts().stream()
|
|
834
|
+
.map(AccountResponse::from)
|
|
835
|
+
.collect(Collectors.toList());
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
@Override
|
|
839
|
+
@Transactional
|
|
840
|
+
public AccountResponse createAccount(CreateAccountCommand command) {
|
|
841
|
+
if (accountRepository.exists(command.getAccountCode())) {
|
|
842
|
+
throw new AccountAlreadyExistsException(command.getAccountCode());
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
Account account = Account.builder()
|
|
846
|
+
.accountCode(command.getAccountCode())
|
|
847
|
+
.accountName(command.getAccountName())
|
|
848
|
+
.accountShortName(command.getAccountShortName())
|
|
849
|
+
.bsPlType(BsPlType.valueOf(command.getBsPlType()))
|
|
850
|
+
.dcType(AccountDcType.fromDisplayName(command.getDcType()))
|
|
851
|
+
.elementType(ElementType.fromDisplayName(command.getElementType()))
|
|
852
|
+
.summaryType(SummaryType.fromDisplayName(command.getSummaryType()))
|
|
853
|
+
.taxCode(command.getTaxCode())
|
|
854
|
+
.build();
|
|
855
|
+
|
|
856
|
+
accountRepository.save(account);
|
|
857
|
+
|
|
858
|
+
String accountPath = generateAccountPath(command.getAccountCode(), command.getParentAccountCode());
|
|
859
|
+
AccountStructure structure = AccountStructure.builder()
|
|
860
|
+
.accountCode(command.getAccountCode())
|
|
861
|
+
.accountPath(accountPath)
|
|
862
|
+
.account(account)
|
|
863
|
+
.build();
|
|
864
|
+
accountStructureRepository.save(structure);
|
|
865
|
+
|
|
866
|
+
return AccountResponse.from(account);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
@Override
|
|
870
|
+
@Transactional
|
|
871
|
+
public AccountResponse updateAccount(String accountCode, UpdateAccountCommand command) {
|
|
872
|
+
Account account = accountRepository.findByCode(accountCode)
|
|
873
|
+
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
874
|
+
|
|
875
|
+
if (command.getAccountName() != null) {
|
|
876
|
+
account.setAccountName(command.getAccountName());
|
|
877
|
+
}
|
|
878
|
+
if (command.getAccountShortName() != null) {
|
|
879
|
+
account.setAccountShortName(command.getAccountShortName());
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
accountRepository.save(account);
|
|
883
|
+
return AccountResponse.from(account);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
@Override
|
|
887
|
+
@Transactional
|
|
888
|
+
public void deleteAccount(String accountCode) {
|
|
889
|
+
if (!accountRepository.exists(accountCode)) {
|
|
890
|
+
throw new AccountNotFoundException(accountCode);
|
|
891
|
+
}
|
|
892
|
+
accountStructureRepository.delete(accountCode);
|
|
893
|
+
accountRepository.delete(accountCode);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
private String generateAccountPath(String accountCode, String parentAccountCode) {
|
|
897
|
+
if (parentAccountCode == null || parentAccountCode.isEmpty()) {
|
|
898
|
+
return accountCode;
|
|
899
|
+
}
|
|
900
|
+
return accountStructureRepository.findByCode(parentAccountCode)
|
|
901
|
+
.map(parent -> parent.getAccountPath() + "~" + accountCode)
|
|
902
|
+
.orElse(accountCode);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
</details>
|
|
908
|
+
|
|
909
|
+
## 21.5 トランザクション API
|
|
910
|
+
|
|
911
|
+
### 21.5.1 仕訳 API エンドポイント
|
|
912
|
+
|
|
913
|
+
| メソッド | パス | 説明 |
|
|
914
|
+
|---------|------|------|
|
|
915
|
+
| GET | /api/journals | 仕訳一覧取得 |
|
|
916
|
+
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
917
|
+
| POST | /api/journals | 仕訳登録 |
|
|
918
|
+
| POST | /api/journals/check-balance | 貸借バランスチェック |
|
|
919
|
+
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消(赤黒処理) |
|
|
920
|
+
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正(赤黒処理) |
|
|
921
|
+
|
|
922
|
+
<details>
|
|
923
|
+
<summary>JournalController</summary>
|
|
924
|
+
|
|
925
|
+
```java
|
|
926
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/JournalController.java
|
|
927
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
928
|
+
|
|
929
|
+
import com.example.accounting.application.port.in.JournalUseCase;
|
|
930
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
931
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
932
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
933
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
934
|
+
import jakarta.validation.Valid;
|
|
935
|
+
import lombok.RequiredArgsConstructor;
|
|
936
|
+
import org.springframework.format.annotation.DateTimeFormat;
|
|
937
|
+
import org.springframework.http.HttpStatus;
|
|
938
|
+
import org.springframework.http.ResponseEntity;
|
|
939
|
+
import org.springframework.web.bind.annotation.*;
|
|
940
|
+
|
|
941
|
+
import java.time.LocalDate;
|
|
942
|
+
import java.util.List;
|
|
943
|
+
|
|
944
|
+
@RestController
|
|
945
|
+
@RequestMapping("/api/journals")
|
|
946
|
+
@RequiredArgsConstructor
|
|
947
|
+
@Tag(name = "仕訳", description = "仕訳の管理API")
|
|
948
|
+
public class JournalController {
|
|
949
|
+
|
|
950
|
+
private final JournalUseCase journalUseCase;
|
|
951
|
+
|
|
952
|
+
@GetMapping("/{journalNumber}")
|
|
953
|
+
@Operation(summary = "仕訳取得", description = "仕訳伝票番号で仕訳を取得します")
|
|
954
|
+
public ResponseEntity<JournalResponse> getJournal(
|
|
955
|
+
@Parameter(description = "仕訳伝票番号")
|
|
956
|
+
@PathVariable String journalNumber) {
|
|
957
|
+
return ResponseEntity.ok(journalUseCase.getJournal(journalNumber));
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
@GetMapping
|
|
961
|
+
@Operation(summary = "仕訳一覧取得", description = "条件を指定して仕訳を検索します")
|
|
962
|
+
public ResponseEntity<List<JournalResponse>> getJournals(
|
|
963
|
+
@Parameter(description = "開始日")
|
|
964
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
965
|
+
@Parameter(description = "終了日")
|
|
966
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
|
|
967
|
+
@Parameter(description = "部門コード")
|
|
968
|
+
@RequestParam(required = false) String departmentCode) {
|
|
969
|
+
|
|
970
|
+
List<JournalResponse> journals;
|
|
971
|
+
if (departmentCode != null) {
|
|
972
|
+
journals = journalUseCase.getJournalsByDepartment(departmentCode, fromDate, toDate);
|
|
973
|
+
} else {
|
|
974
|
+
journals = journalUseCase.getJournalsByDateRange(fromDate, toDate);
|
|
975
|
+
}
|
|
976
|
+
return ResponseEntity.ok(journals);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
@PostMapping
|
|
980
|
+
@Operation(summary = "仕訳登録", description = "新規仕訳を登録します")
|
|
981
|
+
public ResponseEntity<JournalResponse> createJournal(
|
|
982
|
+
@Valid @RequestBody CreateJournalCommand command) {
|
|
983
|
+
JournalResponse response = journalUseCase.createJournal(command);
|
|
984
|
+
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
@PostMapping("/check-balance")
|
|
988
|
+
@Operation(summary = "貸借バランスチェック", description = "仕訳の貸借バランスをチェックします")
|
|
989
|
+
public ResponseEntity<BalanceCheckResult> checkBalance(
|
|
990
|
+
@Valid @RequestBody CreateJournalCommand command) {
|
|
991
|
+
return ResponseEntity.ok(journalUseCase.checkBalance(command));
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
@PostMapping("/{journalNumber}/cancel")
|
|
995
|
+
@Operation(summary = "仕訳取消", description = "仕訳を赤黒処理で取消します")
|
|
996
|
+
public ResponseEntity<JournalCancellationResult> cancelJournal(
|
|
997
|
+
@PathVariable String journalNumber,
|
|
998
|
+
@RequestParam String reason) {
|
|
999
|
+
return ResponseEntity.ok(journalUseCase.cancelJournal(journalNumber, reason));
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
@PostMapping("/{journalNumber}/correct")
|
|
1003
|
+
@Operation(summary = "仕訳訂正", description = "仕訳を赤黒処理で訂正します")
|
|
1004
|
+
public ResponseEntity<JournalCorrectionResult> correctJournal(
|
|
1005
|
+
@PathVariable String journalNumber,
|
|
1006
|
+
@RequestParam String reason,
|
|
1007
|
+
@Valid @RequestBody CreateJournalCommand correctedData) {
|
|
1008
|
+
return ResponseEntity.ok(journalUseCase.correctJournal(journalNumber, correctedData, reason));
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
</details>
|
|
1014
|
+
|
|
1015
|
+
### 21.5.2 残高照会 API
|
|
1016
|
+
|
|
1017
|
+
<details>
|
|
1018
|
+
<summary>BalanceController</summary>
|
|
1019
|
+
|
|
1020
|
+
```java
|
|
1021
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/BalanceController.java
|
|
1022
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1023
|
+
|
|
1024
|
+
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
1025
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
1026
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
1027
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
1028
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
1029
|
+
import lombok.RequiredArgsConstructor;
|
|
1030
|
+
import org.springframework.format.annotation.DateTimeFormat;
|
|
1031
|
+
import org.springframework.http.ResponseEntity;
|
|
1032
|
+
import org.springframework.web.bind.annotation.*;
|
|
1033
|
+
|
|
1034
|
+
import java.time.LocalDate;
|
|
1035
|
+
import java.util.List;
|
|
1036
|
+
|
|
1037
|
+
@RestController
|
|
1038
|
+
@RequestMapping("/api/balances")
|
|
1039
|
+
@RequiredArgsConstructor
|
|
1040
|
+
@Tag(name = "残高照会", description = "勘定科目残高の照会API")
|
|
1041
|
+
public class BalanceController {
|
|
1042
|
+
|
|
1043
|
+
private final BalanceUseCase balanceUseCase;
|
|
1044
|
+
|
|
1045
|
+
@GetMapping("/daily")
|
|
1046
|
+
@Operation(summary = "日次残高取得", description = "指定日の勘定科目残高を取得します")
|
|
1047
|
+
public ResponseEntity<List<DailyBalanceResponse>> getDailyBalances(
|
|
1048
|
+
@Parameter(description = "対象日")
|
|
1049
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
|
|
1050
|
+
@Parameter(description = "勘定科目コード(省略時は全科目)")
|
|
1051
|
+
@RequestParam(required = false) String accountCode) {
|
|
1052
|
+
return ResponseEntity.ok(balanceUseCase.getDailyBalances(date, accountCode));
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
@GetMapping("/monthly")
|
|
1056
|
+
@Operation(summary = "月次残高取得", description = "指定月の勘定科目残高を取得します")
|
|
1057
|
+
public ResponseEntity<List<MonthlyBalanceResponse>> getMonthlyBalances(
|
|
1058
|
+
@Parameter(description = "決算期")
|
|
1059
|
+
@RequestParam int fiscalYear,
|
|
1060
|
+
@Parameter(description = "月度")
|
|
1061
|
+
@RequestParam int month) {
|
|
1062
|
+
return ResponseEntity.ok(balanceUseCase.getMonthlyBalances(fiscalYear, month));
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
@GetMapping("/accounts/{accountCode}")
|
|
1066
|
+
@Operation(summary = "勘定科目別残高取得", description = "勘定科目の期間別残高を取得します")
|
|
1067
|
+
public ResponseEntity<AccountBalanceSummary> getAccountBalanceSummary(
|
|
1068
|
+
@PathVariable String accountCode,
|
|
1069
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
1070
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate) {
|
|
1071
|
+
return ResponseEntity.ok(balanceUseCase.getAccountBalanceSummary(accountCode, fromDate, toDate));
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
```
|
|
1075
|
+
|
|
1076
|
+
</details>
|
|
1077
|
+
|
|
1078
|
+
## 21.6 エラーハンドリング
|
|
1079
|
+
|
|
1080
|
+
### 21.6.1 ドメイン例外
|
|
1081
|
+
|
|
1082
|
+
<details>
|
|
1083
|
+
<summary>ドメイン例外クラス</summary>
|
|
1084
|
+
|
|
1085
|
+
```java
|
|
1086
|
+
// src/main/java/com/example/accounting/domain/exception/AccountingException.java
|
|
1087
|
+
package com.example.accounting.domain.exception;
|
|
1088
|
+
|
|
1089
|
+
import lombok.Getter;
|
|
1090
|
+
|
|
1091
|
+
@Getter
|
|
1092
|
+
public abstract class AccountingException extends RuntimeException {
|
|
1093
|
+
private final String errorCode;
|
|
1094
|
+
|
|
1095
|
+
protected AccountingException(String errorCode, String message) {
|
|
1096
|
+
super(message);
|
|
1097
|
+
this.errorCode = errorCode;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// AccountNotFoundException.java
|
|
1102
|
+
package com.example.accounting.domain.exception;
|
|
1103
|
+
|
|
1104
|
+
public class AccountNotFoundException extends AccountingException {
|
|
1105
|
+
public AccountNotFoundException(String accountCode) {
|
|
1106
|
+
super("ACC001", "勘定科目が見つかりません: " + accountCode);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// JournalBalanceException.java
|
|
1111
|
+
package com.example.accounting.domain.exception;
|
|
1112
|
+
|
|
1113
|
+
import java.math.BigDecimal;
|
|
1114
|
+
|
|
1115
|
+
public class JournalBalanceException extends AccountingException {
|
|
1116
|
+
public JournalBalanceException(BigDecimal debit, BigDecimal credit) {
|
|
1117
|
+
super("JNL001", String.format("貸借が一致しません。借方合計: %s, 貸方合計: %s", debit, credit));
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// AccountAlreadyExistsException.java
|
|
1122
|
+
package com.example.accounting.domain.exception;
|
|
1123
|
+
|
|
1124
|
+
public class AccountAlreadyExistsException extends AccountingException {
|
|
1125
|
+
public AccountAlreadyExistsException(String accountCode) {
|
|
1126
|
+
super("ACC002", "勘定科目は既に存在します: " + accountCode);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
```
|
|
1130
|
+
|
|
1131
|
+
</details>
|
|
1132
|
+
|
|
1133
|
+
### 21.6.2 グローバル例外ハンドラー
|
|
1134
|
+
|
|
1135
|
+
<details>
|
|
1136
|
+
<summary>GlobalExceptionHandler</summary>
|
|
1137
|
+
|
|
1138
|
+
```java
|
|
1139
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/GlobalExceptionHandler.java
|
|
1140
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1141
|
+
|
|
1142
|
+
import com.example.accounting.domain.exception.*;
|
|
1143
|
+
import lombok.Builder;
|
|
1144
|
+
import lombok.Data;
|
|
1145
|
+
import lombok.extern.slf4j.Slf4j;
|
|
1146
|
+
import org.springframework.http.HttpStatus;
|
|
1147
|
+
import org.springframework.http.ResponseEntity;
|
|
1148
|
+
import org.springframework.validation.FieldError;
|
|
1149
|
+
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
1150
|
+
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
1151
|
+
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
1152
|
+
|
|
1153
|
+
import java.time.LocalDateTime;
|
|
1154
|
+
import java.util.HashMap;
|
|
1155
|
+
import java.util.Map;
|
|
1156
|
+
|
|
1157
|
+
@RestControllerAdvice
|
|
1158
|
+
@Slf4j
|
|
1159
|
+
public class GlobalExceptionHandler {
|
|
1160
|
+
|
|
1161
|
+
@ExceptionHandler(AccountNotFoundException.class)
|
|
1162
|
+
public ResponseEntity<ErrorResponse> handleAccountNotFoundException(AccountNotFoundException e) {
|
|
1163
|
+
log.warn("Account not found: {}", e.getMessage());
|
|
1164
|
+
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1165
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
@ExceptionHandler(AccountAlreadyExistsException.class)
|
|
1169
|
+
public ResponseEntity<ErrorResponse> handleAccountAlreadyExistsException(AccountAlreadyExistsException e) {
|
|
1170
|
+
log.warn("Account already exists: {}", e.getMessage());
|
|
1171
|
+
return ResponseEntity.status(HttpStatus.CONFLICT)
|
|
1172
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
@ExceptionHandler(JournalBalanceException.class)
|
|
1176
|
+
public ResponseEntity<ErrorResponse> handleJournalBalanceException(JournalBalanceException e) {
|
|
1177
|
+
log.warn("Journal balance error: {}", e.getMessage());
|
|
1178
|
+
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1179
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
1183
|
+
public ResponseEntity<ValidationErrorResponse> handleValidationException(MethodArgumentNotValidException e) {
|
|
1184
|
+
log.warn("Validation error: {}", e.getMessage());
|
|
1185
|
+
|
|
1186
|
+
Map<String, String> errors = new HashMap<>();
|
|
1187
|
+
e.getBindingResult().getAllErrors().forEach(error -> {
|
|
1188
|
+
String fieldName = ((FieldError) error).getField();
|
|
1189
|
+
String errorMessage = error.getDefaultMessage();
|
|
1190
|
+
errors.put(fieldName, errorMessage);
|
|
1191
|
+
});
|
|
1192
|
+
|
|
1193
|
+
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1194
|
+
.body(ValidationErrorResponse.builder()
|
|
1195
|
+
.errorCode("VAL001")
|
|
1196
|
+
.message("入力値が不正です")
|
|
1197
|
+
.timestamp(LocalDateTime.now())
|
|
1198
|
+
.errors(errors)
|
|
1199
|
+
.build());
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
@ExceptionHandler(Exception.class)
|
|
1203
|
+
public ResponseEntity<ErrorResponse> handleGenericException(Exception e) {
|
|
1204
|
+
log.error("Unexpected error", e);
|
|
1205
|
+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
1206
|
+
.body(createErrorResponse("SYS001", "システムエラーが発生しました"));
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
private ErrorResponse createErrorResponse(String errorCode, String message) {
|
|
1210
|
+
return ErrorResponse.builder()
|
|
1211
|
+
.errorCode(errorCode)
|
|
1212
|
+
.message(message)
|
|
1213
|
+
.timestamp(LocalDateTime.now())
|
|
1214
|
+
.build();
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
@Data
|
|
1218
|
+
@Builder
|
|
1219
|
+
public static class ErrorResponse {
|
|
1220
|
+
private String errorCode;
|
|
1221
|
+
private String message;
|
|
1222
|
+
private LocalDateTime timestamp;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
@Data
|
|
1226
|
+
@Builder
|
|
1227
|
+
public static class ValidationErrorResponse {
|
|
1228
|
+
private String errorCode;
|
|
1229
|
+
private String message;
|
|
1230
|
+
private LocalDateTime timestamp;
|
|
1231
|
+
private Map<String, String> errors;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
</details>
|
|
1237
|
+
|
|
1238
|
+
## 21.7 統合テスト
|
|
1239
|
+
|
|
1240
|
+
<details>
|
|
1241
|
+
<summary>AccountControllerIntegrationTest</summary>
|
|
1242
|
+
|
|
1243
|
+
```java
|
|
1244
|
+
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerIntegrationTest.java
|
|
1245
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1246
|
+
|
|
1247
|
+
import com.example.accounting.application.port.in.dto.CreateAccountCommand;
|
|
1248
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
1249
|
+
import org.junit.jupiter.api.*;
|
|
1250
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
1251
|
+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
1252
|
+
import org.springframework.boot.test.context.SpringBootTest;
|
|
1253
|
+
import org.springframework.http.MediaType;
|
|
1254
|
+
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1255
|
+
import org.springframework.test.context.DynamicPropertySource;
|
|
1256
|
+
import org.springframework.test.web.servlet.MockMvc;
|
|
1257
|
+
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1258
|
+
import org.testcontainers.junit.jupiter.Container;
|
|
1259
|
+
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1260
|
+
|
|
1261
|
+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
1262
|
+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
1263
|
+
|
|
1264
|
+
@SpringBootTest
|
|
1265
|
+
@AutoConfigureMockMvc
|
|
1266
|
+
@Testcontainers
|
|
1267
|
+
@DisplayName("勘定科目 API 統合テスト")
|
|
1268
|
+
class AccountControllerIntegrationTest {
|
|
1269
|
+
|
|
1270
|
+
@Container
|
|
1271
|
+
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1272
|
+
.withDatabaseName("testdb")
|
|
1273
|
+
.withUsername("testuser")
|
|
1274
|
+
.withPassword("testpass");
|
|
1275
|
+
|
|
1276
|
+
@DynamicPropertySource
|
|
1277
|
+
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1278
|
+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1279
|
+
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1280
|
+
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
@Autowired
|
|
1284
|
+
private MockMvc mockMvc;
|
|
1285
|
+
|
|
1286
|
+
@Autowired
|
|
1287
|
+
private ObjectMapper objectMapper;
|
|
1288
|
+
|
|
1289
|
+
@Nested
|
|
1290
|
+
@DisplayName("勘定科目 CRUD")
|
|
1291
|
+
class AccountCrud {
|
|
1292
|
+
|
|
1293
|
+
@Test
|
|
1294
|
+
@DisplayName("勘定科目の登録・取得・更新・削除が正常に動作する")
|
|
1295
|
+
void crudOperationsWork() throws Exception {
|
|
1296
|
+
// Create
|
|
1297
|
+
CreateAccountCommand createCommand = CreateAccountCommand.builder()
|
|
1298
|
+
.accountCode("99999")
|
|
1299
|
+
.accountName("テスト科目")
|
|
1300
|
+
.accountShortName("テスト")
|
|
1301
|
+
.bsPlType("BS")
|
|
1302
|
+
.dcType("借方")
|
|
1303
|
+
.elementType("資産")
|
|
1304
|
+
.summaryType("計上科目")
|
|
1305
|
+
.build();
|
|
1306
|
+
|
|
1307
|
+
mockMvc.perform(post("/api/accounts")
|
|
1308
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
1309
|
+
.content(objectMapper.writeValueAsString(createCommand)))
|
|
1310
|
+
.andExpect(status().isCreated())
|
|
1311
|
+
.andExpect(jsonPath("$.accountCode").value("99999"))
|
|
1312
|
+
.andExpect(jsonPath("$.accountName").value("テスト科目"));
|
|
1313
|
+
|
|
1314
|
+
// Read
|
|
1315
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1316
|
+
.andExpect(status().isOk())
|
|
1317
|
+
.andExpect(jsonPath("$.accountCode").value("99999"));
|
|
1318
|
+
|
|
1319
|
+
// Delete
|
|
1320
|
+
mockMvc.perform(delete("/api/accounts/{accountCode}", "99999"))
|
|
1321
|
+
.andExpect(status().isNoContent());
|
|
1322
|
+
|
|
1323
|
+
// Verify deleted
|
|
1324
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1325
|
+
.andExpect(status().isNotFound());
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
</details>
|
|
1332
|
+
|
|
1333
|
+
## 21.8 OpenAPI 設定
|
|
1334
|
+
|
|
1335
|
+
<details>
|
|
1336
|
+
<summary>OpenApiConfig</summary>
|
|
1337
|
+
|
|
1338
|
+
```java
|
|
1339
|
+
// src/main/java/com/example/accounting/infrastructure/config/OpenApiConfig.java
|
|
1340
|
+
package com.example.accounting.infrastructure.config;
|
|
1341
|
+
|
|
1342
|
+
import io.swagger.v3.oas.models.OpenAPI;
|
|
1343
|
+
import io.swagger.v3.oas.models.info.Contact;
|
|
1344
|
+
import io.swagger.v3.oas.models.info.Info;
|
|
1345
|
+
import io.swagger.v3.oas.models.info.License;
|
|
1346
|
+
import io.swagger.v3.oas.models.servers.Server;
|
|
1347
|
+
import org.springframework.context.annotation.Bean;
|
|
1348
|
+
import org.springframework.context.annotation.Configuration;
|
|
1349
|
+
|
|
1350
|
+
import java.util.List;
|
|
1351
|
+
|
|
1352
|
+
@Configuration
|
|
1353
|
+
public class OpenApiConfig {
|
|
1354
|
+
|
|
1355
|
+
@Bean
|
|
1356
|
+
public OpenAPI customOpenAPI() {
|
|
1357
|
+
return new OpenAPI()
|
|
1358
|
+
.info(new Info()
|
|
1359
|
+
.title("財務会計システム API")
|
|
1360
|
+
.description("財務会計システムのREST API仕様書(JPA版)")
|
|
1361
|
+
.version("1.0.0")
|
|
1362
|
+
.contact(new Contact()
|
|
1363
|
+
.name("開発チーム")
|
|
1364
|
+
.email("dev@example.com"))
|
|
1365
|
+
.license(new License()
|
|
1366
|
+
.name("MIT License")
|
|
1367
|
+
.url("https://opensource.org/licenses/MIT")))
|
|
1368
|
+
.servers(List.of(
|
|
1369
|
+
new Server().url("http://localhost:8080").description("開発環境"),
|
|
1370
|
+
new Server().url("https://api.example.com").description("本番環境")
|
|
1371
|
+
));
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
```
|
|
1375
|
+
|
|
1376
|
+
</details>
|
|
1377
|
+
|
|
1378
|
+
API ドキュメントへのアクセス:
|
|
1379
|
+
- **Swagger UI**: http://localhost:8080/swagger-ui.html
|
|
1380
|
+
- **OpenAPI JSON**: http://localhost:8080/api-docs
|
|
1381
|
+
|
|
1382
|
+
## まとめ
|
|
1383
|
+
|
|
1384
|
+
### MyBatis 版との違い
|
|
1385
|
+
|
|
1386
|
+
| 観点 | MyBatis 版 | JPA 版 |
|
|
1387
|
+
|------|-----------|--------|
|
|
1388
|
+
| Output Port 実装 | Mapper + XML | JpaRepository + Adapter |
|
|
1389
|
+
| クエリ定義 | XML に SQL | @Query or メソッド名規約 |
|
|
1390
|
+
| トランザクション | @Transactional | @Transactional(同一) |
|
|
1391
|
+
| N+1 対策 | JOIN を XML で記述 | @EntityGraph |
|
|
1392
|
+
| 動的クエリ | `<if>` タグ | Specification |
|
|
1393
|
+
| テスト | @MybatisTest | @DataJpaTest |
|
|
1394
|
+
|
|
1395
|
+
### JPA 固有の実装ポイント
|
|
1396
|
+
|
|
1397
|
+
1. **Repository Adapter パターン**
|
|
1398
|
+
```java
|
|
1399
|
+
@Component
|
|
1400
|
+
@RequiredArgsConstructor
|
|
1401
|
+
public class AccountRepositoryAdapter implements AccountRepository {
|
|
1402
|
+
private final AccountJpaRepository jpaRepository;
|
|
1403
|
+
|
|
1404
|
+
@Override
|
|
1405
|
+
public Optional<Account> findByCode(String accountCode) {
|
|
1406
|
+
return jpaRepository.findById(accountCode);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
2. **@Query によるカスタムクエリ**
|
|
1412
|
+
```java
|
|
1413
|
+
@Query("SELECT a FROM Account a JOIN AccountStructure s ON a.accountCode = s.accountCode " +
|
|
1414
|
+
"WHERE s.accountPath LIKE CONCAT(:pathPrefix, '%') ORDER BY a.accountCode")
|
|
1415
|
+
List<Account> findByAccountPathStartsWith(@Param("pathPrefix") String pathPrefix);
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1418
|
+
3. **existsById() による存在確認**
|
|
1419
|
+
```java
|
|
1420
|
+
@Override
|
|
1421
|
+
public boolean exists(String accountCode) {
|
|
1422
|
+
return jpaRepository.existsById(accountCode);
|
|
1423
|
+
}
|
|
1424
|
+
```
|
|
1425
|
+
|
|
1426
|
+
### API エンドポイント一覧
|
|
1427
|
+
|
|
1428
|
+
| メソッド | パス | 説明 |
|
|
1429
|
+
|---------|------|------|
|
|
1430
|
+
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
1431
|
+
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
1432
|
+
| POST | /api/accounts | 勘定科目登録 |
|
|
1433
|
+
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
1434
|
+
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
1435
|
+
| GET | /api/journals | 仕訳一覧取得 |
|
|
1436
|
+
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
1437
|
+
| POST | /api/journals | 仕訳登録 |
|
|
1438
|
+
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消 |
|
|
1439
|
+
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正 |
|
|
1440
|
+
| GET | /api/balances/daily | 日次残高取得 |
|
|
1441
|
+
| GET | /api/balances/monthly | 月次残高取得 |
|
|
1442
|
+
| GET | /api/reports/daily-report | 日計表取得 |
|
|
1443
|
+
| GET | /api/reports/trial-balance | 合計残高試算表取得 |
|
|
1444
|
+
|
|
1445
|
+
---
|
|
1446
|
+
|
|
1447
|
+
[← 第20章:財務会計データ設計(D社事例)【ORM版】](./chapter20-orm.md) | [第22章:生産管理システムの全体像 →](../part4/chapter22.md)
|