@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,1382 +1,1382 @@
|
|
|
1
|
-
# 第21章:API サービスの実装
|
|
2
|
-
|
|
3
|
-
本章では、財務会計システムの API サービスを TDD で実装します。ヘキサゴナルアーキテクチャに基づき、勘定科目マスタ API、仕訳 API、残高照会 API を構築します。
|
|
4
|
-
|
|
5
|
-
## 21.1 ヘキサゴナルアーキテクチャの復習
|
|
6
|
-
|
|
7
|
-
### 21.1.1 Ports and Adapters パターンの概要
|
|
8
|
-
|
|
9
|
-
ヘキサゴナルアーキテクチャ(別名:Ports and Adapters パターン)は、ドメインロジックを外部の技術的関心事から分離するアーキテクチャパターンです。
|
|
10
|
-
|
|
11
|
-
```plantuml
|
|
12
|
-
@startuml
|
|
13
|
-
|
|
14
|
-
title ヘキサゴナルアーキテクチャ
|
|
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(MyBatis)" 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 : Repository Impl
|
|
40
|
-
ext --> inport
|
|
41
|
-
|
|
42
|
-
note bottom of core
|
|
43
|
-
ドメインロジックは
|
|
44
|
-
外部技術から独立
|
|
45
|
-
end note
|
|
46
|
-
|
|
47
|
-
@enduml
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### 21.1.2 ドメイン中心設計
|
|
51
|
-
|
|
52
|
-
ヘキサゴナルアーキテクチャでは、ドメインロジックがアプリケーションの中心に位置します。外部の技術(Web フレームワーク、データベース、外部 API)は周辺に配置され、ドメインに依存します。
|
|
53
|
-
|
|
54
|
-
### 21.1.3 依存性の逆転
|
|
55
|
-
|
|
56
|
-
依存性の方向は常に外側から内側(ドメイン)に向かいます。Output Port(リポジトリインターフェース)を使用することで、ドメインがインフラストラクチャに依存しない設計を実現します。
|
|
57
|
-
|
|
58
|
-
### 21.1.4 テスト容易性
|
|
59
|
-
|
|
60
|
-
アーキテクチャの利点をまとめます。
|
|
61
|
-
|
|
62
|
-
| 利点 | 説明 |
|
|
63
|
-
|------|------|
|
|
64
|
-
| **テスト容易性** | ドメインロジックを単独でテスト可能 |
|
|
65
|
-
| **技術独立性** | DB、フレームワークの変更が容易 |
|
|
66
|
-
| **可読性** | 責務が明確に分離される |
|
|
67
|
-
| **保守性** | 変更の影響範囲が限定される |
|
|
68
|
-
|
|
69
|
-
## 21.2 アーキテクチャ構造
|
|
70
|
-
|
|
71
|
-
### 21.2.1 パッケージ構成
|
|
72
|
-
|
|
73
|
-
```plantuml
|
|
74
|
-
@startuml
|
|
75
|
-
|
|
76
|
-
title パッケージ構成
|
|
77
|
-
|
|
78
|
-
package "com.example.accounting" {
|
|
79
|
-
|
|
80
|
-
package "domain" {
|
|
81
|
-
package "model" {
|
|
82
|
-
class Account
|
|
83
|
-
class Journal
|
|
84
|
-
class Balance
|
|
85
|
-
}
|
|
86
|
-
package "service" {
|
|
87
|
-
class JournalDomainService
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
package "application" {
|
|
92
|
-
package "port.in" {
|
|
93
|
-
interface AccountUseCase
|
|
94
|
-
interface JournalUseCase
|
|
95
|
-
}
|
|
96
|
-
package "port.out" {
|
|
97
|
-
interface AccountRepository
|
|
98
|
-
interface JournalRepository
|
|
99
|
-
}
|
|
100
|
-
package "service" {
|
|
101
|
-
class AccountApplicationService
|
|
102
|
-
class JournalApplicationService
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
package "infrastructure" {
|
|
107
|
-
package "adapter.in.web" {
|
|
108
|
-
class AccountController
|
|
109
|
-
class JournalController
|
|
110
|
-
}
|
|
111
|
-
package "adapter.out.persistence" {
|
|
112
|
-
class AccountRepositoryImpl
|
|
113
|
-
class JournalRepositoryImpl
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
AccountUseCase <|.. AccountApplicationService
|
|
119
|
-
AccountRepository <|.. AccountRepositoryImpl
|
|
120
|
-
AccountController --> AccountUseCase
|
|
121
|
-
AccountApplicationService --> AccountRepository
|
|
122
|
-
|
|
123
|
-
@enduml
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### 21.2.2 各レイヤーの責務
|
|
127
|
-
|
|
128
|
-
```plantuml
|
|
129
|
-
@startuml
|
|
130
|
-
|
|
131
|
-
title 各層の責務
|
|
132
|
-
|
|
133
|
-
rectangle "Infrastructure Layer (Adapter)" #BBDEFB {
|
|
134
|
-
card "**入力アダプター**\n・REST Controller\n・リクエスト変換\n・レスポンス生成\n・バリデーション" as in_adapter
|
|
135
|
-
|
|
136
|
-
card "**出力アダプター**\n・Repository実装\n・DB操作\n・外部API連携\n・データ変換" as out_adapter
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
rectangle "Application Layer (Port + UseCase)" #FFF9C4 {
|
|
140
|
-
card "**入力ポート**\n・UseCase インターフェース\n・DTO定義\n・コマンド/クエリ" as in_port
|
|
141
|
-
|
|
142
|
-
card "**出力ポート**\n・Repository インターフェース\n・永続化抽象\n・外部連携抽象" as out_port
|
|
143
|
-
|
|
144
|
-
card "**アプリケーションサービス**\n・ユースケース実装\n・トランザクション制御\n・ドメイン調整" as app_service
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
rectangle "Domain Layer" #C8E6C9 {
|
|
148
|
-
card "**エンティティ**\n・ビジネスルール\n・状態管理\n・不変条件" as entity
|
|
149
|
-
|
|
150
|
-
card "**値オブジェクト**\n・不変性\n・同値性\n・自己完結性" as vo
|
|
151
|
-
|
|
152
|
-
card "**ドメインサービス**\n・複数エンティティ操作\n・ドメインロジック" as domain_service
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
in_adapter --> in_port
|
|
156
|
-
app_service --> out_port
|
|
157
|
-
out_port --> out_adapter
|
|
158
|
-
app_service --> entity
|
|
159
|
-
app_service --> domain_service
|
|
160
|
-
|
|
161
|
-
@enduml
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
## 21.3 マスタ API の実装
|
|
165
|
-
|
|
166
|
-
### 21.3.1 勘定科目マスタ API(CRUD エンドポイント)
|
|
167
|
-
|
|
168
|
-
勘定科目マスタの API エンドポイントを設計します。
|
|
169
|
-
|
|
170
|
-
| メソッド | パス | 説明 |
|
|
171
|
-
|---------|------|------|
|
|
172
|
-
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
173
|
-
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
174
|
-
| GET | /api/accounts/{accountCode}/hierarchy | 科目階層取得 |
|
|
175
|
-
| POST | /api/accounts | 勘定科目登録 |
|
|
176
|
-
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
177
|
-
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
178
|
-
|
|
179
|
-
<details>
|
|
180
|
-
<summary>Output Port(リポジトリインターフェース)</summary>
|
|
181
|
-
|
|
182
|
-
```java
|
|
183
|
-
// src/main/java/com/example/accounting/application/port/out/AccountRepository.java
|
|
184
|
-
package com.example.accounting.application.port.out;
|
|
185
|
-
|
|
186
|
-
import com.example.accounting.domain.model.account.AccountMaster;
|
|
187
|
-
|
|
188
|
-
import java.util.List;
|
|
189
|
-
import java.util.Optional;
|
|
190
|
-
|
|
191
|
-
public interface AccountRepository {
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* 勘定科目コードで検索
|
|
195
|
-
*/
|
|
196
|
-
Optional<AccountMaster> findByCode(String accountCode);
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* 全件取得
|
|
200
|
-
*/
|
|
201
|
-
List<AccountMaster> findAll();
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* BSPL区分で検索
|
|
205
|
-
*/
|
|
206
|
-
List<AccountMaster> findByBsPlType(String bsPlType);
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* 科目パスで検索(チルダ連結方式)
|
|
210
|
-
*/
|
|
211
|
-
List<AccountMaster> findByPathLike(String pathPattern);
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 計上科目のみ取得
|
|
215
|
-
*/
|
|
216
|
-
List<AccountMaster> findPostingAccounts();
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* 保存(新規・更新)
|
|
220
|
-
*/
|
|
221
|
-
void save(AccountMaster account);
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* 削除
|
|
225
|
-
*/
|
|
226
|
-
void delete(String accountCode);
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* 存在確認
|
|
230
|
-
*/
|
|
231
|
-
boolean exists(String accountCode);
|
|
232
|
-
}
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
</details>
|
|
236
|
-
|
|
237
|
-
<details>
|
|
238
|
-
<summary>Input Port(ユースケースインターフェース)</summary>
|
|
239
|
-
|
|
240
|
-
```java
|
|
241
|
-
// src/main/java/com/example/accounting/application/port/in/AccountUseCase.java
|
|
242
|
-
package com.example.accounting.application.port.in;
|
|
243
|
-
|
|
244
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
245
|
-
|
|
246
|
-
import java.util.List;
|
|
247
|
-
|
|
248
|
-
public interface AccountUseCase {
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* 勘定科目を取得
|
|
252
|
-
*/
|
|
253
|
-
AccountResponse getAccount(String accountCode);
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* 全勘定科目を取得
|
|
257
|
-
*/
|
|
258
|
-
List<AccountResponse> getAllAccounts();
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* BS/PL区分で勘定科目を取得
|
|
262
|
-
*/
|
|
263
|
-
List<AccountResponse> getAccountsByBsPlType(String bsPlType);
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* 科目階層を取得(親科目以下の全科目)
|
|
267
|
-
*/
|
|
268
|
-
List<AccountResponse> getAccountHierarchy(String parentAccountCode);
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* 計上科目のみ取得
|
|
272
|
-
*/
|
|
273
|
-
List<AccountResponse> getPostingAccounts();
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* 勘定科目を登録
|
|
277
|
-
*/
|
|
278
|
-
AccountResponse createAccount(CreateAccountCommand command);
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* 勘定科目を更新
|
|
282
|
-
*/
|
|
283
|
-
AccountResponse updateAccount(String accountCode, UpdateAccountCommand command);
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* 勘定科目を削除
|
|
287
|
-
*/
|
|
288
|
-
void deleteAccount(String accountCode);
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
</details>
|
|
293
|
-
|
|
294
|
-
### 21.3.2 TDD による実装(Red-Green-Refactor)
|
|
295
|
-
|
|
296
|
-
#### Red: 失敗するテストを書く
|
|
297
|
-
|
|
298
|
-
<details>
|
|
299
|
-
<summary>Controller テスト</summary>
|
|
300
|
-
|
|
301
|
-
```java
|
|
302
|
-
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerTest.java
|
|
303
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
304
|
-
|
|
305
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
306
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
307
|
-
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
308
|
-
import org.junit.jupiter.api.*;
|
|
309
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
310
|
-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|
311
|
-
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
312
|
-
import org.springframework.http.MediaType;
|
|
313
|
-
import org.springframework.test.web.servlet.MockMvc;
|
|
314
|
-
|
|
315
|
-
import java.util.List;
|
|
316
|
-
|
|
317
|
-
import static org.mockito.ArgumentMatchers.*;
|
|
318
|
-
import static org.mockito.BDDMockito.*;
|
|
319
|
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
320
|
-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
321
|
-
|
|
322
|
-
@WebMvcTest(AccountController.class)
|
|
323
|
-
@DisplayName("勘定科目マスタ API")
|
|
324
|
-
class AccountControllerTest {
|
|
325
|
-
|
|
326
|
-
@Autowired
|
|
327
|
-
private MockMvc mockMvc;
|
|
328
|
-
|
|
329
|
-
@Autowired
|
|
330
|
-
private ObjectMapper objectMapper;
|
|
331
|
-
|
|
332
|
-
@MockBean
|
|
333
|
-
private AccountUseCase accountUseCase;
|
|
334
|
-
|
|
335
|
-
@Nested
|
|
336
|
-
@DisplayName("GET /api/accounts/{accountCode}")
|
|
337
|
-
class GetAccount {
|
|
338
|
-
|
|
339
|
-
@Test
|
|
340
|
-
@DisplayName("勘定科目を取得できる")
|
|
341
|
-
void canGetAccount() throws Exception {
|
|
342
|
-
// Given
|
|
343
|
-
AccountResponse response = AccountResponse.builder()
|
|
344
|
-
.accountCode("11110")
|
|
345
|
-
.accountName("現金")
|
|
346
|
-
.accountShortName("現金")
|
|
347
|
-
.bsPlType("BS")
|
|
348
|
-
.dcType("借方")
|
|
349
|
-
.elementType("資産")
|
|
350
|
-
.summaryType("計上科目")
|
|
351
|
-
.build();
|
|
352
|
-
|
|
353
|
-
given(accountUseCase.getAccount("11110")).willReturn(response);
|
|
354
|
-
|
|
355
|
-
// When & Then
|
|
356
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "11110"))
|
|
357
|
-
.andExpect(status().isOk())
|
|
358
|
-
.andExpect(jsonPath("$.accountCode").value("11110"))
|
|
359
|
-
.andExpect(jsonPath("$.accountName").value("現金"))
|
|
360
|
-
.andExpect(jsonPath("$.bsPlType").value("BS"));
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
@Test
|
|
364
|
-
@DisplayName("存在しない勘定科目は404を返す")
|
|
365
|
-
void notFoundForNonExistent() throws Exception {
|
|
366
|
-
// Given
|
|
367
|
-
given(accountUseCase.getAccount("99999")).willThrow(
|
|
368
|
-
new AccountNotFoundException("99999"));
|
|
369
|
-
|
|
370
|
-
// When & Then
|
|
371
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
372
|
-
.andExpect(status().isNotFound());
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
@Nested
|
|
377
|
-
@DisplayName("POST /api/accounts")
|
|
378
|
-
class CreateAccount {
|
|
379
|
-
|
|
380
|
-
@Test
|
|
381
|
-
@DisplayName("勘定科目を登録できる")
|
|
382
|
-
void canCreateAccount() throws Exception {
|
|
383
|
-
// Given
|
|
384
|
-
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
385
|
-
.accountCode("11150")
|
|
386
|
-
.accountName("手許現金")
|
|
387
|
-
.bsPlType("BS")
|
|
388
|
-
.dcType("借方")
|
|
389
|
-
.elementType("資産")
|
|
390
|
-
.summaryType("計上科目")
|
|
391
|
-
.build();
|
|
392
|
-
|
|
393
|
-
AccountResponse response = AccountResponse.builder()
|
|
394
|
-
.accountCode("11150")
|
|
395
|
-
.accountName("手許現金")
|
|
396
|
-
.bsPlType("BS")
|
|
397
|
-
.dcType("借方")
|
|
398
|
-
.build();
|
|
399
|
-
|
|
400
|
-
given(accountUseCase.createAccount(any())).willReturn(response);
|
|
401
|
-
|
|
402
|
-
// When & Then
|
|
403
|
-
mockMvc.perform(post("/api/accounts")
|
|
404
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
405
|
-
.content(objectMapper.writeValueAsString(command)))
|
|
406
|
-
.andExpect(status().isCreated())
|
|
407
|
-
.andExpect(jsonPath("$.accountCode").value("11150"));
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
@Test
|
|
411
|
-
@DisplayName("バリデーションエラーで400を返す")
|
|
412
|
-
void badRequestForValidationError() throws Exception {
|
|
413
|
-
// Given
|
|
414
|
-
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
415
|
-
.accountCode("") // 必須項目が空
|
|
416
|
-
.build();
|
|
417
|
-
|
|
418
|
-
// When & Then
|
|
419
|
-
mockMvc.perform(post("/api/accounts")
|
|
420
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
421
|
-
.content(objectMapper.writeValueAsString(command)))
|
|
422
|
-
.andExpect(status().isBadRequest());
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
</details>
|
|
429
|
-
|
|
430
|
-
#### Green: テストを通す最小限の実装
|
|
431
|
-
|
|
432
|
-
<details>
|
|
433
|
-
<summary>Controller の実装</summary>
|
|
434
|
-
|
|
435
|
-
```java
|
|
436
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/AccountController.java
|
|
437
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
438
|
-
|
|
439
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
440
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
441
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
442
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
443
|
-
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
444
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
445
|
-
import jakarta.validation.Valid;
|
|
446
|
-
import lombok.RequiredArgsConstructor;
|
|
447
|
-
import org.springframework.http.HttpStatus;
|
|
448
|
-
import org.springframework.http.ResponseEntity;
|
|
449
|
-
import org.springframework.web.bind.annotation.*;
|
|
450
|
-
|
|
451
|
-
import java.util.List;
|
|
452
|
-
|
|
453
|
-
@RestController
|
|
454
|
-
@RequestMapping("/api/accounts")
|
|
455
|
-
@RequiredArgsConstructor
|
|
456
|
-
@Tag(name = "勘定科目マスタ", description = "勘定科目マスタの管理API")
|
|
457
|
-
public class AccountController {
|
|
458
|
-
|
|
459
|
-
private final AccountUseCase accountUseCase;
|
|
460
|
-
|
|
461
|
-
@GetMapping("/{accountCode}")
|
|
462
|
-
@Operation(summary = "勘定科目取得", description = "勘定科目コードで勘定科目を取得します")
|
|
463
|
-
@ApiResponse(responseCode = "200", description = "取得成功")
|
|
464
|
-
@ApiResponse(responseCode = "404", description = "勘定科目が存在しない")
|
|
465
|
-
public ResponseEntity<AccountResponse> getAccount(
|
|
466
|
-
@Parameter(description = "勘定科目コード")
|
|
467
|
-
@PathVariable String accountCode) {
|
|
468
|
-
return ResponseEntity.ok(accountUseCase.getAccount(accountCode));
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
@GetMapping
|
|
472
|
-
@Operation(summary = "勘定科目一覧取得", description = "勘定科目の一覧を取得します")
|
|
473
|
-
public ResponseEntity<List<AccountResponse>> getAccounts(
|
|
474
|
-
@Parameter(description = "BSPL区分(BS/PL)")
|
|
475
|
-
@RequestParam(required = false) String bsPlType,
|
|
476
|
-
@Parameter(description = "計上科目のみ")
|
|
477
|
-
@RequestParam(required = false, defaultValue = "false") boolean postingOnly) {
|
|
478
|
-
|
|
479
|
-
List<AccountResponse> accounts;
|
|
480
|
-
if (bsPlType != null) {
|
|
481
|
-
accounts = accountUseCase.getAccountsByBsPlType(bsPlType);
|
|
482
|
-
} else if (postingOnly) {
|
|
483
|
-
accounts = accountUseCase.getPostingAccounts();
|
|
484
|
-
} else {
|
|
485
|
-
accounts = accountUseCase.getAllAccounts();
|
|
486
|
-
}
|
|
487
|
-
return ResponseEntity.ok(accounts);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
@PostMapping
|
|
491
|
-
@Operation(summary = "勘定科目登録", description = "新規勘定科目を登録します")
|
|
492
|
-
@ApiResponse(responseCode = "201", description = "登録成功")
|
|
493
|
-
@ApiResponse(responseCode = "400", description = "バリデーションエラー")
|
|
494
|
-
public ResponseEntity<AccountResponse> createAccount(
|
|
495
|
-
@Valid @RequestBody CreateAccountCommand command) {
|
|
496
|
-
AccountResponse response = accountUseCase.createAccount(command);
|
|
497
|
-
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
@PutMapping("/{accountCode}")
|
|
501
|
-
@Operation(summary = "勘定科目更新", description = "勘定科目を更新します")
|
|
502
|
-
public ResponseEntity<AccountResponse> updateAccount(
|
|
503
|
-
@PathVariable String accountCode,
|
|
504
|
-
@Valid @RequestBody UpdateAccountCommand command) {
|
|
505
|
-
return ResponseEntity.ok(accountUseCase.updateAccount(accountCode, command));
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
@DeleteMapping("/{accountCode}")
|
|
509
|
-
@Operation(summary = "勘定科目削除", description = "勘定科目を削除します")
|
|
510
|
-
@ApiResponse(responseCode = "204", description = "削除成功")
|
|
511
|
-
public ResponseEntity<Void> deleteAccount(@PathVariable String accountCode) {
|
|
512
|
-
accountUseCase.deleteAccount(accountCode);
|
|
513
|
-
return ResponseEntity.noContent().build();
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
</details>
|
|
519
|
-
|
|
520
|
-
#### Refactor: Application Service の実装
|
|
521
|
-
|
|
522
|
-
<details>
|
|
523
|
-
<summary>Application Service</summary>
|
|
524
|
-
|
|
525
|
-
```java
|
|
526
|
-
// src/main/java/com/example/accounting/application/service/AccountApplicationService.java
|
|
527
|
-
package com.example.accounting.application.service;
|
|
528
|
-
|
|
529
|
-
import com.example.accounting.application.port.in.AccountUseCase;
|
|
530
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
531
|
-
import com.example.accounting.application.port.out.AccountRepository;
|
|
532
|
-
import com.example.accounting.application.port.out.AccountConfigRepository;
|
|
533
|
-
import com.example.accounting.domain.model.account.*;
|
|
534
|
-
import lombok.RequiredArgsConstructor;
|
|
535
|
-
import org.springframework.stereotype.Service;
|
|
536
|
-
import org.springframework.transaction.annotation.Transactional;
|
|
537
|
-
|
|
538
|
-
import java.util.List;
|
|
539
|
-
import java.util.stream.Collectors;
|
|
540
|
-
|
|
541
|
-
@Service
|
|
542
|
-
@RequiredArgsConstructor
|
|
543
|
-
@Transactional(readOnly = true)
|
|
544
|
-
public class AccountApplicationService implements AccountUseCase {
|
|
545
|
-
|
|
546
|
-
private final AccountRepository accountRepository;
|
|
547
|
-
private final AccountConfigRepository accountConfigRepository;
|
|
548
|
-
|
|
549
|
-
@Override
|
|
550
|
-
public AccountResponse getAccount(String accountCode) {
|
|
551
|
-
AccountMaster account = accountRepository.findByCode(accountCode)
|
|
552
|
-
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
553
|
-
return AccountResponse.from(account);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
@Override
|
|
557
|
-
public List<AccountResponse> getAllAccounts() {
|
|
558
|
-
return accountRepository.findAll().stream()
|
|
559
|
-
.map(AccountResponse::from)
|
|
560
|
-
.collect(Collectors.toList());
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
@Override
|
|
564
|
-
public List<AccountResponse> getAccountsByBsPlType(String bsPlType) {
|
|
565
|
-
return accountRepository.findByBsPlType(bsPlType).stream()
|
|
566
|
-
.map(AccountResponse::from)
|
|
567
|
-
.collect(Collectors.toList());
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
@Override
|
|
571
|
-
public List<AccountResponse> getAccountHierarchy(String parentAccountCode) {
|
|
572
|
-
String pathPattern = "%" + parentAccountCode + "%";
|
|
573
|
-
return accountRepository.findByPathLike(pathPattern).stream()
|
|
574
|
-
.map(AccountResponse::from)
|
|
575
|
-
.collect(Collectors.toList());
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
@Override
|
|
579
|
-
public List<AccountResponse> getPostingAccounts() {
|
|
580
|
-
return accountRepository.findPostingAccounts().stream()
|
|
581
|
-
.map(AccountResponse::from)
|
|
582
|
-
.collect(Collectors.toList());
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
@Override
|
|
586
|
-
@Transactional
|
|
587
|
-
public AccountResponse createAccount(CreateAccountCommand command) {
|
|
588
|
-
if (accountRepository.exists(command.getAccountCode())) {
|
|
589
|
-
throw new AccountAlreadyExistsException(command.getAccountCode());
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
AccountMaster account = AccountMaster.builder()
|
|
593
|
-
.accountCode(command.getAccountCode())
|
|
594
|
-
.accountName(command.getAccountName())
|
|
595
|
-
.accountShortName(command.getAccountShortName())
|
|
596
|
-
.bsPlType(BsPlType.valueOf(command.getBsPlType()))
|
|
597
|
-
.dcType(AccountDcType.fromDisplayName(command.getDcType()))
|
|
598
|
-
.elementType(ElementType.fromDisplayName(command.getElementType()))
|
|
599
|
-
.summaryType(SummaryType.fromDisplayName(command.getSummaryType()))
|
|
600
|
-
.taxCode(command.getTaxCode())
|
|
601
|
-
.build();
|
|
602
|
-
|
|
603
|
-
accountRepository.save(account);
|
|
604
|
-
|
|
605
|
-
String accountPath = generateAccountPath(command.getAccountCode(), command.getParentAccountCode());
|
|
606
|
-
AccountConfig config = AccountConfig.builder()
|
|
607
|
-
.accountCode(command.getAccountCode())
|
|
608
|
-
.accountPath(accountPath)
|
|
609
|
-
.build();
|
|
610
|
-
accountConfigRepository.save(config);
|
|
611
|
-
|
|
612
|
-
return AccountResponse.from(account);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
@Override
|
|
616
|
-
@Transactional
|
|
617
|
-
public AccountResponse updateAccount(String accountCode, UpdateAccountCommand command) {
|
|
618
|
-
AccountMaster account = accountRepository.findByCode(accountCode)
|
|
619
|
-
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
620
|
-
|
|
621
|
-
if (command.getAccountName() != null) {
|
|
622
|
-
account.setAccountName(command.getAccountName());
|
|
623
|
-
}
|
|
624
|
-
if (command.getAccountShortName() != null) {
|
|
625
|
-
account.setAccountShortName(command.getAccountShortName());
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
accountRepository.save(account);
|
|
629
|
-
return AccountResponse.from(account);
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
@Override
|
|
633
|
-
@Transactional
|
|
634
|
-
public void deleteAccount(String accountCode) {
|
|
635
|
-
if (!accountRepository.exists(accountCode)) {
|
|
636
|
-
throw new AccountNotFoundException(accountCode);
|
|
637
|
-
}
|
|
638
|
-
accountConfigRepository.delete(accountCode);
|
|
639
|
-
accountRepository.delete(accountCode);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
private String generateAccountPath(String accountCode, String parentAccountCode) {
|
|
643
|
-
if (parentAccountCode == null || parentAccountCode.isEmpty()) {
|
|
644
|
-
return accountCode;
|
|
645
|
-
}
|
|
646
|
-
return accountConfigRepository.findByCode(parentAccountCode)
|
|
647
|
-
.map(parent -> parent.getAccountPath() + "~" + accountCode)
|
|
648
|
-
.orElse(accountCode);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
</details>
|
|
654
|
-
|
|
655
|
-
### 21.3.3 補助科目マスタ API
|
|
656
|
-
|
|
657
|
-
補助科目は勘定科目に紐づく詳細区分で、得意先・仕入先・銀行口座などを管理します。
|
|
658
|
-
|
|
659
|
-
| メソッド | パス | 説明 |
|
|
660
|
-
|---------|------|------|
|
|
661
|
-
| GET | /api/accounts/{accountCode}/sub-accounts | 補助科目一覧取得 |
|
|
662
|
-
| POST | /api/accounts/{accountCode}/sub-accounts | 補助科目登録 |
|
|
663
|
-
|
|
664
|
-
## 21.4 トランザクション API の実装
|
|
665
|
-
|
|
666
|
-
### 21.4.1 仕訳 API
|
|
667
|
-
|
|
668
|
-
仕訳の登録・照会・訂正・取消を行う API を実装します。
|
|
669
|
-
|
|
670
|
-
| メソッド | パス | 説明 |
|
|
671
|
-
|---------|------|------|
|
|
672
|
-
| GET | /api/journals | 仕訳一覧取得 |
|
|
673
|
-
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
674
|
-
| POST | /api/journals | 仕訳登録 |
|
|
675
|
-
| POST | /api/journals/check-balance | 貸借バランスチェック |
|
|
676
|
-
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消(赤黒処理) |
|
|
677
|
-
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正(赤黒処理) |
|
|
678
|
-
|
|
679
|
-
<details>
|
|
680
|
-
<summary>仕訳ユースケースインターフェース</summary>
|
|
681
|
-
|
|
682
|
-
```java
|
|
683
|
-
// src/main/java/com/example/accounting/application/port/in/JournalUseCase.java
|
|
684
|
-
package com.example.accounting.application.port.in;
|
|
685
|
-
|
|
686
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
687
|
-
|
|
688
|
-
import java.time.LocalDate;
|
|
689
|
-
import java.util.List;
|
|
690
|
-
|
|
691
|
-
public interface JournalUseCase {
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* 仕訳を取得
|
|
695
|
-
*/
|
|
696
|
-
JournalResponse getJournal(String journalNumber);
|
|
697
|
-
|
|
698
|
-
/**
|
|
699
|
-
* 日付範囲で仕訳を検索
|
|
700
|
-
*/
|
|
701
|
-
List<JournalResponse> getJournalsByDateRange(LocalDate fromDate, LocalDate toDate);
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* 部門で仕訳を検索
|
|
705
|
-
*/
|
|
706
|
-
List<JournalResponse> getJournalsByDepartment(String departmentCode, LocalDate fromDate, LocalDate toDate);
|
|
707
|
-
|
|
708
|
-
/**
|
|
709
|
-
* 仕訳を登録
|
|
710
|
-
*/
|
|
711
|
-
JournalResponse createJournal(CreateJournalCommand command);
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* 仕訳を取消(赤黒処理)
|
|
715
|
-
*/
|
|
716
|
-
JournalCancellationResult cancelJournal(String journalNumber, String reason);
|
|
717
|
-
|
|
718
|
-
/**
|
|
719
|
-
* 仕訳を訂正(赤黒処理)
|
|
720
|
-
*/
|
|
721
|
-
JournalCorrectionResult correctJournal(String journalNumber, CreateJournalCommand correctedData, String reason);
|
|
722
|
-
|
|
723
|
-
/**
|
|
724
|
-
* 貸借バランスをチェック
|
|
725
|
-
*/
|
|
726
|
-
BalanceCheckResult checkBalance(CreateJournalCommand command);
|
|
727
|
-
}
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
</details>
|
|
731
|
-
|
|
732
|
-
<details>
|
|
733
|
-
<summary>仕訳 Controller</summary>
|
|
734
|
-
|
|
735
|
-
```java
|
|
736
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/JournalController.java
|
|
737
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
738
|
-
|
|
739
|
-
import com.example.accounting.application.port.in.JournalUseCase;
|
|
740
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
741
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
742
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
743
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
744
|
-
import jakarta.validation.Valid;
|
|
745
|
-
import lombok.RequiredArgsConstructor;
|
|
746
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
747
|
-
import org.springframework.http.HttpStatus;
|
|
748
|
-
import org.springframework.http.ResponseEntity;
|
|
749
|
-
import org.springframework.web.bind.annotation.*;
|
|
750
|
-
|
|
751
|
-
import java.time.LocalDate;
|
|
752
|
-
import java.util.List;
|
|
753
|
-
|
|
754
|
-
@RestController
|
|
755
|
-
@RequestMapping("/api/journals")
|
|
756
|
-
@RequiredArgsConstructor
|
|
757
|
-
@Tag(name = "仕訳", description = "仕訳の管理API")
|
|
758
|
-
public class JournalController {
|
|
759
|
-
|
|
760
|
-
private final JournalUseCase journalUseCase;
|
|
761
|
-
|
|
762
|
-
@GetMapping("/{journalNumber}")
|
|
763
|
-
@Operation(summary = "仕訳取得", description = "仕訳伝票番号で仕訳を取得します")
|
|
764
|
-
public ResponseEntity<JournalResponse> getJournal(
|
|
765
|
-
@Parameter(description = "仕訳伝票番号")
|
|
766
|
-
@PathVariable String journalNumber) {
|
|
767
|
-
return ResponseEntity.ok(journalUseCase.getJournal(journalNumber));
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
@GetMapping
|
|
771
|
-
@Operation(summary = "仕訳一覧取得", description = "条件を指定して仕訳を検索します")
|
|
772
|
-
public ResponseEntity<List<JournalResponse>> getJournals(
|
|
773
|
-
@Parameter(description = "開始日")
|
|
774
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
775
|
-
@Parameter(description = "終了日")
|
|
776
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
|
|
777
|
-
@Parameter(description = "部門コード")
|
|
778
|
-
@RequestParam(required = false) String departmentCode) {
|
|
779
|
-
|
|
780
|
-
List<JournalResponse> journals;
|
|
781
|
-
if (departmentCode != null) {
|
|
782
|
-
journals = journalUseCase.getJournalsByDepartment(departmentCode, fromDate, toDate);
|
|
783
|
-
} else {
|
|
784
|
-
journals = journalUseCase.getJournalsByDateRange(fromDate, toDate);
|
|
785
|
-
}
|
|
786
|
-
return ResponseEntity.ok(journals);
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
@PostMapping
|
|
790
|
-
@Operation(summary = "仕訳登録", description = "新規仕訳を登録します")
|
|
791
|
-
public ResponseEntity<JournalResponse> createJournal(
|
|
792
|
-
@Valid @RequestBody CreateJournalCommand command) {
|
|
793
|
-
JournalResponse response = journalUseCase.createJournal(command);
|
|
794
|
-
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
@PostMapping("/check-balance")
|
|
798
|
-
@Operation(summary = "貸借バランスチェック", description = "仕訳の貸借バランスをチェックします")
|
|
799
|
-
public ResponseEntity<BalanceCheckResult> checkBalance(
|
|
800
|
-
@Valid @RequestBody CreateJournalCommand command) {
|
|
801
|
-
return ResponseEntity.ok(journalUseCase.checkBalance(command));
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
@PostMapping("/{journalNumber}/cancel")
|
|
805
|
-
@Operation(summary = "仕訳取消", description = "仕訳を赤黒処理で取消します")
|
|
806
|
-
public ResponseEntity<JournalCancellationResult> cancelJournal(
|
|
807
|
-
@PathVariable String journalNumber,
|
|
808
|
-
@RequestParam String reason) {
|
|
809
|
-
return ResponseEntity.ok(journalUseCase.cancelJournal(journalNumber, reason));
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
@PostMapping("/{journalNumber}/correct")
|
|
813
|
-
@Operation(summary = "仕訳訂正", description = "仕訳を赤黒処理で訂正します")
|
|
814
|
-
public ResponseEntity<JournalCorrectionResult> correctJournal(
|
|
815
|
-
@PathVariable String journalNumber,
|
|
816
|
-
@RequestParam String reason,
|
|
817
|
-
@Valid @RequestBody CreateJournalCommand correctedData) {
|
|
818
|
-
return ResponseEntity.ok(journalUseCase.correctJournal(journalNumber, correctedData, reason));
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
```
|
|
822
|
-
|
|
823
|
-
</details>
|
|
824
|
-
|
|
825
|
-
### 21.4.2 残高照会 API
|
|
826
|
-
|
|
827
|
-
日次残高・月次残高・部門別残高を照会する API を実装します。
|
|
828
|
-
|
|
829
|
-
| メソッド | パス | 説明 |
|
|
830
|
-
|---------|------|------|
|
|
831
|
-
| GET | /api/balances/daily | 日次残高取得 |
|
|
832
|
-
| GET | /api/balances/monthly | 月次残高取得 |
|
|
833
|
-
| GET | /api/balances/accounts/{accountCode} | 勘定科目別残高取得 |
|
|
834
|
-
| GET | /api/balances/departments | 部門別残高取得 |
|
|
835
|
-
|
|
836
|
-
<details>
|
|
837
|
-
<summary>残高照会 Controller</summary>
|
|
838
|
-
|
|
839
|
-
```java
|
|
840
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/BalanceController.java
|
|
841
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
842
|
-
|
|
843
|
-
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
844
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
845
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
846
|
-
import io.swagger.v3.oas.annotations.Parameter;
|
|
847
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
848
|
-
import lombok.RequiredArgsConstructor;
|
|
849
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
850
|
-
import org.springframework.http.ResponseEntity;
|
|
851
|
-
import org.springframework.web.bind.annotation.*;
|
|
852
|
-
|
|
853
|
-
import java.time.LocalDate;
|
|
854
|
-
import java.util.List;
|
|
855
|
-
|
|
856
|
-
@RestController
|
|
857
|
-
@RequestMapping("/api/balances")
|
|
858
|
-
@RequiredArgsConstructor
|
|
859
|
-
@Tag(name = "残高照会", description = "勘定科目残高の照会API")
|
|
860
|
-
public class BalanceController {
|
|
861
|
-
|
|
862
|
-
private final BalanceUseCase balanceUseCase;
|
|
863
|
-
|
|
864
|
-
@GetMapping("/daily")
|
|
865
|
-
@Operation(summary = "日次残高取得", description = "指定日の勘定科目残高を取得します")
|
|
866
|
-
public ResponseEntity<List<DailyBalanceResponse>> getDailyBalances(
|
|
867
|
-
@Parameter(description = "対象日")
|
|
868
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
|
|
869
|
-
@Parameter(description = "勘定科目コード(省略時は全科目)")
|
|
870
|
-
@RequestParam(required = false) String accountCode) {
|
|
871
|
-
return ResponseEntity.ok(balanceUseCase.getDailyBalances(date, accountCode));
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
@GetMapping("/monthly")
|
|
875
|
-
@Operation(summary = "月次残高取得", description = "指定月の勘定科目残高を取得します")
|
|
876
|
-
public ResponseEntity<List<MonthlyBalanceResponse>> getMonthlyBalances(
|
|
877
|
-
@Parameter(description = "決算期")
|
|
878
|
-
@RequestParam int fiscalYear,
|
|
879
|
-
@Parameter(description = "月度")
|
|
880
|
-
@RequestParam int month) {
|
|
881
|
-
return ResponseEntity.ok(balanceUseCase.getMonthlyBalances(fiscalYear, month));
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
@GetMapping("/accounts/{accountCode}")
|
|
885
|
-
@Operation(summary = "勘定科目別残高取得", description = "勘定科目の期間別残高を取得します")
|
|
886
|
-
public ResponseEntity<AccountBalanceSummary> getAccountBalanceSummary(
|
|
887
|
-
@PathVariable String accountCode,
|
|
888
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
889
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate) {
|
|
890
|
-
return ResponseEntity.ok(balanceUseCase.getAccountBalanceSummary(accountCode, fromDate, toDate));
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
@GetMapping("/departments")
|
|
894
|
-
@Operation(summary = "部門別残高取得", description = "部門別の勘定科目残高を取得します")
|
|
895
|
-
public ResponseEntity<List<DepartmentBalanceResponse>> getDepartmentBalances(
|
|
896
|
-
@RequestParam int fiscalYear,
|
|
897
|
-
@RequestParam int month,
|
|
898
|
-
@RequestParam(required = false) String accountCode) {
|
|
899
|
-
return ResponseEntity.ok(balanceUseCase.getDepartmentBalances(fiscalYear, month, accountCode));
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
```
|
|
903
|
-
|
|
904
|
-
</details>
|
|
905
|
-
|
|
906
|
-
### 21.4.3 試算表 API
|
|
907
|
-
|
|
908
|
-
日計表と合計残高試算表を出力する API を実装します。
|
|
909
|
-
|
|
910
|
-
<details>
|
|
911
|
-
<summary>帳票出力 Controller</summary>
|
|
912
|
-
|
|
913
|
-
```java
|
|
914
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/ReportController.java
|
|
915
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
916
|
-
|
|
917
|
-
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
918
|
-
import com.example.accounting.application.port.in.dto.*;
|
|
919
|
-
import io.swagger.v3.oas.annotations.Operation;
|
|
920
|
-
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
921
|
-
import lombok.RequiredArgsConstructor;
|
|
922
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
923
|
-
import org.springframework.http.ResponseEntity;
|
|
924
|
-
import org.springframework.web.bind.annotation.*;
|
|
925
|
-
|
|
926
|
-
import java.time.LocalDate;
|
|
927
|
-
|
|
928
|
-
@RestController
|
|
929
|
-
@RequestMapping("/api/reports")
|
|
930
|
-
@RequiredArgsConstructor
|
|
931
|
-
@Tag(name = "帳票出力", description = "会計帳票の出力API")
|
|
932
|
-
public class ReportController {
|
|
933
|
-
|
|
934
|
-
private final BalanceUseCase balanceUseCase;
|
|
935
|
-
|
|
936
|
-
@GetMapping("/daily-report")
|
|
937
|
-
@Operation(summary = "日計表取得", description = "指定日の日計表データを取得します")
|
|
938
|
-
public ResponseEntity<DailyReportResponse> getDailyReport(
|
|
939
|
-
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
|
|
940
|
-
return ResponseEntity.ok(balanceUseCase.getDailyReport(date));
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
@GetMapping("/trial-balance")
|
|
944
|
-
@Operation(summary = "合計残高試算表取得", description = "指定月の合計残高試算表を取得します")
|
|
945
|
-
public ResponseEntity<TrialBalanceResponse> getTrialBalance(
|
|
946
|
-
@RequestParam int fiscalYear,
|
|
947
|
-
@RequestParam int month) {
|
|
948
|
-
return ResponseEntity.ok(balanceUseCase.getTrialBalance(fiscalYear, month));
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
```
|
|
952
|
-
|
|
953
|
-
</details>
|
|
954
|
-
|
|
955
|
-
<details>
|
|
956
|
-
<summary>合計残高試算表レスポンス DTO</summary>
|
|
957
|
-
|
|
958
|
-
```java
|
|
959
|
-
// src/main/java/com/example/accounting/application/port/in/dto/TrialBalanceResponse.java
|
|
960
|
-
package com.example.accounting.application.port.in.dto;
|
|
961
|
-
|
|
962
|
-
import lombok.Builder;
|
|
963
|
-
import lombok.Data;
|
|
964
|
-
|
|
965
|
-
import java.math.BigDecimal;
|
|
966
|
-
import java.util.List;
|
|
967
|
-
|
|
968
|
-
@Data
|
|
969
|
-
@Builder
|
|
970
|
-
public class TrialBalanceResponse {
|
|
971
|
-
private int fiscalYear;
|
|
972
|
-
private int month;
|
|
973
|
-
private List<TrialBalanceLine> lines;
|
|
974
|
-
private TrialBalanceTotals totals;
|
|
975
|
-
|
|
976
|
-
@Data
|
|
977
|
-
@Builder
|
|
978
|
-
public static class TrialBalanceLine {
|
|
979
|
-
private String accountCode;
|
|
980
|
-
private String accountName;
|
|
981
|
-
private String bsPlType;
|
|
982
|
-
private String dcType;
|
|
983
|
-
private BigDecimal openingBalance;
|
|
984
|
-
private BigDecimal debitAmount;
|
|
985
|
-
private BigDecimal creditAmount;
|
|
986
|
-
private BigDecimal closingBalance;
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
@Data
|
|
990
|
-
@Builder
|
|
991
|
-
public static class TrialBalanceTotals {
|
|
992
|
-
private BigDecimal totalOpeningDebit;
|
|
993
|
-
private BigDecimal totalOpeningCredit;
|
|
994
|
-
private BigDecimal totalDebit;
|
|
995
|
-
private BigDecimal totalCredit;
|
|
996
|
-
private BigDecimal totalClosingDebit;
|
|
997
|
-
private BigDecimal totalClosingCredit;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
```
|
|
1001
|
-
|
|
1002
|
-
</details>
|
|
1003
|
-
|
|
1004
|
-
## 21.5 エラーハンドリング
|
|
1005
|
-
|
|
1006
|
-
### 21.5.1 ドメイン例外の定義
|
|
1007
|
-
|
|
1008
|
-
```plantuml
|
|
1009
|
-
@startuml
|
|
1010
|
-
|
|
1011
|
-
title エラー階層
|
|
1012
|
-
|
|
1013
|
-
abstract class AccountingException {
|
|
1014
|
-
- errorCode: String
|
|
1015
|
-
- message: String
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
class AccountNotFoundException extends AccountingException
|
|
1019
|
-
class AccountAlreadyExistsException extends AccountingException
|
|
1020
|
-
class JournalNotFoundException extends AccountingException
|
|
1021
|
-
class JournalBalanceException extends AccountingException
|
|
1022
|
-
class JournalAlreadyCancelledException extends AccountingException
|
|
1023
|
-
class ValidationException extends AccountingException
|
|
1024
|
-
|
|
1025
|
-
note right of AccountingException
|
|
1026
|
-
ドメイン例外の基底クラス
|
|
1027
|
-
HTTPステータスは
|
|
1028
|
-
Controller層で決定
|
|
1029
|
-
end note
|
|
1030
|
-
|
|
1031
|
-
@enduml
|
|
1032
|
-
```
|
|
1033
|
-
|
|
1034
|
-
<details>
|
|
1035
|
-
<summary>ドメイン例外クラス</summary>
|
|
1036
|
-
|
|
1037
|
-
```java
|
|
1038
|
-
// src/main/java/com/example/accounting/domain/exception/AccountingException.java
|
|
1039
|
-
package com.example.accounting.domain.exception;
|
|
1040
|
-
|
|
1041
|
-
import lombok.Getter;
|
|
1042
|
-
|
|
1043
|
-
@Getter
|
|
1044
|
-
public abstract class AccountingException extends RuntimeException {
|
|
1045
|
-
private final String errorCode;
|
|
1046
|
-
|
|
1047
|
-
protected AccountingException(String errorCode, String message) {
|
|
1048
|
-
super(message);
|
|
1049
|
-
this.errorCode = errorCode;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
// AccountNotFoundException.java
|
|
1054
|
-
package com.example.accounting.domain.exception;
|
|
1055
|
-
|
|
1056
|
-
public class AccountNotFoundException extends AccountingException {
|
|
1057
|
-
public AccountNotFoundException(String accountCode) {
|
|
1058
|
-
super("ACC001", "勘定科目が見つかりません: " + accountCode);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
// JournalBalanceException.java
|
|
1063
|
-
package com.example.accounting.domain.exception;
|
|
1064
|
-
|
|
1065
|
-
import java.math.BigDecimal;
|
|
1066
|
-
|
|
1067
|
-
public class JournalBalanceException extends AccountingException {
|
|
1068
|
-
public JournalBalanceException(BigDecimal debit, BigDecimal credit) {
|
|
1069
|
-
super("JNL001", String.format("貸借が一致しません。借方合計: %s, 貸方合計: %s", debit, credit));
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
|
-
```
|
|
1073
|
-
|
|
1074
|
-
</details>
|
|
1075
|
-
|
|
1076
|
-
### 21.5.2 グローバル例外ハンドラー
|
|
1077
|
-
|
|
1078
|
-
<details>
|
|
1079
|
-
<summary>GlobalExceptionHandler</summary>
|
|
1080
|
-
|
|
1081
|
-
```java
|
|
1082
|
-
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/GlobalExceptionHandler.java
|
|
1083
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1084
|
-
|
|
1085
|
-
import com.example.accounting.domain.exception.*;
|
|
1086
|
-
import lombok.Builder;
|
|
1087
|
-
import lombok.Data;
|
|
1088
|
-
import lombok.extern.slf4j.Slf4j;
|
|
1089
|
-
import org.springframework.http.HttpStatus;
|
|
1090
|
-
import org.springframework.http.ResponseEntity;
|
|
1091
|
-
import org.springframework.validation.FieldError;
|
|
1092
|
-
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
1093
|
-
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
1094
|
-
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
1095
|
-
|
|
1096
|
-
import java.time.LocalDateTime;
|
|
1097
|
-
import java.util.HashMap;
|
|
1098
|
-
import java.util.Map;
|
|
1099
|
-
|
|
1100
|
-
@RestControllerAdvice
|
|
1101
|
-
@Slf4j
|
|
1102
|
-
public class GlobalExceptionHandler {
|
|
1103
|
-
|
|
1104
|
-
@ExceptionHandler(AccountNotFoundException.class)
|
|
1105
|
-
public ResponseEntity<ErrorResponse> handleAccountNotFoundException(AccountNotFoundException e) {
|
|
1106
|
-
log.warn("Account not found: {}", e.getMessage());
|
|
1107
|
-
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1108
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1111
|
-
@ExceptionHandler(JournalNotFoundException.class)
|
|
1112
|
-
public ResponseEntity<ErrorResponse> handleJournalNotFoundException(JournalNotFoundException e) {
|
|
1113
|
-
log.warn("Journal not found: {}", e.getMessage());
|
|
1114
|
-
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1115
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
@ExceptionHandler(JournalBalanceException.class)
|
|
1119
|
-
public ResponseEntity<ErrorResponse> handleJournalBalanceException(JournalBalanceException e) {
|
|
1120
|
-
log.warn("Journal balance error: {}", e.getMessage());
|
|
1121
|
-
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1122
|
-
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
1126
|
-
public ResponseEntity<ValidationErrorResponse> handleValidationException(MethodArgumentNotValidException e) {
|
|
1127
|
-
log.warn("Validation error: {}", e.getMessage());
|
|
1128
|
-
|
|
1129
|
-
Map<String, String> errors = new HashMap<>();
|
|
1130
|
-
e.getBindingResult().getAllErrors().forEach(error -> {
|
|
1131
|
-
String fieldName = ((FieldError) error).getField();
|
|
1132
|
-
String errorMessage = error.getDefaultMessage();
|
|
1133
|
-
errors.put(fieldName, errorMessage);
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1137
|
-
.body(ValidationErrorResponse.builder()
|
|
1138
|
-
.errorCode("VAL001")
|
|
1139
|
-
.message("入力値が不正です")
|
|
1140
|
-
.timestamp(LocalDateTime.now())
|
|
1141
|
-
.errors(errors)
|
|
1142
|
-
.build());
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
@ExceptionHandler(Exception.class)
|
|
1146
|
-
public ResponseEntity<ErrorResponse> handleGenericException(Exception e) {
|
|
1147
|
-
log.error("Unexpected error", e);
|
|
1148
|
-
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
1149
|
-
.body(createErrorResponse("SYS001", "システムエラーが発生しました"));
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
private ErrorResponse createErrorResponse(String errorCode, String message) {
|
|
1153
|
-
return ErrorResponse.builder()
|
|
1154
|
-
.errorCode(errorCode)
|
|
1155
|
-
.message(message)
|
|
1156
|
-
.timestamp(LocalDateTime.now())
|
|
1157
|
-
.build();
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
@Data
|
|
1161
|
-
@Builder
|
|
1162
|
-
public static class ErrorResponse {
|
|
1163
|
-
private String errorCode;
|
|
1164
|
-
private String message;
|
|
1165
|
-
private LocalDateTime timestamp;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
@Data
|
|
1169
|
-
@Builder
|
|
1170
|
-
public static class ValidationErrorResponse {
|
|
1171
|
-
private String errorCode;
|
|
1172
|
-
private String message;
|
|
1173
|
-
private LocalDateTime timestamp;
|
|
1174
|
-
private Map<String, String> errors;
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
```
|
|
1178
|
-
|
|
1179
|
-
</details>
|
|
1180
|
-
|
|
1181
|
-
## 21.6 API ドキュメント
|
|
1182
|
-
|
|
1183
|
-
### 21.6.1 OpenAPI / Swagger の設定
|
|
1184
|
-
|
|
1185
|
-
<details>
|
|
1186
|
-
<summary>OpenAPI 設定</summary>
|
|
1187
|
-
|
|
1188
|
-
```java
|
|
1189
|
-
// src/main/java/com/example/accounting/infrastructure/config/OpenApiConfig.java
|
|
1190
|
-
package com.example.accounting.infrastructure.config;
|
|
1191
|
-
|
|
1192
|
-
import io.swagger.v3.oas.models.OpenAPI;
|
|
1193
|
-
import io.swagger.v3.oas.models.info.Contact;
|
|
1194
|
-
import io.swagger.v3.oas.models.info.Info;
|
|
1195
|
-
import io.swagger.v3.oas.models.info.License;
|
|
1196
|
-
import io.swagger.v3.oas.models.servers.Server;
|
|
1197
|
-
import org.springframework.context.annotation.Bean;
|
|
1198
|
-
import org.springframework.context.annotation.Configuration;
|
|
1199
|
-
|
|
1200
|
-
import java.util.List;
|
|
1201
|
-
|
|
1202
|
-
@Configuration
|
|
1203
|
-
public class OpenApiConfig {
|
|
1204
|
-
|
|
1205
|
-
@Bean
|
|
1206
|
-
public OpenAPI customOpenAPI() {
|
|
1207
|
-
return new OpenAPI()
|
|
1208
|
-
.info(new Info()
|
|
1209
|
-
.title("財務会計システム API")
|
|
1210
|
-
.description("財務会計システムのREST API仕様書")
|
|
1211
|
-
.version("1.0.0")
|
|
1212
|
-
.contact(new Contact()
|
|
1213
|
-
.name("開発チーム")
|
|
1214
|
-
.email("dev@example.com"))
|
|
1215
|
-
.license(new License()
|
|
1216
|
-
.name("MIT License")
|
|
1217
|
-
.url("https://opensource.org/licenses/MIT")))
|
|
1218
|
-
.servers(List.of(
|
|
1219
|
-
new Server().url("http://localhost:8080").description("開発環境"),
|
|
1220
|
-
new Server().url("https://api.example.com").description("本番環境")
|
|
1221
|
-
));
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
```
|
|
1225
|
-
|
|
1226
|
-
</details>
|
|
1227
|
-
|
|
1228
|
-
### 21.6.2 API ドキュメントへのアクセス
|
|
1229
|
-
|
|
1230
|
-
アプリケーション起動後、以下の URL で API 仕様書を確認できます:
|
|
1231
|
-
|
|
1232
|
-
- **Swagger UI**: http://localhost:8080/swagger-ui.html
|
|
1233
|
-
- **OpenAPI JSON**: http://localhost:8080/api-docs
|
|
1234
|
-
|
|
1235
|
-
## 21.7 API インテグレーションテスト
|
|
1236
|
-
|
|
1237
|
-
### 21.7.1 テストコンテナによる統合テスト環境
|
|
1238
|
-
|
|
1239
|
-
Testcontainers を使用して、実際の PostgreSQL データベースを使用した統合テストを実行します。
|
|
1240
|
-
|
|
1241
|
-
<details>
|
|
1242
|
-
<summary>統合テストの設定</summary>
|
|
1243
|
-
|
|
1244
|
-
```java
|
|
1245
|
-
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerIntegrationTest.java
|
|
1246
|
-
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1247
|
-
|
|
1248
|
-
import com.example.accounting.application.port.in.dto.CreateAccountCommand;
|
|
1249
|
-
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
1250
|
-
import org.junit.jupiter.api.*;
|
|
1251
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
1252
|
-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
1253
|
-
import org.springframework.boot.test.context.SpringBootTest;
|
|
1254
|
-
import org.springframework.http.MediaType;
|
|
1255
|
-
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1256
|
-
import org.springframework.test.context.DynamicPropertySource;
|
|
1257
|
-
import org.springframework.test.web.servlet.MockMvc;
|
|
1258
|
-
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1259
|
-
import org.testcontainers.junit.jupiter.Container;
|
|
1260
|
-
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1261
|
-
|
|
1262
|
-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
1263
|
-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
1264
|
-
|
|
1265
|
-
@SpringBootTest
|
|
1266
|
-
@AutoConfigureMockMvc
|
|
1267
|
-
@Testcontainers
|
|
1268
|
-
@DisplayName("勘定科目 API 統合テスト")
|
|
1269
|
-
class AccountControllerIntegrationTest {
|
|
1270
|
-
|
|
1271
|
-
@Container
|
|
1272
|
-
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1273
|
-
.withDatabaseName("testdb")
|
|
1274
|
-
.withUsername("testuser")
|
|
1275
|
-
.withPassword("testpass");
|
|
1276
|
-
|
|
1277
|
-
@DynamicPropertySource
|
|
1278
|
-
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1279
|
-
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1280
|
-
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1281
|
-
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
@Autowired
|
|
1285
|
-
private MockMvc mockMvc;
|
|
1286
|
-
|
|
1287
|
-
@Autowired
|
|
1288
|
-
private ObjectMapper objectMapper;
|
|
1289
|
-
|
|
1290
|
-
@Nested
|
|
1291
|
-
@DisplayName("勘定科目 CRUD")
|
|
1292
|
-
class AccountCrud {
|
|
1293
|
-
|
|
1294
|
-
@Test
|
|
1295
|
-
@DisplayName("勘定科目の登録・取得・更新・削除が正常に動作する")
|
|
1296
|
-
void crudOperationsWork() throws Exception {
|
|
1297
|
-
// Create
|
|
1298
|
-
CreateAccountCommand createCommand = CreateAccountCommand.builder()
|
|
1299
|
-
.accountCode("99999")
|
|
1300
|
-
.accountName("テスト科目")
|
|
1301
|
-
.accountShortName("テスト")
|
|
1302
|
-
.bsPlType("BS")
|
|
1303
|
-
.dcType("借方")
|
|
1304
|
-
.elementType("資産")
|
|
1305
|
-
.summaryType("計上科目")
|
|
1306
|
-
.build();
|
|
1307
|
-
|
|
1308
|
-
mockMvc.perform(post("/api/accounts")
|
|
1309
|
-
.contentType(MediaType.APPLICATION_JSON)
|
|
1310
|
-
.content(objectMapper.writeValueAsString(createCommand)))
|
|
1311
|
-
.andExpect(status().isCreated())
|
|
1312
|
-
.andExpect(jsonPath("$.accountCode").value("99999"))
|
|
1313
|
-
.andExpect(jsonPath("$.accountName").value("テスト科目"));
|
|
1314
|
-
|
|
1315
|
-
// Read
|
|
1316
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1317
|
-
.andExpect(status().isOk())
|
|
1318
|
-
.andExpect(jsonPath("$.accountCode").value("99999"));
|
|
1319
|
-
|
|
1320
|
-
// Delete
|
|
1321
|
-
mockMvc.perform(delete("/api/accounts/{accountCode}", "99999"))
|
|
1322
|
-
.andExpect(status().isNoContent());
|
|
1323
|
-
|
|
1324
|
-
// Verify deleted
|
|
1325
|
-
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1326
|
-
.andExpect(status().isNotFound());
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
```
|
|
1331
|
-
|
|
1332
|
-
</details>
|
|
1333
|
-
|
|
1334
|
-
### 21.7.2 API エンドポイント一覧
|
|
1335
|
-
|
|
1336
|
-
| メソッド | パス | 説明 |
|
|
1337
|
-
|---------|------|------|
|
|
1338
|
-
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
1339
|
-
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
1340
|
-
| POST | /api/accounts | 勘定科目登録 |
|
|
1341
|
-
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
1342
|
-
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
1343
|
-
| GET | /api/journals | 仕訳一覧取得 |
|
|
1344
|
-
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
1345
|
-
| POST | /api/journals | 仕訳登録 |
|
|
1346
|
-
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消 |
|
|
1347
|
-
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正 |
|
|
1348
|
-
| GET | /api/balances/daily | 日次残高取得 |
|
|
1349
|
-
| GET | /api/balances/monthly | 月次残高取得 |
|
|
1350
|
-
| GET | /api/reports/daily-report | 日計表取得 |
|
|
1351
|
-
| GET | /api/reports/trial-balance | 合計残高試算表取得 |
|
|
1352
|
-
|
|
1353
|
-
## まとめ
|
|
1354
|
-
|
|
1355
|
-
本章では、財務会計システムの API サービスを実装しました。
|
|
1356
|
-
|
|
1357
|
-
### 設計のポイント
|
|
1358
|
-
|
|
1359
|
-
1. **ヘキサゴナルアーキテクチャ**
|
|
1360
|
-
- ドメインロジックの独立性
|
|
1361
|
-
- Ports and Adapters パターンによる責務分離
|
|
1362
|
-
- テスト容易性の確保
|
|
1363
|
-
|
|
1364
|
-
2. **マスタ API の設計**
|
|
1365
|
-
- CRUD 操作の標準化
|
|
1366
|
-
- 階層構造(チルダ連結)への対応
|
|
1367
|
-
- バリデーションとエラーハンドリング
|
|
1368
|
-
|
|
1369
|
-
3. **トランザクション API の設計**
|
|
1370
|
-
- 仕訳の登録・照会・訂正・取消
|
|
1371
|
-
- 貸借バランスチェック
|
|
1372
|
-
- 赤黒処理との連携
|
|
1373
|
-
|
|
1374
|
-
4. **帳票 API の設計**
|
|
1375
|
-
- 日計表・合計残高試算表
|
|
1376
|
-
- 部門別・科目別残高照会
|
|
1377
|
-
|
|
1378
|
-
これで財務会計システムの第3部は完了です。次の第4部では、生産管理システムについて解説します。
|
|
1379
|
-
|
|
1380
|
-
---
|
|
1381
|
-
|
|
1382
|
-
[← 第20章:財務会計データ設計 D社事例](./chapter20.md) | [第22章:生産管理システムの全体像 →](../part4/chapter22.md)
|
|
1
|
+
# 第21章:API サービスの実装
|
|
2
|
+
|
|
3
|
+
本章では、財務会計システムの API サービスを TDD で実装します。ヘキサゴナルアーキテクチャに基づき、勘定科目マスタ API、仕訳 API、残高照会 API を構築します。
|
|
4
|
+
|
|
5
|
+
## 21.1 ヘキサゴナルアーキテクチャの復習
|
|
6
|
+
|
|
7
|
+
### 21.1.1 Ports and Adapters パターンの概要
|
|
8
|
+
|
|
9
|
+
ヘキサゴナルアーキテクチャ(別名:Ports and Adapters パターン)は、ドメインロジックを外部の技術的関心事から分離するアーキテクチャパターンです。
|
|
10
|
+
|
|
11
|
+
```plantuml
|
|
12
|
+
@startuml
|
|
13
|
+
|
|
14
|
+
title ヘキサゴナルアーキテクチャ
|
|
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(MyBatis)" 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 : Repository Impl
|
|
40
|
+
ext --> inport
|
|
41
|
+
|
|
42
|
+
note bottom of core
|
|
43
|
+
ドメインロジックは
|
|
44
|
+
外部技術から独立
|
|
45
|
+
end note
|
|
46
|
+
|
|
47
|
+
@enduml
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 21.1.2 ドメイン中心設計
|
|
51
|
+
|
|
52
|
+
ヘキサゴナルアーキテクチャでは、ドメインロジックがアプリケーションの中心に位置します。外部の技術(Web フレームワーク、データベース、外部 API)は周辺に配置され、ドメインに依存します。
|
|
53
|
+
|
|
54
|
+
### 21.1.3 依存性の逆転
|
|
55
|
+
|
|
56
|
+
依存性の方向は常に外側から内側(ドメイン)に向かいます。Output Port(リポジトリインターフェース)を使用することで、ドメインがインフラストラクチャに依存しない設計を実現します。
|
|
57
|
+
|
|
58
|
+
### 21.1.4 テスト容易性
|
|
59
|
+
|
|
60
|
+
アーキテクチャの利点をまとめます。
|
|
61
|
+
|
|
62
|
+
| 利点 | 説明 |
|
|
63
|
+
|------|------|
|
|
64
|
+
| **テスト容易性** | ドメインロジックを単独でテスト可能 |
|
|
65
|
+
| **技術独立性** | DB、フレームワークの変更が容易 |
|
|
66
|
+
| **可読性** | 責務が明確に分離される |
|
|
67
|
+
| **保守性** | 変更の影響範囲が限定される |
|
|
68
|
+
|
|
69
|
+
## 21.2 アーキテクチャ構造
|
|
70
|
+
|
|
71
|
+
### 21.2.1 パッケージ構成
|
|
72
|
+
|
|
73
|
+
```plantuml
|
|
74
|
+
@startuml
|
|
75
|
+
|
|
76
|
+
title パッケージ構成
|
|
77
|
+
|
|
78
|
+
package "com.example.accounting" {
|
|
79
|
+
|
|
80
|
+
package "domain" {
|
|
81
|
+
package "model" {
|
|
82
|
+
class Account
|
|
83
|
+
class Journal
|
|
84
|
+
class Balance
|
|
85
|
+
}
|
|
86
|
+
package "service" {
|
|
87
|
+
class JournalDomainService
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
package "application" {
|
|
92
|
+
package "port.in" {
|
|
93
|
+
interface AccountUseCase
|
|
94
|
+
interface JournalUseCase
|
|
95
|
+
}
|
|
96
|
+
package "port.out" {
|
|
97
|
+
interface AccountRepository
|
|
98
|
+
interface JournalRepository
|
|
99
|
+
}
|
|
100
|
+
package "service" {
|
|
101
|
+
class AccountApplicationService
|
|
102
|
+
class JournalApplicationService
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
package "infrastructure" {
|
|
107
|
+
package "adapter.in.web" {
|
|
108
|
+
class AccountController
|
|
109
|
+
class JournalController
|
|
110
|
+
}
|
|
111
|
+
package "adapter.out.persistence" {
|
|
112
|
+
class AccountRepositoryImpl
|
|
113
|
+
class JournalRepositoryImpl
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
AccountUseCase <|.. AccountApplicationService
|
|
119
|
+
AccountRepository <|.. AccountRepositoryImpl
|
|
120
|
+
AccountController --> AccountUseCase
|
|
121
|
+
AccountApplicationService --> AccountRepository
|
|
122
|
+
|
|
123
|
+
@enduml
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 21.2.2 各レイヤーの責務
|
|
127
|
+
|
|
128
|
+
```plantuml
|
|
129
|
+
@startuml
|
|
130
|
+
|
|
131
|
+
title 各層の責務
|
|
132
|
+
|
|
133
|
+
rectangle "Infrastructure Layer (Adapter)" #BBDEFB {
|
|
134
|
+
card "**入力アダプター**\n・REST Controller\n・リクエスト変換\n・レスポンス生成\n・バリデーション" as in_adapter
|
|
135
|
+
|
|
136
|
+
card "**出力アダプター**\n・Repository実装\n・DB操作\n・外部API連携\n・データ変換" as out_adapter
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
rectangle "Application Layer (Port + UseCase)" #FFF9C4 {
|
|
140
|
+
card "**入力ポート**\n・UseCase インターフェース\n・DTO定義\n・コマンド/クエリ" as in_port
|
|
141
|
+
|
|
142
|
+
card "**出力ポート**\n・Repository インターフェース\n・永続化抽象\n・外部連携抽象" as out_port
|
|
143
|
+
|
|
144
|
+
card "**アプリケーションサービス**\n・ユースケース実装\n・トランザクション制御\n・ドメイン調整" as app_service
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
rectangle "Domain Layer" #C8E6C9 {
|
|
148
|
+
card "**エンティティ**\n・ビジネスルール\n・状態管理\n・不変条件" as entity
|
|
149
|
+
|
|
150
|
+
card "**値オブジェクト**\n・不変性\n・同値性\n・自己完結性" as vo
|
|
151
|
+
|
|
152
|
+
card "**ドメインサービス**\n・複数エンティティ操作\n・ドメインロジック" as domain_service
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
in_adapter --> in_port
|
|
156
|
+
app_service --> out_port
|
|
157
|
+
out_port --> out_adapter
|
|
158
|
+
app_service --> entity
|
|
159
|
+
app_service --> domain_service
|
|
160
|
+
|
|
161
|
+
@enduml
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 21.3 マスタ API の実装
|
|
165
|
+
|
|
166
|
+
### 21.3.1 勘定科目マスタ API(CRUD エンドポイント)
|
|
167
|
+
|
|
168
|
+
勘定科目マスタの API エンドポイントを設計します。
|
|
169
|
+
|
|
170
|
+
| メソッド | パス | 説明 |
|
|
171
|
+
|---------|------|------|
|
|
172
|
+
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
173
|
+
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
174
|
+
| GET | /api/accounts/{accountCode}/hierarchy | 科目階層取得 |
|
|
175
|
+
| POST | /api/accounts | 勘定科目登録 |
|
|
176
|
+
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
177
|
+
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
178
|
+
|
|
179
|
+
<details>
|
|
180
|
+
<summary>Output Port(リポジトリインターフェース)</summary>
|
|
181
|
+
|
|
182
|
+
```java
|
|
183
|
+
// src/main/java/com/example/accounting/application/port/out/AccountRepository.java
|
|
184
|
+
package com.example.accounting.application.port.out;
|
|
185
|
+
|
|
186
|
+
import com.example.accounting.domain.model.account.AccountMaster;
|
|
187
|
+
|
|
188
|
+
import java.util.List;
|
|
189
|
+
import java.util.Optional;
|
|
190
|
+
|
|
191
|
+
public interface AccountRepository {
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* 勘定科目コードで検索
|
|
195
|
+
*/
|
|
196
|
+
Optional<AccountMaster> findByCode(String accountCode);
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 全件取得
|
|
200
|
+
*/
|
|
201
|
+
List<AccountMaster> findAll();
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* BSPL区分で検索
|
|
205
|
+
*/
|
|
206
|
+
List<AccountMaster> findByBsPlType(String bsPlType);
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* 科目パスで検索(チルダ連結方式)
|
|
210
|
+
*/
|
|
211
|
+
List<AccountMaster> findByPathLike(String pathPattern);
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 計上科目のみ取得
|
|
215
|
+
*/
|
|
216
|
+
List<AccountMaster> findPostingAccounts();
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 保存(新規・更新)
|
|
220
|
+
*/
|
|
221
|
+
void save(AccountMaster account);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 削除
|
|
225
|
+
*/
|
|
226
|
+
void delete(String accountCode);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 存在確認
|
|
230
|
+
*/
|
|
231
|
+
boolean exists(String accountCode);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
</details>
|
|
236
|
+
|
|
237
|
+
<details>
|
|
238
|
+
<summary>Input Port(ユースケースインターフェース)</summary>
|
|
239
|
+
|
|
240
|
+
```java
|
|
241
|
+
// src/main/java/com/example/accounting/application/port/in/AccountUseCase.java
|
|
242
|
+
package com.example.accounting.application.port.in;
|
|
243
|
+
|
|
244
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
245
|
+
|
|
246
|
+
import java.util.List;
|
|
247
|
+
|
|
248
|
+
public interface AccountUseCase {
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 勘定科目を取得
|
|
252
|
+
*/
|
|
253
|
+
AccountResponse getAccount(String accountCode);
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* 全勘定科目を取得
|
|
257
|
+
*/
|
|
258
|
+
List<AccountResponse> getAllAccounts();
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* BS/PL区分で勘定科目を取得
|
|
262
|
+
*/
|
|
263
|
+
List<AccountResponse> getAccountsByBsPlType(String bsPlType);
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 科目階層を取得(親科目以下の全科目)
|
|
267
|
+
*/
|
|
268
|
+
List<AccountResponse> getAccountHierarchy(String parentAccountCode);
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 計上科目のみ取得
|
|
272
|
+
*/
|
|
273
|
+
List<AccountResponse> getPostingAccounts();
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 勘定科目を登録
|
|
277
|
+
*/
|
|
278
|
+
AccountResponse createAccount(CreateAccountCommand command);
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* 勘定科目を更新
|
|
282
|
+
*/
|
|
283
|
+
AccountResponse updateAccount(String accountCode, UpdateAccountCommand command);
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 勘定科目を削除
|
|
287
|
+
*/
|
|
288
|
+
void deleteAccount(String accountCode);
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
</details>
|
|
293
|
+
|
|
294
|
+
### 21.3.2 TDD による実装(Red-Green-Refactor)
|
|
295
|
+
|
|
296
|
+
#### Red: 失敗するテストを書く
|
|
297
|
+
|
|
298
|
+
<details>
|
|
299
|
+
<summary>Controller テスト</summary>
|
|
300
|
+
|
|
301
|
+
```java
|
|
302
|
+
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerTest.java
|
|
303
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
304
|
+
|
|
305
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
306
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
307
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
308
|
+
import org.junit.jupiter.api.*;
|
|
309
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
310
|
+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
|
311
|
+
import org.springframework.boot.test.mock.mockito.MockBean;
|
|
312
|
+
import org.springframework.http.MediaType;
|
|
313
|
+
import org.springframework.test.web.servlet.MockMvc;
|
|
314
|
+
|
|
315
|
+
import java.util.List;
|
|
316
|
+
|
|
317
|
+
import static org.mockito.ArgumentMatchers.*;
|
|
318
|
+
import static org.mockito.BDDMockito.*;
|
|
319
|
+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
320
|
+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
321
|
+
|
|
322
|
+
@WebMvcTest(AccountController.class)
|
|
323
|
+
@DisplayName("勘定科目マスタ API")
|
|
324
|
+
class AccountControllerTest {
|
|
325
|
+
|
|
326
|
+
@Autowired
|
|
327
|
+
private MockMvc mockMvc;
|
|
328
|
+
|
|
329
|
+
@Autowired
|
|
330
|
+
private ObjectMapper objectMapper;
|
|
331
|
+
|
|
332
|
+
@MockBean
|
|
333
|
+
private AccountUseCase accountUseCase;
|
|
334
|
+
|
|
335
|
+
@Nested
|
|
336
|
+
@DisplayName("GET /api/accounts/{accountCode}")
|
|
337
|
+
class GetAccount {
|
|
338
|
+
|
|
339
|
+
@Test
|
|
340
|
+
@DisplayName("勘定科目を取得できる")
|
|
341
|
+
void canGetAccount() throws Exception {
|
|
342
|
+
// Given
|
|
343
|
+
AccountResponse response = AccountResponse.builder()
|
|
344
|
+
.accountCode("11110")
|
|
345
|
+
.accountName("現金")
|
|
346
|
+
.accountShortName("現金")
|
|
347
|
+
.bsPlType("BS")
|
|
348
|
+
.dcType("借方")
|
|
349
|
+
.elementType("資産")
|
|
350
|
+
.summaryType("計上科目")
|
|
351
|
+
.build();
|
|
352
|
+
|
|
353
|
+
given(accountUseCase.getAccount("11110")).willReturn(response);
|
|
354
|
+
|
|
355
|
+
// When & Then
|
|
356
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "11110"))
|
|
357
|
+
.andExpect(status().isOk())
|
|
358
|
+
.andExpect(jsonPath("$.accountCode").value("11110"))
|
|
359
|
+
.andExpect(jsonPath("$.accountName").value("現金"))
|
|
360
|
+
.andExpect(jsonPath("$.bsPlType").value("BS"));
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
@Test
|
|
364
|
+
@DisplayName("存在しない勘定科目は404を返す")
|
|
365
|
+
void notFoundForNonExistent() throws Exception {
|
|
366
|
+
// Given
|
|
367
|
+
given(accountUseCase.getAccount("99999")).willThrow(
|
|
368
|
+
new AccountNotFoundException("99999"));
|
|
369
|
+
|
|
370
|
+
// When & Then
|
|
371
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
372
|
+
.andExpect(status().isNotFound());
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
@Nested
|
|
377
|
+
@DisplayName("POST /api/accounts")
|
|
378
|
+
class CreateAccount {
|
|
379
|
+
|
|
380
|
+
@Test
|
|
381
|
+
@DisplayName("勘定科目を登録できる")
|
|
382
|
+
void canCreateAccount() throws Exception {
|
|
383
|
+
// Given
|
|
384
|
+
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
385
|
+
.accountCode("11150")
|
|
386
|
+
.accountName("手許現金")
|
|
387
|
+
.bsPlType("BS")
|
|
388
|
+
.dcType("借方")
|
|
389
|
+
.elementType("資産")
|
|
390
|
+
.summaryType("計上科目")
|
|
391
|
+
.build();
|
|
392
|
+
|
|
393
|
+
AccountResponse response = AccountResponse.builder()
|
|
394
|
+
.accountCode("11150")
|
|
395
|
+
.accountName("手許現金")
|
|
396
|
+
.bsPlType("BS")
|
|
397
|
+
.dcType("借方")
|
|
398
|
+
.build();
|
|
399
|
+
|
|
400
|
+
given(accountUseCase.createAccount(any())).willReturn(response);
|
|
401
|
+
|
|
402
|
+
// When & Then
|
|
403
|
+
mockMvc.perform(post("/api/accounts")
|
|
404
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
405
|
+
.content(objectMapper.writeValueAsString(command)))
|
|
406
|
+
.andExpect(status().isCreated())
|
|
407
|
+
.andExpect(jsonPath("$.accountCode").value("11150"));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
@Test
|
|
411
|
+
@DisplayName("バリデーションエラーで400を返す")
|
|
412
|
+
void badRequestForValidationError() throws Exception {
|
|
413
|
+
// Given
|
|
414
|
+
CreateAccountCommand command = CreateAccountCommand.builder()
|
|
415
|
+
.accountCode("") // 必須項目が空
|
|
416
|
+
.build();
|
|
417
|
+
|
|
418
|
+
// When & Then
|
|
419
|
+
mockMvc.perform(post("/api/accounts")
|
|
420
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
421
|
+
.content(objectMapper.writeValueAsString(command)))
|
|
422
|
+
.andExpect(status().isBadRequest());
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
</details>
|
|
429
|
+
|
|
430
|
+
#### Green: テストを通す最小限の実装
|
|
431
|
+
|
|
432
|
+
<details>
|
|
433
|
+
<summary>Controller の実装</summary>
|
|
434
|
+
|
|
435
|
+
```java
|
|
436
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/AccountController.java
|
|
437
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
438
|
+
|
|
439
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
440
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
441
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
442
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
443
|
+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
|
444
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
445
|
+
import jakarta.validation.Valid;
|
|
446
|
+
import lombok.RequiredArgsConstructor;
|
|
447
|
+
import org.springframework.http.HttpStatus;
|
|
448
|
+
import org.springframework.http.ResponseEntity;
|
|
449
|
+
import org.springframework.web.bind.annotation.*;
|
|
450
|
+
|
|
451
|
+
import java.util.List;
|
|
452
|
+
|
|
453
|
+
@RestController
|
|
454
|
+
@RequestMapping("/api/accounts")
|
|
455
|
+
@RequiredArgsConstructor
|
|
456
|
+
@Tag(name = "勘定科目マスタ", description = "勘定科目マスタの管理API")
|
|
457
|
+
public class AccountController {
|
|
458
|
+
|
|
459
|
+
private final AccountUseCase accountUseCase;
|
|
460
|
+
|
|
461
|
+
@GetMapping("/{accountCode}")
|
|
462
|
+
@Operation(summary = "勘定科目取得", description = "勘定科目コードで勘定科目を取得します")
|
|
463
|
+
@ApiResponse(responseCode = "200", description = "取得成功")
|
|
464
|
+
@ApiResponse(responseCode = "404", description = "勘定科目が存在しない")
|
|
465
|
+
public ResponseEntity<AccountResponse> getAccount(
|
|
466
|
+
@Parameter(description = "勘定科目コード")
|
|
467
|
+
@PathVariable String accountCode) {
|
|
468
|
+
return ResponseEntity.ok(accountUseCase.getAccount(accountCode));
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
@GetMapping
|
|
472
|
+
@Operation(summary = "勘定科目一覧取得", description = "勘定科目の一覧を取得します")
|
|
473
|
+
public ResponseEntity<List<AccountResponse>> getAccounts(
|
|
474
|
+
@Parameter(description = "BSPL区分(BS/PL)")
|
|
475
|
+
@RequestParam(required = false) String bsPlType,
|
|
476
|
+
@Parameter(description = "計上科目のみ")
|
|
477
|
+
@RequestParam(required = false, defaultValue = "false") boolean postingOnly) {
|
|
478
|
+
|
|
479
|
+
List<AccountResponse> accounts;
|
|
480
|
+
if (bsPlType != null) {
|
|
481
|
+
accounts = accountUseCase.getAccountsByBsPlType(bsPlType);
|
|
482
|
+
} else if (postingOnly) {
|
|
483
|
+
accounts = accountUseCase.getPostingAccounts();
|
|
484
|
+
} else {
|
|
485
|
+
accounts = accountUseCase.getAllAccounts();
|
|
486
|
+
}
|
|
487
|
+
return ResponseEntity.ok(accounts);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
@PostMapping
|
|
491
|
+
@Operation(summary = "勘定科目登録", description = "新規勘定科目を登録します")
|
|
492
|
+
@ApiResponse(responseCode = "201", description = "登録成功")
|
|
493
|
+
@ApiResponse(responseCode = "400", description = "バリデーションエラー")
|
|
494
|
+
public ResponseEntity<AccountResponse> createAccount(
|
|
495
|
+
@Valid @RequestBody CreateAccountCommand command) {
|
|
496
|
+
AccountResponse response = accountUseCase.createAccount(command);
|
|
497
|
+
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
@PutMapping("/{accountCode}")
|
|
501
|
+
@Operation(summary = "勘定科目更新", description = "勘定科目を更新します")
|
|
502
|
+
public ResponseEntity<AccountResponse> updateAccount(
|
|
503
|
+
@PathVariable String accountCode,
|
|
504
|
+
@Valid @RequestBody UpdateAccountCommand command) {
|
|
505
|
+
return ResponseEntity.ok(accountUseCase.updateAccount(accountCode, command));
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
@DeleteMapping("/{accountCode}")
|
|
509
|
+
@Operation(summary = "勘定科目削除", description = "勘定科目を削除します")
|
|
510
|
+
@ApiResponse(responseCode = "204", description = "削除成功")
|
|
511
|
+
public ResponseEntity<Void> deleteAccount(@PathVariable String accountCode) {
|
|
512
|
+
accountUseCase.deleteAccount(accountCode);
|
|
513
|
+
return ResponseEntity.noContent().build();
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
</details>
|
|
519
|
+
|
|
520
|
+
#### Refactor: Application Service の実装
|
|
521
|
+
|
|
522
|
+
<details>
|
|
523
|
+
<summary>Application Service</summary>
|
|
524
|
+
|
|
525
|
+
```java
|
|
526
|
+
// src/main/java/com/example/accounting/application/service/AccountApplicationService.java
|
|
527
|
+
package com.example.accounting.application.service;
|
|
528
|
+
|
|
529
|
+
import com.example.accounting.application.port.in.AccountUseCase;
|
|
530
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
531
|
+
import com.example.accounting.application.port.out.AccountRepository;
|
|
532
|
+
import com.example.accounting.application.port.out.AccountConfigRepository;
|
|
533
|
+
import com.example.accounting.domain.model.account.*;
|
|
534
|
+
import lombok.RequiredArgsConstructor;
|
|
535
|
+
import org.springframework.stereotype.Service;
|
|
536
|
+
import org.springframework.transaction.annotation.Transactional;
|
|
537
|
+
|
|
538
|
+
import java.util.List;
|
|
539
|
+
import java.util.stream.Collectors;
|
|
540
|
+
|
|
541
|
+
@Service
|
|
542
|
+
@RequiredArgsConstructor
|
|
543
|
+
@Transactional(readOnly = true)
|
|
544
|
+
public class AccountApplicationService implements AccountUseCase {
|
|
545
|
+
|
|
546
|
+
private final AccountRepository accountRepository;
|
|
547
|
+
private final AccountConfigRepository accountConfigRepository;
|
|
548
|
+
|
|
549
|
+
@Override
|
|
550
|
+
public AccountResponse getAccount(String accountCode) {
|
|
551
|
+
AccountMaster account = accountRepository.findByCode(accountCode)
|
|
552
|
+
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
553
|
+
return AccountResponse.from(account);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
@Override
|
|
557
|
+
public List<AccountResponse> getAllAccounts() {
|
|
558
|
+
return accountRepository.findAll().stream()
|
|
559
|
+
.map(AccountResponse::from)
|
|
560
|
+
.collect(Collectors.toList());
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
@Override
|
|
564
|
+
public List<AccountResponse> getAccountsByBsPlType(String bsPlType) {
|
|
565
|
+
return accountRepository.findByBsPlType(bsPlType).stream()
|
|
566
|
+
.map(AccountResponse::from)
|
|
567
|
+
.collect(Collectors.toList());
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
@Override
|
|
571
|
+
public List<AccountResponse> getAccountHierarchy(String parentAccountCode) {
|
|
572
|
+
String pathPattern = "%" + parentAccountCode + "%";
|
|
573
|
+
return accountRepository.findByPathLike(pathPattern).stream()
|
|
574
|
+
.map(AccountResponse::from)
|
|
575
|
+
.collect(Collectors.toList());
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
@Override
|
|
579
|
+
public List<AccountResponse> getPostingAccounts() {
|
|
580
|
+
return accountRepository.findPostingAccounts().stream()
|
|
581
|
+
.map(AccountResponse::from)
|
|
582
|
+
.collect(Collectors.toList());
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
@Override
|
|
586
|
+
@Transactional
|
|
587
|
+
public AccountResponse createAccount(CreateAccountCommand command) {
|
|
588
|
+
if (accountRepository.exists(command.getAccountCode())) {
|
|
589
|
+
throw new AccountAlreadyExistsException(command.getAccountCode());
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
AccountMaster account = AccountMaster.builder()
|
|
593
|
+
.accountCode(command.getAccountCode())
|
|
594
|
+
.accountName(command.getAccountName())
|
|
595
|
+
.accountShortName(command.getAccountShortName())
|
|
596
|
+
.bsPlType(BsPlType.valueOf(command.getBsPlType()))
|
|
597
|
+
.dcType(AccountDcType.fromDisplayName(command.getDcType()))
|
|
598
|
+
.elementType(ElementType.fromDisplayName(command.getElementType()))
|
|
599
|
+
.summaryType(SummaryType.fromDisplayName(command.getSummaryType()))
|
|
600
|
+
.taxCode(command.getTaxCode())
|
|
601
|
+
.build();
|
|
602
|
+
|
|
603
|
+
accountRepository.save(account);
|
|
604
|
+
|
|
605
|
+
String accountPath = generateAccountPath(command.getAccountCode(), command.getParentAccountCode());
|
|
606
|
+
AccountConfig config = AccountConfig.builder()
|
|
607
|
+
.accountCode(command.getAccountCode())
|
|
608
|
+
.accountPath(accountPath)
|
|
609
|
+
.build();
|
|
610
|
+
accountConfigRepository.save(config);
|
|
611
|
+
|
|
612
|
+
return AccountResponse.from(account);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
@Override
|
|
616
|
+
@Transactional
|
|
617
|
+
public AccountResponse updateAccount(String accountCode, UpdateAccountCommand command) {
|
|
618
|
+
AccountMaster account = accountRepository.findByCode(accountCode)
|
|
619
|
+
.orElseThrow(() -> new AccountNotFoundException(accountCode));
|
|
620
|
+
|
|
621
|
+
if (command.getAccountName() != null) {
|
|
622
|
+
account.setAccountName(command.getAccountName());
|
|
623
|
+
}
|
|
624
|
+
if (command.getAccountShortName() != null) {
|
|
625
|
+
account.setAccountShortName(command.getAccountShortName());
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
accountRepository.save(account);
|
|
629
|
+
return AccountResponse.from(account);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
@Override
|
|
633
|
+
@Transactional
|
|
634
|
+
public void deleteAccount(String accountCode) {
|
|
635
|
+
if (!accountRepository.exists(accountCode)) {
|
|
636
|
+
throw new AccountNotFoundException(accountCode);
|
|
637
|
+
}
|
|
638
|
+
accountConfigRepository.delete(accountCode);
|
|
639
|
+
accountRepository.delete(accountCode);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
private String generateAccountPath(String accountCode, String parentAccountCode) {
|
|
643
|
+
if (parentAccountCode == null || parentAccountCode.isEmpty()) {
|
|
644
|
+
return accountCode;
|
|
645
|
+
}
|
|
646
|
+
return accountConfigRepository.findByCode(parentAccountCode)
|
|
647
|
+
.map(parent -> parent.getAccountPath() + "~" + accountCode)
|
|
648
|
+
.orElse(accountCode);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
</details>
|
|
654
|
+
|
|
655
|
+
### 21.3.3 補助科目マスタ API
|
|
656
|
+
|
|
657
|
+
補助科目は勘定科目に紐づく詳細区分で、得意先・仕入先・銀行口座などを管理します。
|
|
658
|
+
|
|
659
|
+
| メソッド | パス | 説明 |
|
|
660
|
+
|---------|------|------|
|
|
661
|
+
| GET | /api/accounts/{accountCode}/sub-accounts | 補助科目一覧取得 |
|
|
662
|
+
| POST | /api/accounts/{accountCode}/sub-accounts | 補助科目登録 |
|
|
663
|
+
|
|
664
|
+
## 21.4 トランザクション API の実装
|
|
665
|
+
|
|
666
|
+
### 21.4.1 仕訳 API
|
|
667
|
+
|
|
668
|
+
仕訳の登録・照会・訂正・取消を行う API を実装します。
|
|
669
|
+
|
|
670
|
+
| メソッド | パス | 説明 |
|
|
671
|
+
|---------|------|------|
|
|
672
|
+
| GET | /api/journals | 仕訳一覧取得 |
|
|
673
|
+
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
674
|
+
| POST | /api/journals | 仕訳登録 |
|
|
675
|
+
| POST | /api/journals/check-balance | 貸借バランスチェック |
|
|
676
|
+
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消(赤黒処理) |
|
|
677
|
+
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正(赤黒処理) |
|
|
678
|
+
|
|
679
|
+
<details>
|
|
680
|
+
<summary>仕訳ユースケースインターフェース</summary>
|
|
681
|
+
|
|
682
|
+
```java
|
|
683
|
+
// src/main/java/com/example/accounting/application/port/in/JournalUseCase.java
|
|
684
|
+
package com.example.accounting.application.port.in;
|
|
685
|
+
|
|
686
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
687
|
+
|
|
688
|
+
import java.time.LocalDate;
|
|
689
|
+
import java.util.List;
|
|
690
|
+
|
|
691
|
+
public interface JournalUseCase {
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* 仕訳を取得
|
|
695
|
+
*/
|
|
696
|
+
JournalResponse getJournal(String journalNumber);
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* 日付範囲で仕訳を検索
|
|
700
|
+
*/
|
|
701
|
+
List<JournalResponse> getJournalsByDateRange(LocalDate fromDate, LocalDate toDate);
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* 部門で仕訳を検索
|
|
705
|
+
*/
|
|
706
|
+
List<JournalResponse> getJournalsByDepartment(String departmentCode, LocalDate fromDate, LocalDate toDate);
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* 仕訳を登録
|
|
710
|
+
*/
|
|
711
|
+
JournalResponse createJournal(CreateJournalCommand command);
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* 仕訳を取消(赤黒処理)
|
|
715
|
+
*/
|
|
716
|
+
JournalCancellationResult cancelJournal(String journalNumber, String reason);
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* 仕訳を訂正(赤黒処理)
|
|
720
|
+
*/
|
|
721
|
+
JournalCorrectionResult correctJournal(String journalNumber, CreateJournalCommand correctedData, String reason);
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* 貸借バランスをチェック
|
|
725
|
+
*/
|
|
726
|
+
BalanceCheckResult checkBalance(CreateJournalCommand command);
|
|
727
|
+
}
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
</details>
|
|
731
|
+
|
|
732
|
+
<details>
|
|
733
|
+
<summary>仕訳 Controller</summary>
|
|
734
|
+
|
|
735
|
+
```java
|
|
736
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/JournalController.java
|
|
737
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
738
|
+
|
|
739
|
+
import com.example.accounting.application.port.in.JournalUseCase;
|
|
740
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
741
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
742
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
743
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
744
|
+
import jakarta.validation.Valid;
|
|
745
|
+
import lombok.RequiredArgsConstructor;
|
|
746
|
+
import org.springframework.format.annotation.DateTimeFormat;
|
|
747
|
+
import org.springframework.http.HttpStatus;
|
|
748
|
+
import org.springframework.http.ResponseEntity;
|
|
749
|
+
import org.springframework.web.bind.annotation.*;
|
|
750
|
+
|
|
751
|
+
import java.time.LocalDate;
|
|
752
|
+
import java.util.List;
|
|
753
|
+
|
|
754
|
+
@RestController
|
|
755
|
+
@RequestMapping("/api/journals")
|
|
756
|
+
@RequiredArgsConstructor
|
|
757
|
+
@Tag(name = "仕訳", description = "仕訳の管理API")
|
|
758
|
+
public class JournalController {
|
|
759
|
+
|
|
760
|
+
private final JournalUseCase journalUseCase;
|
|
761
|
+
|
|
762
|
+
@GetMapping("/{journalNumber}")
|
|
763
|
+
@Operation(summary = "仕訳取得", description = "仕訳伝票番号で仕訳を取得します")
|
|
764
|
+
public ResponseEntity<JournalResponse> getJournal(
|
|
765
|
+
@Parameter(description = "仕訳伝票番号")
|
|
766
|
+
@PathVariable String journalNumber) {
|
|
767
|
+
return ResponseEntity.ok(journalUseCase.getJournal(journalNumber));
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
@GetMapping
|
|
771
|
+
@Operation(summary = "仕訳一覧取得", description = "条件を指定して仕訳を検索します")
|
|
772
|
+
public ResponseEntity<List<JournalResponse>> getJournals(
|
|
773
|
+
@Parameter(description = "開始日")
|
|
774
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
775
|
+
@Parameter(description = "終了日")
|
|
776
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate,
|
|
777
|
+
@Parameter(description = "部門コード")
|
|
778
|
+
@RequestParam(required = false) String departmentCode) {
|
|
779
|
+
|
|
780
|
+
List<JournalResponse> journals;
|
|
781
|
+
if (departmentCode != null) {
|
|
782
|
+
journals = journalUseCase.getJournalsByDepartment(departmentCode, fromDate, toDate);
|
|
783
|
+
} else {
|
|
784
|
+
journals = journalUseCase.getJournalsByDateRange(fromDate, toDate);
|
|
785
|
+
}
|
|
786
|
+
return ResponseEntity.ok(journals);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
@PostMapping
|
|
790
|
+
@Operation(summary = "仕訳登録", description = "新規仕訳を登録します")
|
|
791
|
+
public ResponseEntity<JournalResponse> createJournal(
|
|
792
|
+
@Valid @RequestBody CreateJournalCommand command) {
|
|
793
|
+
JournalResponse response = journalUseCase.createJournal(command);
|
|
794
|
+
return ResponseEntity.status(HttpStatus.CREATED).body(response);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
@PostMapping("/check-balance")
|
|
798
|
+
@Operation(summary = "貸借バランスチェック", description = "仕訳の貸借バランスをチェックします")
|
|
799
|
+
public ResponseEntity<BalanceCheckResult> checkBalance(
|
|
800
|
+
@Valid @RequestBody CreateJournalCommand command) {
|
|
801
|
+
return ResponseEntity.ok(journalUseCase.checkBalance(command));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
@PostMapping("/{journalNumber}/cancel")
|
|
805
|
+
@Operation(summary = "仕訳取消", description = "仕訳を赤黒処理で取消します")
|
|
806
|
+
public ResponseEntity<JournalCancellationResult> cancelJournal(
|
|
807
|
+
@PathVariable String journalNumber,
|
|
808
|
+
@RequestParam String reason) {
|
|
809
|
+
return ResponseEntity.ok(journalUseCase.cancelJournal(journalNumber, reason));
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
@PostMapping("/{journalNumber}/correct")
|
|
813
|
+
@Operation(summary = "仕訳訂正", description = "仕訳を赤黒処理で訂正します")
|
|
814
|
+
public ResponseEntity<JournalCorrectionResult> correctJournal(
|
|
815
|
+
@PathVariable String journalNumber,
|
|
816
|
+
@RequestParam String reason,
|
|
817
|
+
@Valid @RequestBody CreateJournalCommand correctedData) {
|
|
818
|
+
return ResponseEntity.ok(journalUseCase.correctJournal(journalNumber, correctedData, reason));
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
</details>
|
|
824
|
+
|
|
825
|
+
### 21.4.2 残高照会 API
|
|
826
|
+
|
|
827
|
+
日次残高・月次残高・部門別残高を照会する API を実装します。
|
|
828
|
+
|
|
829
|
+
| メソッド | パス | 説明 |
|
|
830
|
+
|---------|------|------|
|
|
831
|
+
| GET | /api/balances/daily | 日次残高取得 |
|
|
832
|
+
| GET | /api/balances/monthly | 月次残高取得 |
|
|
833
|
+
| GET | /api/balances/accounts/{accountCode} | 勘定科目別残高取得 |
|
|
834
|
+
| GET | /api/balances/departments | 部門別残高取得 |
|
|
835
|
+
|
|
836
|
+
<details>
|
|
837
|
+
<summary>残高照会 Controller</summary>
|
|
838
|
+
|
|
839
|
+
```java
|
|
840
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/BalanceController.java
|
|
841
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
842
|
+
|
|
843
|
+
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
844
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
845
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
846
|
+
import io.swagger.v3.oas.annotations.Parameter;
|
|
847
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
848
|
+
import lombok.RequiredArgsConstructor;
|
|
849
|
+
import org.springframework.format.annotation.DateTimeFormat;
|
|
850
|
+
import org.springframework.http.ResponseEntity;
|
|
851
|
+
import org.springframework.web.bind.annotation.*;
|
|
852
|
+
|
|
853
|
+
import java.time.LocalDate;
|
|
854
|
+
import java.util.List;
|
|
855
|
+
|
|
856
|
+
@RestController
|
|
857
|
+
@RequestMapping("/api/balances")
|
|
858
|
+
@RequiredArgsConstructor
|
|
859
|
+
@Tag(name = "残高照会", description = "勘定科目残高の照会API")
|
|
860
|
+
public class BalanceController {
|
|
861
|
+
|
|
862
|
+
private final BalanceUseCase balanceUseCase;
|
|
863
|
+
|
|
864
|
+
@GetMapping("/daily")
|
|
865
|
+
@Operation(summary = "日次残高取得", description = "指定日の勘定科目残高を取得します")
|
|
866
|
+
public ResponseEntity<List<DailyBalanceResponse>> getDailyBalances(
|
|
867
|
+
@Parameter(description = "対象日")
|
|
868
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
|
|
869
|
+
@Parameter(description = "勘定科目コード(省略時は全科目)")
|
|
870
|
+
@RequestParam(required = false) String accountCode) {
|
|
871
|
+
return ResponseEntity.ok(balanceUseCase.getDailyBalances(date, accountCode));
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
@GetMapping("/monthly")
|
|
875
|
+
@Operation(summary = "月次残高取得", description = "指定月の勘定科目残高を取得します")
|
|
876
|
+
public ResponseEntity<List<MonthlyBalanceResponse>> getMonthlyBalances(
|
|
877
|
+
@Parameter(description = "決算期")
|
|
878
|
+
@RequestParam int fiscalYear,
|
|
879
|
+
@Parameter(description = "月度")
|
|
880
|
+
@RequestParam int month) {
|
|
881
|
+
return ResponseEntity.ok(balanceUseCase.getMonthlyBalances(fiscalYear, month));
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
@GetMapping("/accounts/{accountCode}")
|
|
885
|
+
@Operation(summary = "勘定科目別残高取得", description = "勘定科目の期間別残高を取得します")
|
|
886
|
+
public ResponseEntity<AccountBalanceSummary> getAccountBalanceSummary(
|
|
887
|
+
@PathVariable String accountCode,
|
|
888
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDate,
|
|
889
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDate) {
|
|
890
|
+
return ResponseEntity.ok(balanceUseCase.getAccountBalanceSummary(accountCode, fromDate, toDate));
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
@GetMapping("/departments")
|
|
894
|
+
@Operation(summary = "部門別残高取得", description = "部門別の勘定科目残高を取得します")
|
|
895
|
+
public ResponseEntity<List<DepartmentBalanceResponse>> getDepartmentBalances(
|
|
896
|
+
@RequestParam int fiscalYear,
|
|
897
|
+
@RequestParam int month,
|
|
898
|
+
@RequestParam(required = false) String accountCode) {
|
|
899
|
+
return ResponseEntity.ok(balanceUseCase.getDepartmentBalances(fiscalYear, month, accountCode));
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
</details>
|
|
905
|
+
|
|
906
|
+
### 21.4.3 試算表 API
|
|
907
|
+
|
|
908
|
+
日計表と合計残高試算表を出力する API を実装します。
|
|
909
|
+
|
|
910
|
+
<details>
|
|
911
|
+
<summary>帳票出力 Controller</summary>
|
|
912
|
+
|
|
913
|
+
```java
|
|
914
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/ReportController.java
|
|
915
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
916
|
+
|
|
917
|
+
import com.example.accounting.application.port.in.BalanceUseCase;
|
|
918
|
+
import com.example.accounting.application.port.in.dto.*;
|
|
919
|
+
import io.swagger.v3.oas.annotations.Operation;
|
|
920
|
+
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
921
|
+
import lombok.RequiredArgsConstructor;
|
|
922
|
+
import org.springframework.format.annotation.DateTimeFormat;
|
|
923
|
+
import org.springframework.http.ResponseEntity;
|
|
924
|
+
import org.springframework.web.bind.annotation.*;
|
|
925
|
+
|
|
926
|
+
import java.time.LocalDate;
|
|
927
|
+
|
|
928
|
+
@RestController
|
|
929
|
+
@RequestMapping("/api/reports")
|
|
930
|
+
@RequiredArgsConstructor
|
|
931
|
+
@Tag(name = "帳票出力", description = "会計帳票の出力API")
|
|
932
|
+
public class ReportController {
|
|
933
|
+
|
|
934
|
+
private final BalanceUseCase balanceUseCase;
|
|
935
|
+
|
|
936
|
+
@GetMapping("/daily-report")
|
|
937
|
+
@Operation(summary = "日計表取得", description = "指定日の日計表データを取得します")
|
|
938
|
+
public ResponseEntity<DailyReportResponse> getDailyReport(
|
|
939
|
+
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
|
|
940
|
+
return ResponseEntity.ok(balanceUseCase.getDailyReport(date));
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
@GetMapping("/trial-balance")
|
|
944
|
+
@Operation(summary = "合計残高試算表取得", description = "指定月の合計残高試算表を取得します")
|
|
945
|
+
public ResponseEntity<TrialBalanceResponse> getTrialBalance(
|
|
946
|
+
@RequestParam int fiscalYear,
|
|
947
|
+
@RequestParam int month) {
|
|
948
|
+
return ResponseEntity.ok(balanceUseCase.getTrialBalance(fiscalYear, month));
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
</details>
|
|
954
|
+
|
|
955
|
+
<details>
|
|
956
|
+
<summary>合計残高試算表レスポンス DTO</summary>
|
|
957
|
+
|
|
958
|
+
```java
|
|
959
|
+
// src/main/java/com/example/accounting/application/port/in/dto/TrialBalanceResponse.java
|
|
960
|
+
package com.example.accounting.application.port.in.dto;
|
|
961
|
+
|
|
962
|
+
import lombok.Builder;
|
|
963
|
+
import lombok.Data;
|
|
964
|
+
|
|
965
|
+
import java.math.BigDecimal;
|
|
966
|
+
import java.util.List;
|
|
967
|
+
|
|
968
|
+
@Data
|
|
969
|
+
@Builder
|
|
970
|
+
public class TrialBalanceResponse {
|
|
971
|
+
private int fiscalYear;
|
|
972
|
+
private int month;
|
|
973
|
+
private List<TrialBalanceLine> lines;
|
|
974
|
+
private TrialBalanceTotals totals;
|
|
975
|
+
|
|
976
|
+
@Data
|
|
977
|
+
@Builder
|
|
978
|
+
public static class TrialBalanceLine {
|
|
979
|
+
private String accountCode;
|
|
980
|
+
private String accountName;
|
|
981
|
+
private String bsPlType;
|
|
982
|
+
private String dcType;
|
|
983
|
+
private BigDecimal openingBalance;
|
|
984
|
+
private BigDecimal debitAmount;
|
|
985
|
+
private BigDecimal creditAmount;
|
|
986
|
+
private BigDecimal closingBalance;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
@Data
|
|
990
|
+
@Builder
|
|
991
|
+
public static class TrialBalanceTotals {
|
|
992
|
+
private BigDecimal totalOpeningDebit;
|
|
993
|
+
private BigDecimal totalOpeningCredit;
|
|
994
|
+
private BigDecimal totalDebit;
|
|
995
|
+
private BigDecimal totalCredit;
|
|
996
|
+
private BigDecimal totalClosingDebit;
|
|
997
|
+
private BigDecimal totalClosingCredit;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
</details>
|
|
1003
|
+
|
|
1004
|
+
## 21.5 エラーハンドリング
|
|
1005
|
+
|
|
1006
|
+
### 21.5.1 ドメイン例外の定義
|
|
1007
|
+
|
|
1008
|
+
```plantuml
|
|
1009
|
+
@startuml
|
|
1010
|
+
|
|
1011
|
+
title エラー階層
|
|
1012
|
+
|
|
1013
|
+
abstract class AccountingException {
|
|
1014
|
+
- errorCode: String
|
|
1015
|
+
- message: String
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
class AccountNotFoundException extends AccountingException
|
|
1019
|
+
class AccountAlreadyExistsException extends AccountingException
|
|
1020
|
+
class JournalNotFoundException extends AccountingException
|
|
1021
|
+
class JournalBalanceException extends AccountingException
|
|
1022
|
+
class JournalAlreadyCancelledException extends AccountingException
|
|
1023
|
+
class ValidationException extends AccountingException
|
|
1024
|
+
|
|
1025
|
+
note right of AccountingException
|
|
1026
|
+
ドメイン例外の基底クラス
|
|
1027
|
+
HTTPステータスは
|
|
1028
|
+
Controller層で決定
|
|
1029
|
+
end note
|
|
1030
|
+
|
|
1031
|
+
@enduml
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
<details>
|
|
1035
|
+
<summary>ドメイン例外クラス</summary>
|
|
1036
|
+
|
|
1037
|
+
```java
|
|
1038
|
+
// src/main/java/com/example/accounting/domain/exception/AccountingException.java
|
|
1039
|
+
package com.example.accounting.domain.exception;
|
|
1040
|
+
|
|
1041
|
+
import lombok.Getter;
|
|
1042
|
+
|
|
1043
|
+
@Getter
|
|
1044
|
+
public abstract class AccountingException extends RuntimeException {
|
|
1045
|
+
private final String errorCode;
|
|
1046
|
+
|
|
1047
|
+
protected AccountingException(String errorCode, String message) {
|
|
1048
|
+
super(message);
|
|
1049
|
+
this.errorCode = errorCode;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
// AccountNotFoundException.java
|
|
1054
|
+
package com.example.accounting.domain.exception;
|
|
1055
|
+
|
|
1056
|
+
public class AccountNotFoundException extends AccountingException {
|
|
1057
|
+
public AccountNotFoundException(String accountCode) {
|
|
1058
|
+
super("ACC001", "勘定科目が見つかりません: " + accountCode);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
// JournalBalanceException.java
|
|
1063
|
+
package com.example.accounting.domain.exception;
|
|
1064
|
+
|
|
1065
|
+
import java.math.BigDecimal;
|
|
1066
|
+
|
|
1067
|
+
public class JournalBalanceException extends AccountingException {
|
|
1068
|
+
public JournalBalanceException(BigDecimal debit, BigDecimal credit) {
|
|
1069
|
+
super("JNL001", String.format("貸借が一致しません。借方合計: %s, 貸方合計: %s", debit, credit));
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
```
|
|
1073
|
+
|
|
1074
|
+
</details>
|
|
1075
|
+
|
|
1076
|
+
### 21.5.2 グローバル例外ハンドラー
|
|
1077
|
+
|
|
1078
|
+
<details>
|
|
1079
|
+
<summary>GlobalExceptionHandler</summary>
|
|
1080
|
+
|
|
1081
|
+
```java
|
|
1082
|
+
// src/main/java/com/example/accounting/infrastructure/adapter/in/web/GlobalExceptionHandler.java
|
|
1083
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1084
|
+
|
|
1085
|
+
import com.example.accounting.domain.exception.*;
|
|
1086
|
+
import lombok.Builder;
|
|
1087
|
+
import lombok.Data;
|
|
1088
|
+
import lombok.extern.slf4j.Slf4j;
|
|
1089
|
+
import org.springframework.http.HttpStatus;
|
|
1090
|
+
import org.springframework.http.ResponseEntity;
|
|
1091
|
+
import org.springframework.validation.FieldError;
|
|
1092
|
+
import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
1093
|
+
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
1094
|
+
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
1095
|
+
|
|
1096
|
+
import java.time.LocalDateTime;
|
|
1097
|
+
import java.util.HashMap;
|
|
1098
|
+
import java.util.Map;
|
|
1099
|
+
|
|
1100
|
+
@RestControllerAdvice
|
|
1101
|
+
@Slf4j
|
|
1102
|
+
public class GlobalExceptionHandler {
|
|
1103
|
+
|
|
1104
|
+
@ExceptionHandler(AccountNotFoundException.class)
|
|
1105
|
+
public ResponseEntity<ErrorResponse> handleAccountNotFoundException(AccountNotFoundException e) {
|
|
1106
|
+
log.warn("Account not found: {}", e.getMessage());
|
|
1107
|
+
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1108
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
@ExceptionHandler(JournalNotFoundException.class)
|
|
1112
|
+
public ResponseEntity<ErrorResponse> handleJournalNotFoundException(JournalNotFoundException e) {
|
|
1113
|
+
log.warn("Journal not found: {}", e.getMessage());
|
|
1114
|
+
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
|
1115
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
@ExceptionHandler(JournalBalanceException.class)
|
|
1119
|
+
public ResponseEntity<ErrorResponse> handleJournalBalanceException(JournalBalanceException e) {
|
|
1120
|
+
log.warn("Journal balance error: {}", e.getMessage());
|
|
1121
|
+
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1122
|
+
.body(createErrorResponse(e.getErrorCode(), e.getMessage()));
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
@ExceptionHandler(MethodArgumentNotValidException.class)
|
|
1126
|
+
public ResponseEntity<ValidationErrorResponse> handleValidationException(MethodArgumentNotValidException e) {
|
|
1127
|
+
log.warn("Validation error: {}", e.getMessage());
|
|
1128
|
+
|
|
1129
|
+
Map<String, String> errors = new HashMap<>();
|
|
1130
|
+
e.getBindingResult().getAllErrors().forEach(error -> {
|
|
1131
|
+
String fieldName = ((FieldError) error).getField();
|
|
1132
|
+
String errorMessage = error.getDefaultMessage();
|
|
1133
|
+
errors.put(fieldName, errorMessage);
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
|
1137
|
+
.body(ValidationErrorResponse.builder()
|
|
1138
|
+
.errorCode("VAL001")
|
|
1139
|
+
.message("入力値が不正です")
|
|
1140
|
+
.timestamp(LocalDateTime.now())
|
|
1141
|
+
.errors(errors)
|
|
1142
|
+
.build());
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
@ExceptionHandler(Exception.class)
|
|
1146
|
+
public ResponseEntity<ErrorResponse> handleGenericException(Exception e) {
|
|
1147
|
+
log.error("Unexpected error", e);
|
|
1148
|
+
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
|
1149
|
+
.body(createErrorResponse("SYS001", "システムエラーが発生しました"));
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
private ErrorResponse createErrorResponse(String errorCode, String message) {
|
|
1153
|
+
return ErrorResponse.builder()
|
|
1154
|
+
.errorCode(errorCode)
|
|
1155
|
+
.message(message)
|
|
1156
|
+
.timestamp(LocalDateTime.now())
|
|
1157
|
+
.build();
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
@Data
|
|
1161
|
+
@Builder
|
|
1162
|
+
public static class ErrorResponse {
|
|
1163
|
+
private String errorCode;
|
|
1164
|
+
private String message;
|
|
1165
|
+
private LocalDateTime timestamp;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
@Data
|
|
1169
|
+
@Builder
|
|
1170
|
+
public static class ValidationErrorResponse {
|
|
1171
|
+
private String errorCode;
|
|
1172
|
+
private String message;
|
|
1173
|
+
private LocalDateTime timestamp;
|
|
1174
|
+
private Map<String, String> errors;
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
</details>
|
|
1180
|
+
|
|
1181
|
+
## 21.6 API ドキュメント
|
|
1182
|
+
|
|
1183
|
+
### 21.6.1 OpenAPI / Swagger の設定
|
|
1184
|
+
|
|
1185
|
+
<details>
|
|
1186
|
+
<summary>OpenAPI 設定</summary>
|
|
1187
|
+
|
|
1188
|
+
```java
|
|
1189
|
+
// src/main/java/com/example/accounting/infrastructure/config/OpenApiConfig.java
|
|
1190
|
+
package com.example.accounting.infrastructure.config;
|
|
1191
|
+
|
|
1192
|
+
import io.swagger.v3.oas.models.OpenAPI;
|
|
1193
|
+
import io.swagger.v3.oas.models.info.Contact;
|
|
1194
|
+
import io.swagger.v3.oas.models.info.Info;
|
|
1195
|
+
import io.swagger.v3.oas.models.info.License;
|
|
1196
|
+
import io.swagger.v3.oas.models.servers.Server;
|
|
1197
|
+
import org.springframework.context.annotation.Bean;
|
|
1198
|
+
import org.springframework.context.annotation.Configuration;
|
|
1199
|
+
|
|
1200
|
+
import java.util.List;
|
|
1201
|
+
|
|
1202
|
+
@Configuration
|
|
1203
|
+
public class OpenApiConfig {
|
|
1204
|
+
|
|
1205
|
+
@Bean
|
|
1206
|
+
public OpenAPI customOpenAPI() {
|
|
1207
|
+
return new OpenAPI()
|
|
1208
|
+
.info(new Info()
|
|
1209
|
+
.title("財務会計システム API")
|
|
1210
|
+
.description("財務会計システムのREST API仕様書")
|
|
1211
|
+
.version("1.0.0")
|
|
1212
|
+
.contact(new Contact()
|
|
1213
|
+
.name("開発チーム")
|
|
1214
|
+
.email("dev@example.com"))
|
|
1215
|
+
.license(new License()
|
|
1216
|
+
.name("MIT License")
|
|
1217
|
+
.url("https://opensource.org/licenses/MIT")))
|
|
1218
|
+
.servers(List.of(
|
|
1219
|
+
new Server().url("http://localhost:8080").description("開発環境"),
|
|
1220
|
+
new Server().url("https://api.example.com").description("本番環境")
|
|
1221
|
+
));
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
</details>
|
|
1227
|
+
|
|
1228
|
+
### 21.6.2 API ドキュメントへのアクセス
|
|
1229
|
+
|
|
1230
|
+
アプリケーション起動後、以下の URL で API 仕様書を確認できます:
|
|
1231
|
+
|
|
1232
|
+
- **Swagger UI**: http://localhost:8080/swagger-ui.html
|
|
1233
|
+
- **OpenAPI JSON**: http://localhost:8080/api-docs
|
|
1234
|
+
|
|
1235
|
+
## 21.7 API インテグレーションテスト
|
|
1236
|
+
|
|
1237
|
+
### 21.7.1 テストコンテナによる統合テスト環境
|
|
1238
|
+
|
|
1239
|
+
Testcontainers を使用して、実際の PostgreSQL データベースを使用した統合テストを実行します。
|
|
1240
|
+
|
|
1241
|
+
<details>
|
|
1242
|
+
<summary>統合テストの設定</summary>
|
|
1243
|
+
|
|
1244
|
+
```java
|
|
1245
|
+
// src/test/java/com/example/accounting/infrastructure/adapter/in/web/AccountControllerIntegrationTest.java
|
|
1246
|
+
package com.example.accounting.infrastructure.adapter.in.web;
|
|
1247
|
+
|
|
1248
|
+
import com.example.accounting.application.port.in.dto.CreateAccountCommand;
|
|
1249
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
1250
|
+
import org.junit.jupiter.api.*;
|
|
1251
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
|
1252
|
+
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
|
1253
|
+
import org.springframework.boot.test.context.SpringBootTest;
|
|
1254
|
+
import org.springframework.http.MediaType;
|
|
1255
|
+
import org.springframework.test.context.DynamicPropertyRegistry;
|
|
1256
|
+
import org.springframework.test.context.DynamicPropertySource;
|
|
1257
|
+
import org.springframework.test.web.servlet.MockMvc;
|
|
1258
|
+
import org.testcontainers.containers.PostgreSQLContainer;
|
|
1259
|
+
import org.testcontainers.junit.jupiter.Container;
|
|
1260
|
+
import org.testcontainers.junit.jupiter.Testcontainers;
|
|
1261
|
+
|
|
1262
|
+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
|
1263
|
+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
|
1264
|
+
|
|
1265
|
+
@SpringBootTest
|
|
1266
|
+
@AutoConfigureMockMvc
|
|
1267
|
+
@Testcontainers
|
|
1268
|
+
@DisplayName("勘定科目 API 統合テスト")
|
|
1269
|
+
class AccountControllerIntegrationTest {
|
|
1270
|
+
|
|
1271
|
+
@Container
|
|
1272
|
+
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16")
|
|
1273
|
+
.withDatabaseName("testdb")
|
|
1274
|
+
.withUsername("testuser")
|
|
1275
|
+
.withPassword("testpass");
|
|
1276
|
+
|
|
1277
|
+
@DynamicPropertySource
|
|
1278
|
+
static void configureProperties(DynamicPropertyRegistry registry) {
|
|
1279
|
+
registry.add("spring.datasource.url", postgres::getJdbcUrl);
|
|
1280
|
+
registry.add("spring.datasource.username", postgres::getUsername);
|
|
1281
|
+
registry.add("spring.datasource.password", postgres::getPassword);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
@Autowired
|
|
1285
|
+
private MockMvc mockMvc;
|
|
1286
|
+
|
|
1287
|
+
@Autowired
|
|
1288
|
+
private ObjectMapper objectMapper;
|
|
1289
|
+
|
|
1290
|
+
@Nested
|
|
1291
|
+
@DisplayName("勘定科目 CRUD")
|
|
1292
|
+
class AccountCrud {
|
|
1293
|
+
|
|
1294
|
+
@Test
|
|
1295
|
+
@DisplayName("勘定科目の登録・取得・更新・削除が正常に動作する")
|
|
1296
|
+
void crudOperationsWork() throws Exception {
|
|
1297
|
+
// Create
|
|
1298
|
+
CreateAccountCommand createCommand = CreateAccountCommand.builder()
|
|
1299
|
+
.accountCode("99999")
|
|
1300
|
+
.accountName("テスト科目")
|
|
1301
|
+
.accountShortName("テスト")
|
|
1302
|
+
.bsPlType("BS")
|
|
1303
|
+
.dcType("借方")
|
|
1304
|
+
.elementType("資産")
|
|
1305
|
+
.summaryType("計上科目")
|
|
1306
|
+
.build();
|
|
1307
|
+
|
|
1308
|
+
mockMvc.perform(post("/api/accounts")
|
|
1309
|
+
.contentType(MediaType.APPLICATION_JSON)
|
|
1310
|
+
.content(objectMapper.writeValueAsString(createCommand)))
|
|
1311
|
+
.andExpect(status().isCreated())
|
|
1312
|
+
.andExpect(jsonPath("$.accountCode").value("99999"))
|
|
1313
|
+
.andExpect(jsonPath("$.accountName").value("テスト科目"));
|
|
1314
|
+
|
|
1315
|
+
// Read
|
|
1316
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1317
|
+
.andExpect(status().isOk())
|
|
1318
|
+
.andExpect(jsonPath("$.accountCode").value("99999"));
|
|
1319
|
+
|
|
1320
|
+
// Delete
|
|
1321
|
+
mockMvc.perform(delete("/api/accounts/{accountCode}", "99999"))
|
|
1322
|
+
.andExpect(status().isNoContent());
|
|
1323
|
+
|
|
1324
|
+
// Verify deleted
|
|
1325
|
+
mockMvc.perform(get("/api/accounts/{accountCode}", "99999"))
|
|
1326
|
+
.andExpect(status().isNotFound());
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
</details>
|
|
1333
|
+
|
|
1334
|
+
### 21.7.2 API エンドポイント一覧
|
|
1335
|
+
|
|
1336
|
+
| メソッド | パス | 説明 |
|
|
1337
|
+
|---------|------|------|
|
|
1338
|
+
| GET | /api/accounts | 勘定科目一覧取得 |
|
|
1339
|
+
| GET | /api/accounts/{accountCode} | 勘定科目取得 |
|
|
1340
|
+
| POST | /api/accounts | 勘定科目登録 |
|
|
1341
|
+
| PUT | /api/accounts/{accountCode} | 勘定科目更新 |
|
|
1342
|
+
| DELETE | /api/accounts/{accountCode} | 勘定科目削除 |
|
|
1343
|
+
| GET | /api/journals | 仕訳一覧取得 |
|
|
1344
|
+
| GET | /api/journals/{journalNumber} | 仕訳取得 |
|
|
1345
|
+
| POST | /api/journals | 仕訳登録 |
|
|
1346
|
+
| POST | /api/journals/{journalNumber}/cancel | 仕訳取消 |
|
|
1347
|
+
| POST | /api/journals/{journalNumber}/correct | 仕訳訂正 |
|
|
1348
|
+
| GET | /api/balances/daily | 日次残高取得 |
|
|
1349
|
+
| GET | /api/balances/monthly | 月次残高取得 |
|
|
1350
|
+
| GET | /api/reports/daily-report | 日計表取得 |
|
|
1351
|
+
| GET | /api/reports/trial-balance | 合計残高試算表取得 |
|
|
1352
|
+
|
|
1353
|
+
## まとめ
|
|
1354
|
+
|
|
1355
|
+
本章では、財務会計システムの API サービスを実装しました。
|
|
1356
|
+
|
|
1357
|
+
### 設計のポイント
|
|
1358
|
+
|
|
1359
|
+
1. **ヘキサゴナルアーキテクチャ**
|
|
1360
|
+
- ドメインロジックの独立性
|
|
1361
|
+
- Ports and Adapters パターンによる責務分離
|
|
1362
|
+
- テスト容易性の確保
|
|
1363
|
+
|
|
1364
|
+
2. **マスタ API の設計**
|
|
1365
|
+
- CRUD 操作の標準化
|
|
1366
|
+
- 階層構造(チルダ連結)への対応
|
|
1367
|
+
- バリデーションとエラーハンドリング
|
|
1368
|
+
|
|
1369
|
+
3. **トランザクション API の設計**
|
|
1370
|
+
- 仕訳の登録・照会・訂正・取消
|
|
1371
|
+
- 貸借バランスチェック
|
|
1372
|
+
- 赤黒処理との連携
|
|
1373
|
+
|
|
1374
|
+
4. **帳票 API の設計**
|
|
1375
|
+
- 日計表・合計残高試算表
|
|
1376
|
+
- 部門別・科目別残高照会
|
|
1377
|
+
|
|
1378
|
+
これで財務会計システムの第3部は完了です。次の第4部では、生産管理システムについて解説します。
|
|
1379
|
+
|
|
1380
|
+
---
|
|
1381
|
+
|
|
1382
|
+
[← 第20章:財務会計データ設計 D社事例](./chapter20.md) | [第22章:生産管理システムの全体像 →](../part4/chapter22.md)
|