├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── micro-app
├── .gitignore
├── README.md
├── build.gradle
├── libs
│ └── .gitkeep
└── src
│ ├── main
│ ├── java
│ │ └── sample
│ │ │ ├── MicroApp.java
│ │ │ ├── MicroAppConfig.java
│ │ │ ├── api
│ │ │ ├── MasterFacadeExporter.java
│ │ │ ├── admin
│ │ │ │ ├── MasterAdminFacadeExporter.java
│ │ │ │ ├── SystemAdminFacadeExporter.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── usecase
│ │ │ ├── AccountService.java
│ │ │ ├── MasterAdminService.java
│ │ │ ├── SystemAdminService.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── application-app.yml
│ │ └── banner.txt
│ └── test
│ ├── java
│ └── sample
│ │ ├── EntityTestSupport.java
│ │ └── support
│ │ └── MockDomainHelper.java
│ └── resources
│ ├── application-test.yml
│ ├── application-testweb.yml
│ └── logback.xml
├── micro-asset
├── .gitignore
├── README.md
├── build.gradle
├── libs
│ └── .gitkeep
└── src
│ ├── main
│ ├── java
│ │ └── sample
│ │ │ └── microasset
│ │ │ ├── MicroAsset.java
│ │ │ ├── MicroAssetConfig.java
│ │ │ ├── MicroAssetDbConfig.java
│ │ │ ├── api
│ │ │ ├── AssetFacade.java
│ │ │ ├── AssetFacadeExporter.java
│ │ │ ├── admin
│ │ │ │ ├── AssetAdminFacade.java
│ │ │ │ ├── AssetAdminFacadeExporter.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── context
│ │ │ └── orm
│ │ │ │ └── AssetRepository.java
│ │ │ ├── model
│ │ │ ├── AssetDataFixtures.java
│ │ │ └── asset
│ │ │ │ ├── Asset.java
│ │ │ │ ├── AssetErrorKeys.java
│ │ │ │ ├── CashBalance.java
│ │ │ │ ├── CashInOut.java
│ │ │ │ ├── Cashflow.java
│ │ │ │ ├── Remarks.java
│ │ │ │ ├── package-info.java
│ │ │ │ └── type
│ │ │ │ ├── CashflowType.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── usecase
│ │ │ ├── AssetAdminService.java
│ │ │ ├── AssetService.java
│ │ │ ├── event
│ │ │ └── AppMailEvent.java
│ │ │ ├── mail
│ │ │ ├── ServiceMailDeliver.java
│ │ │ └── package-info.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── application-asset.yml
│ │ └── banner.txt
│ └── test
│ ├── java
│ └── sample
│ │ ├── EntityTestSupport.java
│ │ ├── microasset
│ │ └── model
│ │ │ └── asset
│ │ │ ├── AssetTest.java
│ │ │ ├── CashBalanceTest.java
│ │ │ ├── CashInOutTest.java
│ │ │ └── CashflowTest.java
│ │ └── support
│ │ └── MockDomainHelper.java
│ └── resources
│ ├── application-test.yml
│ ├── application-testweb.yml
│ └── logback.xml
├── micro-core
├── .gitignore
├── README.md
├── build.gradle
├── libs
│ └── .gitkeep
└── src
│ ├── main
│ ├── java
│ │ └── sample
│ │ │ ├── ActionStatusType.java
│ │ │ ├── ApplicationConfig.java
│ │ │ ├── ApplicationDbConfig.java
│ │ │ ├── ApplicationSecurityConfig.java
│ │ │ ├── InvocationException.java
│ │ │ ├── ValidationException.java
│ │ │ ├── api
│ │ │ ├── ApiClient.java
│ │ │ ├── ApiUtils.java
│ │ │ ├── admin
│ │ │ │ ├── MasterAdminFacade.java
│ │ │ │ ├── SystemAdminFacade.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── context
│ │ │ ├── AppSetting.java
│ │ │ ├── AppSettingHandler.java
│ │ │ ├── DomainHelper.java
│ │ │ ├── Dto.java
│ │ │ ├── Entity.java
│ │ │ ├── Repository.java
│ │ │ ├── ResourceBundleHandler.java
│ │ │ ├── SimpleObjectProvider.java
│ │ │ ├── Timestamper.java
│ │ │ ├── actor
│ │ │ │ ├── Actor.java
│ │ │ │ ├── ActorSession.java
│ │ │ │ └── package-info.java
│ │ │ ├── audit
│ │ │ │ ├── AuditActor.java
│ │ │ │ ├── AuditEvent.java
│ │ │ │ ├── AuditHandler.java
│ │ │ │ └── package-info.java
│ │ │ ├── lock
│ │ │ │ ├── IdLockHandler.java
│ │ │ │ └── package-info.java
│ │ │ ├── mail
│ │ │ │ ├── MailHandler.java
│ │ │ │ └── package-info.java
│ │ │ ├── orm
│ │ │ │ ├── DefaultRepository.java
│ │ │ │ ├── OrmActiveMetaRecord.java
│ │ │ │ ├── OrmActiveRecord.java
│ │ │ │ ├── OrmCriteria.java
│ │ │ │ ├── OrmDataSourceProperties.java
│ │ │ │ ├── OrmInterceptor.java
│ │ │ │ ├── OrmQueryMetadata.java
│ │ │ │ ├── OrmRepository.java
│ │ │ │ ├── OrmTemplate.java
│ │ │ │ ├── OrmUtils.java
│ │ │ │ ├── Pagination.java
│ │ │ │ ├── PagingList.java
│ │ │ │ ├── Sort.java
│ │ │ │ ├── SystemRepository.java
│ │ │ │ ├── TxTemplate.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ ├── report
│ │ │ │ ├── ReportFile.java
│ │ │ │ ├── ReportHandler.java
│ │ │ │ └── package-info.java
│ │ │ ├── rest
│ │ │ │ ├── RestActorSessionBindFilter.java
│ │ │ │ ├── RestActorSessionInterceptor.java
│ │ │ │ ├── RestInvoker.java
│ │ │ │ └── package-info.java
│ │ │ └── security
│ │ │ │ ├── SecurityActorFinder.java
│ │ │ │ ├── SecurityConfigurer.java
│ │ │ │ ├── SecurityProperties.java
│ │ │ │ └── package-info.java
│ │ │ ├── controller
│ │ │ ├── ControllerUtils.java
│ │ │ ├── RestErrorAdvice.java
│ │ │ ├── RestErrorController.java
│ │ │ └── package-info.java
│ │ │ ├── model
│ │ │ ├── BusinessDayHandler.java
│ │ │ ├── DataFixtures.java
│ │ │ ├── DomainErrorKeys.java
│ │ │ ├── account
│ │ │ │ ├── Account.java
│ │ │ │ ├── FiAccount.java
│ │ │ │ ├── Login.java
│ │ │ │ ├── package-info.java
│ │ │ │ └── type
│ │ │ │ │ ├── AccountStatusType.java
│ │ │ │ │ └── package-info.java
│ │ │ ├── constraints
│ │ │ │ ├── AbsAmount.java
│ │ │ │ ├── AbsAmountEmpty.java
│ │ │ │ ├── Amount.java
│ │ │ │ ├── AmountEmpty.java
│ │ │ │ ├── Category.java
│ │ │ │ ├── CategoryEmpty.java
│ │ │ │ ├── Currency.java
│ │ │ │ ├── CurrencyEmpty.java
│ │ │ │ ├── Description.java
│ │ │ │ ├── DescriptionEmpty.java
│ │ │ │ ├── Email.java
│ │ │ │ ├── EmailEmpty.java
│ │ │ │ ├── ISODate.java
│ │ │ │ ├── ISODateEmpty.java
│ │ │ │ ├── ISODateTime.java
│ │ │ │ ├── ISODateTimeEmpty.java
│ │ │ │ ├── IdStr.java
│ │ │ │ ├── IdStrEmpty.java
│ │ │ │ ├── Name.java
│ │ │ │ ├── NameEmpty.java
│ │ │ │ ├── Outline.java
│ │ │ │ ├── OutlineEmpty.java
│ │ │ │ ├── Password.java
│ │ │ │ ├── Year.java
│ │ │ │ ├── YearEmpty.java
│ │ │ │ └── package-info.java
│ │ │ ├── master
│ │ │ │ ├── Holiday.java
│ │ │ │ ├── SelfFiAccount.java
│ │ │ │ ├── Staff.java
│ │ │ │ ├── StaffAuthority.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ ├── usecase
│ │ │ ├── SecurityService.java
│ │ │ ├── ServiceUtils.java
│ │ │ └── package-info.java
│ │ │ └── util
│ │ │ ├── Calculator.java
│ │ │ ├── Checker.java
│ │ │ ├── ConvertUtils.java
│ │ │ ├── DateUtils.java
│ │ │ ├── Regex.java
│ │ │ ├── TimePoint.java
│ │ │ ├── Validator.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── application.yml
│ │ ├── banner.txt
│ │ ├── ehcache.xml
│ │ ├── logback-spring.xml
│ │ ├── messages-validation.properties
│ │ └── messages.properties
│ └── test
│ ├── java
│ └── sample
│ │ ├── DdlExporter.java
│ │ ├── EntityTestSupport.java
│ │ ├── context
│ │ └── ResourceBundleHandlerTest.java
│ │ ├── model
│ │ ├── account
│ │ │ ├── AccountTest.java
│ │ │ ├── FiAccountTest.java
│ │ │ └── LoginTest.java
│ │ └── master
│ │ │ ├── HolidayTest.java
│ │ │ ├── SelfFiAccountTest.java
│ │ │ ├── StaffAuthorityTest.java
│ │ │ └── StaffTest.java
│ │ ├── support
│ │ └── MockDomainHelper.java
│ │ └── util
│ │ ├── CalculatorTest.java
│ │ ├── CheckerTest.java
│ │ ├── ConvertUtilsTest.java
│ │ ├── DateUtilsTest.java
│ │ ├── TimePointTest.java
│ │ └── ValidatorTest.java
│ └── resources
│ ├── application-test.yml
│ └── logback.xml
├── micro-registry
├── .gitignore
├── README.md
├── build.gradle
├── libs
│ └── .gitkeep
└── src
│ ├── main
│ ├── java
│ │ └── sample
│ │ │ ├── MicroRegistry.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── application.yml
│ │ └── banner.txt
│ └── test
│ ├── java
│ └── sample
│ │ └── .gitkeep
│ └── resources
│ └── .gitkeep
├── micro-web
├── .gitignore
├── README.md
├── build.gradle
├── libs
│ └── .gitkeep
└── src
│ ├── main
│ ├── java
│ │ └── sample
│ │ │ ├── MicroWeb.java
│ │ │ ├── MicroWebConfig.java
│ │ │ ├── api
│ │ │ ├── AssetFacadeInvoker.java
│ │ │ ├── admin
│ │ │ │ ├── AssetAdminFacadeInvoker.java
│ │ │ │ ├── MasterAdminFacadeInvoker.java
│ │ │ │ ├── SystemAdminFacadeInvoker.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ │ ├── controller
│ │ │ ├── AccountController.java
│ │ │ ├── AssetController.java
│ │ │ ├── LoginInterceptor.java
│ │ │ ├── admin
│ │ │ │ ├── AssetAdminController.java
│ │ │ │ ├── MasterAdminController.java
│ │ │ │ ├── SystemAdminController.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── system
│ │ │ │ ├── JobController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ └── resources
│ │ ├── application-web.yml
│ │ └── banner.txt
│ └── test
│ ├── java
│ └── sample
│ │ └── client
│ │ └── SampleClient.java
│ └── resources
│ ├── application-testweb.yml
│ └── logback.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .settings
3 | .classpath
4 | .project
5 | /bin
6 | /build
7 | .idea
8 | *.iml
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016-2019 jkazama
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Dfile.encoding=UTF-8
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkazama/sample-boot-micro/0e8fb571af8d0ab32d22cfba33ab2eab48836381/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/micro-app/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .settings
3 | .classpath
4 | .project
5 | /bin
6 | /build
7 | .idea
8 | *.iml
9 |
--------------------------------------------------------------------------------
/micro-app/README.md:
--------------------------------------------------------------------------------
1 | micro-app
2 | ---
3 |
4 | マイクロサービスのドメインAPIプロセスです。
5 |
6 | - `api` パッケージ直下で内部プロセス向けの API を公開しています。
7 | - ドメインパッケージ ( account / asset etc) 単位で別プロセスに切り出し可能です。
8 | - 切り出す場合は `core` プロジェクトにある model / api パッケージの関連ドメイン移動も考えます。
9 | - 上記対応時は `web` プロジェクトから切り出したドメインプロジェクトへ参照を加える必要があります。
10 |
--------------------------------------------------------------------------------
/micro-app/build.gradle:
--------------------------------------------------------------------------------
1 | bootJar {
2 | mainClassName = 'sample.MicroApp'
3 | classifier = 'exec'
4 | }
5 |
6 | dependencies {
7 | implementation project(':micro-core')
8 | }
9 |
--------------------------------------------------------------------------------
/micro-app/libs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkazama/sample-boot-micro/0e8fb571af8d0ab32d22cfba33ab2eab48836381/micro-app/libs/.gitkeep
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/MicroApp.java:
--------------------------------------------------------------------------------
1 | package sample;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cache.annotation.EnableCaching;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.context.annotation.Import;
8 |
9 | import sample.api.MasterFacadeExporter;
10 | import sample.usecase.AccountService;
11 |
12 | /**
13 | * アプリケーションプロセスの起動クラス。
14 | *
本クラスを実行する事でSpringBootが提供する組込Tomcatでのアプリケーション起動が行われます。
15 | *
自動的に Eureka Server へ登録されます。
16 | *
自動設定対象として以下のパッケージをスキャンしています。
17 | *
18 | * - sample.usecase
19 | *
- sample.api
20 | *
21 | */
22 | @SpringBootApplication(scanBasePackageClasses = {
23 | AccountService.class, MasterFacadeExporter.class })
24 | @Import(MicroAppConfig.class)
25 | @EnableCaching(proxyTargetClass = true)
26 | @EnableDiscoveryClient
27 | public class MicroApp {
28 |
29 | public static void main(String[] args) {
30 | new SpringApplicationBuilder(MicroApp.class)
31 | .profiles("app")
32 | .run(args);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/api/MasterFacadeExporter.java:
--------------------------------------------------------------------------------
1 | package sample.api;
2 |
3 | /**
4 | * マスタ系ユースケースの外部公開処理を表現します。
5 | * low: 自動スキャン用に暫定作成
6 | */
7 | public class MasterFacadeExporter {
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/api/admin/MasterAdminFacadeExporter.java:
--------------------------------------------------------------------------------
1 | package sample.api.admin;
2 |
3 | import static sample.api.admin.MasterAdminFacade.Path;
4 |
5 | import java.util.List;
6 |
7 | import javax.validation.Valid;
8 |
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import sample.api.ApiUtils;
13 | import sample.model.master.*;
14 | import sample.model.master.Holiday.RegHoliday;
15 | import sample.usecase.MasterAdminService;
16 |
17 | /**
18 | * マスタ系社内ユースケースの外部公開処理を表現します。
19 | */
20 | @RestController
21 | @RequestMapping(Path)
22 | public class MasterAdminFacadeExporter implements MasterAdminFacade {
23 |
24 | private final MasterAdminService service;
25 |
26 | public MasterAdminFacadeExporter(MasterAdminService service) {
27 | this.service = service;
28 | }
29 |
30 | /** {@inheritDoc} */
31 | @Override
32 | @GetMapping(PathGetStaff)
33 | public Staff getStaff(@PathVariable String staffId) {
34 | return service.getStaff(staffId).orElse(null);
35 | }
36 |
37 | /** {@inheritDoc} */
38 | @Override
39 | @GetMapping(PathFindStaffAuthority)
40 | public List findStaffAuthority(@PathVariable String staffId) {
41 | return service.findStaffAuthority(staffId);
42 | }
43 |
44 | /** {@inheritDoc} */
45 | @Override
46 | @PostMapping(PathRegisterHoliday)
47 | public ResponseEntity registerHoliday(@RequestBody @Valid RegHoliday p) {
48 | return ApiUtils.resultEmpty(() -> service.registerHoliday(p));
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/api/admin/SystemAdminFacadeExporter.java:
--------------------------------------------------------------------------------
1 | package sample.api.admin;
2 |
3 | import static sample.api.admin.SystemAdminFacade.Path;
4 |
5 | import java.util.List;
6 |
7 | import javax.validation.Valid;
8 |
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import sample.api.ApiUtils;
13 | import sample.context.AppSetting;
14 | import sample.context.AppSetting.FindAppSetting;
15 | import sample.context.audit.*;
16 | import sample.context.audit.AuditActor.FindAuditActor;
17 | import sample.context.audit.AuditEvent.FindAuditEvent;
18 | import sample.context.orm.PagingList;
19 | import sample.usecase.SystemAdminService;
20 |
21 | /**
22 | * システム系社内ユースケースの外部公開処理を表現します。
23 | */
24 | @RestController
25 | @RequestMapping(Path)
26 | public class SystemAdminFacadeExporter implements SystemAdminFacade {
27 |
28 | private final SystemAdminService service;
29 |
30 | public SystemAdminFacadeExporter(SystemAdminService service) {
31 | this.service = service;
32 | }
33 |
34 | /** {@inheritDoc} */
35 | @Override
36 | @GetMapping(PathFindAudiActor)
37 | public PagingList findAuditActor(@Valid FindAuditActor p) {
38 | return service.findAuditActor(p);
39 | }
40 |
41 | /** {@inheritDoc} */
42 | @Override
43 | @GetMapping(PathFindAudiEvent)
44 | public PagingList findAuditEvent(@Valid FindAuditEvent p) {
45 | return service.findAuditEvent(p);
46 | }
47 |
48 | /** {@inheritDoc} */
49 | @Override
50 | @GetMapping(PathFindAppSetting)
51 | public List findAppSetting(@Valid FindAppSetting p) {
52 | return service.findAppSetting(p);
53 | }
54 |
55 | /** {@inheritDoc} */
56 | @Override
57 | @PostMapping(PathChangeAppSetting)
58 | public ResponseEntity changeAppSetting(String id, String value) {
59 | return ApiUtils.resultEmpty(() -> service.changeAppSetting(id, value));
60 | }
61 |
62 | /** {@inheritDoc} */
63 | @Override
64 | @PostMapping(PathProcessDay)
65 | public ResponseEntity processDay() {
66 | return ApiUtils.resultEmpty(() -> service.processDay());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/api/admin/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する社内 API コンポーネント。
3 | */
4 | package sample.api.admin;
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/api/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する API コンポーネント。
3 | */
4 | package sample.api;
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * アプリケーションルートディレクトリ。
3 | * Applicationクラスを実行する事でアプリケーションプロセスが立ち上がります。
4 | */
5 | package sample;
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/usecase/AccountService.java:
--------------------------------------------------------------------------------
1 | package sample.usecase;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.beans.factory.annotation.Qualifier;
6 | import org.springframework.cache.annotation.Cacheable;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.PlatformTransactionManager;
9 |
10 | import sample.context.orm.*;
11 | import sample.model.account.*;
12 |
13 | /**
14 | * 口座ドメインに対する顧客ユースケース処理。
15 | */
16 | @Service
17 | public class AccountService {
18 | private final DefaultRepository rep;
19 | private final PlatformTransactionManager txm;
20 |
21 | public AccountService(
22 | DefaultRepository rep,
23 | @Qualifier(DefaultRepository.BeanNameTx) PlatformTransactionManager txm) {
24 | this.rep = rep;
25 | this.txm = txm;
26 | }
27 |
28 | /** ログイン情報を取得します。 */
29 | @Cacheable("AccountService.getLoginByLoginId")
30 | public Optional getLoginByLoginId(String loginId) {
31 | return TxTemplate.of(txm).readOnly().tx(
32 | () -> Login.getByLoginId(rep, loginId));
33 | }
34 |
35 | /** 有効な口座情報を取得します。 */
36 | @Cacheable("AccountService.getAccount")
37 | public Optional getAccount(String id) {
38 | return TxTemplate.of(txm).readOnly().tx(
39 | () -> Account.getValid(rep, id));
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/usecase/MasterAdminService.java:
--------------------------------------------------------------------------------
1 | package sample.usecase;
2 |
3 | import java.util.*;
4 |
5 | import org.springframework.beans.factory.annotation.Qualifier;
6 | import org.springframework.cache.annotation.Cacheable;
7 | import org.springframework.stereotype.Service;
8 | import org.springframework.transaction.PlatformTransactionManager;
9 |
10 | import sample.context.audit.AuditHandler;
11 | import sample.context.orm.*;
12 | import sample.model.master.*;
13 | import sample.model.master.Holiday.RegHoliday;
14 |
15 | /**
16 | * サービスマスタドメインに対する社内ユースケース処理。
17 | */
18 | @Service
19 | public class MasterAdminService {
20 |
21 | private final DefaultRepository rep;
22 | private final PlatformTransactionManager txm;
23 | private final AuditHandler audit;
24 |
25 | public MasterAdminService(
26 | DefaultRepository rep,
27 | @Qualifier(DefaultRepository.BeanNameTx)
28 | PlatformTransactionManager txm,
29 | AuditHandler audit) {
30 | this.rep = rep;
31 | this.txm = txm;
32 | this.audit = audit;
33 | }
34 |
35 |
36 | /** 社員を取得します。 */
37 | @Cacheable("MasterAdminService.getStaff")
38 | public Optional getStaff(String id) {
39 | return TxTemplate.of(txm).readOnly().tx(() -> Staff.get(rep, id));
40 | }
41 |
42 | /** 社員権限を取得します。 */
43 | @Cacheable("MasterAdminService.findStaffAuthority")
44 | public List findStaffAuthority(String staffId) {
45 | return TxTemplate.of(txm).readOnly().tx(() -> StaffAuthority.find(rep, staffId));
46 | }
47 |
48 | public void registerHoliday(final RegHoliday p) {
49 | audit.audit("休日情報を登録する", () -> {
50 | TxTemplate.of(txm).tx(() -> Holiday.register(rep, p));
51 | });
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/usecase/SystemAdminService.java:
--------------------------------------------------------------------------------
1 | package sample.usecase;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.beans.factory.annotation.Qualifier;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.transaction.PlatformTransactionManager;
8 |
9 | import sample.context.AppSetting;
10 | import sample.context.AppSetting.FindAppSetting;
11 | import sample.context.audit.*;
12 | import sample.context.audit.AuditActor.FindAuditActor;
13 | import sample.context.audit.AuditEvent.FindAuditEvent;
14 | import sample.context.orm.*;
15 | import sample.model.BusinessDayHandler;
16 |
17 | /**
18 | * システムドメインに対する社内ユースケース処理。
19 | */
20 | @Service
21 | public class SystemAdminService {
22 |
23 | private final SystemRepository rep;
24 | private final PlatformTransactionManager txm;
25 | private final AuditHandler audit;
26 | private final BusinessDayHandler businessDay;
27 |
28 | public SystemAdminService(
29 | SystemRepository rep,
30 | @Qualifier(SystemRepository.BeanNameTx)
31 | PlatformTransactionManager txm,
32 | AuditHandler audit,
33 | BusinessDayHandler businessDay) {
34 | this.rep = rep;
35 | this.txm = txm;
36 | this.audit = audit;
37 | this.businessDay = businessDay;
38 | }
39 |
40 | /** 利用者監査ログを検索します。 */
41 | public PagingList findAuditActor(FindAuditActor p) {
42 | return TxTemplate.of(txm).readOnly().tx(() -> AuditActor.find(rep, p));
43 | }
44 |
45 | /** イベント監査ログを検索します。 */
46 | public PagingList findAuditEvent(FindAuditEvent p) {
47 | return TxTemplate.of(txm).readOnly().tx(() -> AuditEvent.find(rep, p));
48 | }
49 |
50 | /** アプリケーション設定一覧を検索します。 */
51 | public List findAppSetting(FindAppSetting p) {
52 | return TxTemplate.of(txm).readOnly().tx(() -> AppSetting.find(rep, p));
53 | }
54 |
55 | public void changeAppSetting(String id, String value) {
56 | audit.audit("アプリケーション設定情報を変更する", () -> rep.dh().settingSet(id, value));
57 | }
58 |
59 | public void processDay() {
60 | audit.audit("営業日を進める", () -> rep.dh().time().proceedDay(businessDay.day(1)));
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/micro-app/src/main/java/sample/usecase/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * アプリケーション層のコンポーネント。
3 | * UI層から呼び出され、ドメイン層のコンポーネントを利用してユースケース処理を実現します。
4 | * アプリケーション層のコンポーネントがUI層を呼び出す事やService同士で相互依存することは想定していません。
5 | */
6 | package sample.usecase;
--------------------------------------------------------------------------------
/micro-app/src/main/resources/application-app.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: app
4 | application.name: micro-app
5 |
6 | server:
7 | port: 8090
8 |
9 | extension:
10 | datasource:
11 | default.jpa.hibernate.ddl-auto: create-drop
12 | system.jpa.hibernate.ddl-auto: create-drop
13 | datafixture.enabled: true
14 |
15 | ---
16 | spring:
17 | profiles: production
18 |
19 | extension:
20 | datasource:
21 | default.jpa.hibernate.ddl-auto: none
22 | system.jpa.hibernate.ddl-auto: none
23 | datafixture.enabled: false
24 |
--------------------------------------------------------------------------------
/micro-app/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | ======================================================================================
2 | Start Application [ micro-app ]
3 | --------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
/micro-app/src/test/java/sample/support/MockDomainHelper.java:
--------------------------------------------------------------------------------
1 | package sample.support;
2 |
3 | import java.time.Clock;
4 | import java.util.*;
5 |
6 | import sample.context.*;
7 | import sample.context.actor.ActorSession;
8 |
9 | /** モックテスト用のドメインヘルパー */
10 | public class MockDomainHelper extends DomainHelper {
11 |
12 | private Map settingMap = new HashMap<>();
13 |
14 | public MockDomainHelper() {
15 | this(Clock.systemDefaultZone());
16 | }
17 |
18 | public MockDomainHelper(final Clock mockClock) {
19 | setActorSession(new ActorSession());
20 | setTime(new Timestamper(mockClock));
21 | setSettingHandler(new AppSettingHandler(settingMap));
22 | }
23 |
24 | public MockDomainHelper setting(String id, String value) {
25 | settingMap.put(id, value);
26 | return this;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/micro-app/src/test/resources/application-test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: test
4 |
5 | logging.config: classpath:logback.xml
6 |
7 | eureka.client.enabled: false
8 |
9 | extension:
10 | datasource:
11 | default:
12 | url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
13 | username:
14 | password:
15 | jpa:
16 | show-sql: true
17 | hibernate.ddl-auto: create-drop
18 | system:
19 | url: jdbc:h2:mem:system;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
20 | username:
21 | password:
22 | jpa:
23 | show-sql: true
24 | hibernate.ddl-auto: create-drop
25 | security.auth.enabled: false
26 | datafixture.enabled: true
27 |
--------------------------------------------------------------------------------
/micro-app/src/test/resources/application-testweb.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: testweb
4 |
5 | logging.config: classpath:logback.xml
6 |
7 | eureka.client.enabled: false
8 |
9 | extension:
10 | datasource:
11 | default:
12 | url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
13 | username:
14 | password:
15 | jpa.hibernate.ddl-auto: none
16 | system:
17 | url: jdbc:h2:mem:system;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
18 | username:
19 | password:
20 | jpa.hibernate.ddl-auto: none
21 | security.auth.enabled: false
22 |
--------------------------------------------------------------------------------
/micro-app/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/micro-asset/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .settings
3 | .classpath
4 | .project
5 | /bin
6 | /build
7 | .idea
8 | *.iml
9 |
--------------------------------------------------------------------------------
/micro-asset/README.md:
--------------------------------------------------------------------------------
1 | micro-asset
2 | ---
3 |
4 | マイクロサービスのドメインAPIプロセス ( 資産固有 ) です。
5 |
6 | - `api` パッケージ直下で内部プロセス向けの API を公開しています。
7 | - 資産に特化したサービスを提供します。
8 | - `core` プロジェクトに存在するドメイン情報については参照前提で利用します。変更が必要であれば `app` プロセスのAPIを呼び出して委譲します。
9 | - RemoteInvocation とは異なるため、web側の依存をなくして同 I/F なクラスで代替えする事も可能です。
10 | - 資産スキーマを AssetRepository によって標準スキーマとは別に管理しています。
11 | - マスタ系の標準スキーマへの依存も外したい場合はそこを API 経由にする方向で。(これ以上はキリがないので割愛)
12 |
--------------------------------------------------------------------------------
/micro-asset/build.gradle:
--------------------------------------------------------------------------------
1 | bootJar {
2 | mainClassName = 'sample.microasset.MicroAsset'
3 | classifier = 'exec'
4 | }
5 | jar.enabled=true
6 |
7 | dependencies {
8 | implementation project(':micro-core')
9 | }
10 |
--------------------------------------------------------------------------------
/micro-asset/libs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkazama/sample-boot-micro/0e8fb571af8d0ab32d22cfba33ab2eab48836381/micro-asset/libs/.gitkeep
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/MicroAsset.java:
--------------------------------------------------------------------------------
1 | package sample.microasset;
2 |
3 | import org.springframework.boot.autoconfigure.SpringBootApplication;
4 | import org.springframework.boot.builder.SpringApplicationBuilder;
5 | import org.springframework.cache.annotation.EnableCaching;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.context.annotation.Import;
8 |
9 | import sample.microasset.api.AssetFacadeExporter;
10 | import sample.microasset.usecase.AssetService;
11 |
12 | /**
13 | * 資産アプリケーションプロセスの起動クラス。
14 | * 本クラスを実行する事でSpringBootが提供する組込Tomcatでのアプリケーション起動が行われます。
15 | *
自動的に Eureka Server へ登録されます。
16 | *
自動設定対象として以下のパッケージをスキャンしています。
17 | *
18 | * - sample.microasset.usecase
19 | *
- sample.microasset.api
20 | *
21 | */
22 | @SpringBootApplication(scanBasePackageClasses = { AssetService.class, AssetFacadeExporter.class })
23 | @Import(MicroAssetConfig.class)
24 | @EnableCaching(proxyTargetClass = true)
25 | @EnableDiscoveryClient
26 | public class MicroAsset {
27 |
28 | public static void main(String[] args) {
29 | new SpringApplicationBuilder(MicroAsset.class)
30 | .profiles("asset")
31 | .run(args);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/MicroAssetDbConfig.java:
--------------------------------------------------------------------------------
1 | package sample.microasset;
2 |
3 | import static sample.microasset.context.orm.AssetRepository.*;
4 |
5 | import javax.persistence.EntityManagerFactory;
6 | import javax.sql.DataSource;
7 |
8 | import org.springframework.beans.factory.annotation.Qualifier;
9 | import org.springframework.boot.context.properties.EnableConfigurationProperties;
10 | import org.springframework.context.annotation.*;
11 | import org.springframework.orm.jpa.*;
12 |
13 | import sample.microasset.context.orm.AssetRepository;
14 | import sample.microasset.context.orm.AssetRepository.AssetDataSourceProperties;
15 |
16 | /**
17 | * 資産ドメインのデータベース接続定義を表現します。
18 | */
19 | @Configuration
20 | @EnableConfigurationProperties({AssetDataSourceProperties.class})
21 | public class MicroAssetDbConfig {
22 |
23 | @Bean
24 | @DependsOn(BeanNameEmf)
25 | AssetRepository assetRepository() {
26 | return new AssetRepository();
27 | }
28 |
29 | @Bean(name = BeanNameDs, destroyMethod = "close")
30 | DataSource assetDataSource(AssetDataSourceProperties props) {
31 | return props.dataSource();
32 | }
33 |
34 | @Bean(name = BeanNameEmf)
35 | LocalContainerEntityManagerFactoryBean assetEntityManagerFactoryBean(
36 | AssetDataSourceProperties props,
37 | @Qualifier(AssetRepository.BeanNameDs) final DataSource dataSource) {
38 | return props.entityManagerFactoryBean(dataSource);
39 | }
40 |
41 | @Bean(name = BeanNameTx)
42 | JpaTransactionManager assetTransactionManager(
43 | AssetDataSourceProperties props,
44 | @Qualifier(AssetRepository.BeanNameEmf) final EntityManagerFactory emf) {
45 | return props.transactionManager(emf);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/AssetFacade.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.api;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.http.ResponseEntity;
6 |
7 | import sample.microasset.model.asset.CashInOut;
8 | import sample.microasset.model.asset.CashInOut.RegCashOut;
9 |
10 | /**
11 | * 資産関連のユースケース API を表現します。
12 | */
13 | public interface AssetFacade {
14 |
15 | String Path = "/api/asset";
16 |
17 | String PathFindUnprocessedCashOut = "/cio/unprocessedOut/";
18 | String PathWithdraw = "/cio/withdraw";
19 |
20 | /**
21 | * 未処理の振込依頼情報を検索します。
22 | * low: CashInOutは情報過多ですがアプリケーション層では公開対象を特定しにくい事もあり、
23 | * UI層に最終判断を委ねています。
24 | */
25 | List findUnprocessedCashOut();
26 |
27 | /**
28 | * 振込出金依頼をします。
29 | * low: 公開リスクがあるためUI層には必要以上の情報を返さない事を意識します。
30 | * @return 振込出金依頼ID
31 | */
32 | ResponseEntity withdraw(RegCashOut p);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/AssetFacadeExporter.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.api;
2 |
3 | import static sample.microasset.api.AssetFacade.Path;
4 |
5 | import java.util.List;
6 |
7 | import javax.validation.Valid;
8 |
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import sample.api.ApiUtils;
13 | import sample.microasset.model.asset.CashInOut;
14 | import sample.microasset.model.asset.CashInOut.RegCashOut;
15 | import sample.microasset.usecase.AssetService;
16 |
17 | /**
18 | * 資産系ユースケースの外部公開処理を表現します。
19 | */
20 | @RestController
21 | @RequestMapping(Path)
22 | public class AssetFacadeExporter implements AssetFacade {
23 |
24 | private final AssetService service;
25 |
26 | public AssetFacadeExporter(AssetService service) {
27 | this.service = service;
28 | }
29 |
30 | /** {@inheritDoc} */
31 | @Override
32 | @GetMapping(PathFindUnprocessedCashOut)
33 | public List findUnprocessedCashOut() {
34 | return service.findUnprocessedCashOut();
35 | }
36 |
37 | /** {@inheritDoc} */
38 | @Override
39 | @PostMapping(PathWithdraw)
40 | public ResponseEntity withdraw(@RequestBody @Valid RegCashOut p) {
41 | return ApiUtils.result(() -> service.withdraw(p));
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/admin/AssetAdminFacade.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.api.admin;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.http.ResponseEntity;
6 |
7 | import sample.microasset.model.asset.CashInOut;
8 | import sample.microasset.model.asset.CashInOut.FindCashInOut;
9 |
10 | /**
11 | * 資産ドメインに対する社内ユースケース API を表現します。
12 | */
13 | public interface AssetAdminFacade {
14 |
15 | String Path = "/api/admin/asset";
16 |
17 | String PathFindCashInOut = "/cio/";
18 | String PathClosingCashOut = "/cio/closingCashOut";
19 | String PathRealizeCashflow = "/cf/realizeCashflow";
20 |
21 | /** 未処理の振込依頼情報を検索します。 */
22 | List findCashInOut(FindCashInOut p);
23 |
24 | /**
25 | * 振込出金依頼を締めます。
26 | */
27 | ResponseEntity closingCashOut();
28 |
29 | /**
30 | * キャッシュフローを実現します。
31 | * 受渡日を迎えたキャッシュフローを残高に反映します。
32 | */
33 | ResponseEntity realizeCashflow();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/admin/AssetAdminFacadeExporter.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.api.admin;
2 |
3 | import static sample.microasset.api.admin.AssetAdminFacade.Path;
4 |
5 | import java.util.List;
6 |
7 | import javax.validation.Valid;
8 |
9 | import org.springframework.http.ResponseEntity;
10 | import org.springframework.web.bind.annotation.*;
11 |
12 | import sample.api.ApiUtils;
13 | import sample.microasset.model.asset.CashInOut;
14 | import sample.microasset.model.asset.CashInOut.FindCashInOut;
15 | import sample.microasset.usecase.AssetAdminService;
16 |
17 | /**
18 | * 資産系社内ユースケースの外部公開処理を表現します。
19 | */
20 | @RestController
21 | @RequestMapping(Path)
22 | public class AssetAdminFacadeExporter implements AssetAdminFacade {
23 |
24 | private final AssetAdminService service;
25 |
26 | public AssetAdminFacadeExporter(AssetAdminService service) {
27 | this.service = service;
28 | }
29 |
30 | /** {@inheritDoc} */
31 | @Override
32 | @GetMapping(PathFindCashInOut)
33 | public List findCashInOut(@Valid FindCashInOut p) {
34 | return service.findCashInOut(p);
35 | }
36 |
37 | /** {@inheritDoc} */
38 | @Override
39 | @PostMapping(PathClosingCashOut)
40 | public ResponseEntity closingCashOut() {
41 | return ApiUtils.resultEmpty(() -> service.closingCashOut());
42 | }
43 |
44 | /** {@inheritDoc} */
45 | @Override
46 | @PostMapping(PathRealizeCashflow)
47 | public ResponseEntity realizeCashflow() {
48 | return ApiUtils.resultEmpty(() -> service.realizeCashflow());
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/admin/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する社内 API コンポーネント。
3 | */
4 | package sample.microasset.api.admin;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/api/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する API コンポーネント。
3 | */
4 | package sample.microasset.api;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/context/orm/AssetRepository.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.context.orm;
2 |
3 | import javax.persistence.*;
4 | import javax.sql.DataSource;
5 |
6 | import org.springframework.boot.context.properties.ConfigurationProperties;
7 | import org.springframework.orm.jpa.*;
8 |
9 | import lombok.*;
10 | import sample.context.orm.*;
11 |
12 | /** 資産スキーマのRepositoryを表現します。 */
13 | @Setter
14 | public class AssetRepository extends OrmRepository {
15 | public static final String BeanNameDs = "assetDataSource";
16 | public static final String BeanNameEmf = "assetEntityManagerFactory";
17 | public static final String BeanNameTx = "assetTransactionManager";
18 |
19 | @PersistenceContext(unitName = BeanNameEmf)
20 | private EntityManager em;
21 |
22 | @Override
23 | public EntityManager em() {
24 | return em;
25 | }
26 |
27 | /** 資産スキーマのHibernateコンポーネントを生成します。 */
28 | @ConfigurationProperties(prefix = "extension.datasource.asset")
29 | @Data
30 | @EqualsAndHashCode(callSuper = false)
31 | public static class AssetDataSourceProperties extends OrmDataSourceProperties {
32 | private OrmRepositoryProperties jpa = new OrmRepositoryProperties();
33 |
34 | public DataSource dataSource() {
35 | return super.dataSource();
36 | }
37 |
38 | public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean(
39 | final DataSource dataSource) {
40 | return jpa.entityManagerFactoryBean(BeanNameEmf, dataSource);
41 | }
42 |
43 | public JpaTransactionManager transactionManager(final EntityManagerFactory emf) {
44 | return jpa.transactionManager(emf);
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/Asset.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset;
2 |
3 | import java.math.BigDecimal;
4 | import java.time.LocalDate;
5 |
6 | import lombok.Getter;
7 | import sample.context.orm.OrmRepository;
8 | import sample.util.Calculator;
9 |
10 | /**
11 | * 口座の資産概念を表現します。
12 | * asset配下のEntityを横断的に取り扱います。
13 | * low: 実際の開発では多通貨や執行中/拘束中のキャッシュフローアクションに対する考慮で、サービスによってはかなり複雑になります。
14 | */
15 | @Getter
16 | public class Asset {
17 | /** 口座ID */
18 | private final String id;
19 |
20 | private Asset(String id) {
21 | this.id = id;
22 | }
23 |
24 | /** 口座IDに紐付く資産概念を返します。 */
25 | public static Asset by(String accountId) {
26 | return new Asset(accountId);
27 | }
28 |
29 | /**
30 | * 振込出金可能か判定します。
31 | * 0 <= 口座残高 + 未実現キャッシュフロー - (出金依頼拘束額 + 出金依頼額)
32 | * low: 判定のみなのでscale指定は省略。余力金額を返す時はきちんと指定する
33 | */
34 | public boolean canWithdraw(final OrmRepository rep, String currency, BigDecimal absAmount, LocalDate valueDay) {
35 | Calculator calc = Calculator.of(CashBalance.getOrNew(rep, id, currency).getAmount());
36 | Cashflow.findUnrealize(rep, id, currency, valueDay).stream().forEach((cf) -> calc.add(cf.getAmount()));
37 | CashInOut.findUnprocessed(rep, id, currency, true).stream()
38 | .forEach((withdrawal) -> calc.add(withdrawal.getAbsAmount().negate()));
39 | calc.add(absAmount.negate());
40 | return 0 <= calc.decimal().signum();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/AssetErrorKeys.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset;
2 |
3 | /**
4 | * 資産の審査例外で用いるメッセージキー定数。
5 | */
6 | public interface AssetErrorKeys {
7 |
8 | /** 受渡日を迎えていないため実現できません */
9 | String CashflowRealizeDay = "error.Cashflow.realizeDay";
10 | /** 既に受渡日を迎えています */
11 | String CashflowBeforeEqualsDay = "error.Cashflow.beforeEqualsDay";
12 |
13 | /** 未到来の受渡日です */
14 | String CashInOutAfterEqualsDay = "error.CashInOut.afterEqualsDay";
15 | /** 既に発生日を迎えています */
16 | String CashInOutBeforeEqualsDay = "error.CashInOut.beforeEqualsDay";
17 | /** 出金可能額を超えています */
18 | String CashInOutWithdrawAmount = "error.CashInOut.withdrawAmount";
19 | }
20 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/Remarks.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset;
2 |
3 | /**
4 | * 摘要定数インターフェース。
5 | */
6 | public interface Remarks {
7 |
8 | /** 振込入金 */
9 | String CashIn = "cashIn";
10 | /** 振込入金(調整) */
11 | String CashInAdjust = "cashInAdjust";
12 | /** 振込入金(取消) */
13 | String CashInCancel = "cashInCancel";
14 | /** 振込出金 */
15 | String CashOut = "cashOut";
16 | /** 振込出金(調整) */
17 | String CashOutAdjust = "cashOutAdjust";
18 | /** 振込出金(取消) */
19 | String CashOutCancel = "cashOutCancel";
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 資産に関連したドメイン概念。
3 | */
4 | package sample.microasset.model.asset;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/type/CashflowType.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset.type;
2 |
3 | /** キャッシュフロー種別。 low: 各社固有です。摘要含めラベルはなるべくmessages.propertiesへ切り出し */
4 | public enum CashflowType {
5 | /** 振込入金 */
6 | CashIn,
7 | /** 振込出金 */
8 | CashOut,
9 | /** 振替入金 */
10 | CashTransferIn,
11 | /** 振替出金 */
12 | CashTransferOut
13 | }
14 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/model/asset/type/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 資産に関連したドメイン列挙型。
3 | */
4 | package sample.microasset.model.asset.type;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * アプリケーションルートディレクトリ。
3 | *
Applicationクラスを実行する事でアプリケーションプロセスが立ち上がります。
4 | */
5 | package sample.microasset;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/usecase/event/AppMailEvent.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.usecase.event;
2 |
3 | import lombok.*;
4 | import sample.context.Dto;
5 |
6 | /**
7 | * メール配信イベントを表現します。
8 | */
9 | @Data
10 | @NoArgsConstructor
11 | @AllArgsConstructor
12 | public class AppMailEvent implements Dto {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private AppMailType mailType;
16 | private T value;
17 |
18 | public static AppMailEvent of(AppMailType mailType, T value) {
19 | return new AppMailEvent(mailType, value);
20 | }
21 |
22 | /** メール配信種別を表現します。 */
23 | public static enum AppMailType {
24 | /** 振込出金依頼の登録受付完了 */
25 | FinishRequestWithdraw;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/usecase/mail/ServiceMailDeliver.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.usecase.mail;
2 |
3 | import org.springframework.context.event.EventListener;
4 | import org.springframework.stereotype.Component;
5 |
6 | import lombok.extern.slf4j.Slf4j;
7 | import sample.context.mail.MailHandler;
8 | import sample.microasset.model.asset.CashInOut;
9 | import sample.microasset.usecase.event.AppMailEvent;
10 |
11 | /**
12 | * アプリケーション層のサービスメール送信を行います。
13 | * AppMailEvent に応じたメール配信をおこないます。
14 | */
15 | @Component
16 | @Slf4j
17 | public class ServiceMailDeliver {
18 | @SuppressWarnings("unused")
19 | private final MailHandler mail;
20 |
21 | public ServiceMailDeliver(MailHandler mail) {
22 | this.mail = mail;
23 | }
24 |
25 | /** メール配信要求を受け付けます。 */
26 | @EventListener(AppMailEvent.class)
27 | public void handleEvent(AppMailEvent> event) {
28 | switch (event.getMailType()) {
29 | case FinishRequestWithdraw:
30 | sendFinishRequestWithdraw((CashInOut)event.getValue());
31 | break;
32 | default:
33 | throw new IllegalStateException("サポートされないメール種別です。 [" + event + "]");
34 | }
35 | }
36 |
37 | private void sendFinishRequestWithdraw(CashInOut cio) {
38 | //low: この例ではログのみ出力
39 | log.info("メール送信が行われました。 [" + cio + "]");
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/usecase/mail/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * アプリケーション層のメールコンポーネント。
3 | *
出金依頼完了メール等、各ユースケースに紐付くメール送受信処理を管理します。
4 | */
5 | package sample.microasset.usecase.mail;
--------------------------------------------------------------------------------
/micro-asset/src/main/java/sample/microasset/usecase/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * アプリケーション層のコンポーネント。
3 | *
UI層から呼び出され、ドメイン層のコンポーネントを利用してユースケース処理を実現します。
4 | * アプリケーション層のコンポーネントがUI層を呼び出す事やService同士で相互依存することは想定していません。
5 | */
6 | package sample.microasset.usecase;
--------------------------------------------------------------------------------
/micro-asset/src/main/resources/application-asset.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: asset
4 | application.name: micro-asset
5 |
6 | server:
7 | port: 8100
8 |
9 | extension:
10 | datasource:
11 | asset:
12 | url: ${DB_ASSET_JDBC_URL:jdbc:h2:tcp://localhost:9092/mem:asset}
13 | username: ${DB_ASSET_JDBC_USERNAME:}
14 | password: ${DB_ASSET_JDBC_USERNAME:}
15 | jpa:
16 | package-to-scan: sample.microasset.model.asset
17 | hibernate.ddl-auto: create-drop
18 | datafixture.enabled: true
19 |
20 |
21 | ---
22 | spring:
23 | profiles: production
24 |
25 | extension:
26 | datasource:
27 | asset.jpa.hibernate.ddl-auto: none
28 | datafixture.enabled: false
29 |
--------------------------------------------------------------------------------
/micro-asset/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | ======================================================================================
2 | Start Application [ micro-asset ]
3 | --------------------------------------------------------------------------------------
--------------------------------------------------------------------------------
/micro-asset/src/test/java/sample/microasset/model/asset/AssetTest.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset;
2 |
3 | import static org.hamcrest.Matchers.is;
4 | import static org.junit.Assert.assertThat;
5 |
6 | import java.math.BigDecimal;
7 | import java.time.LocalDate;
8 |
9 | import org.junit.Test;
10 |
11 | import sample.EntityTestSupport;
12 | import sample.model.account.Account;
13 |
14 | //low: 簡易な検証が中心
15 | public class AssetTest extends EntityTestSupport {
16 |
17 | @Override
18 | protected void setupPreset() {
19 | targetEntities(Account.class, CashBalance.class, Cashflow.class, CashInOut.class);
20 | }
21 |
22 | @Test
23 | public void 振込出金可能か判定する() {
24 | // 残高 + 未実現キャッシュフロー - 出金依頼拘束額 = 出金可能額
25 | // 10000 + (1000 - 2000) - 8000 = 1000
26 | tx(() -> {
27 | fixtures.acc("test").save(rep);
28 | fixturesAsset.cb("test", LocalDate.of(2014, 11, 18), "JPY", "10000").save(rep);
29 | fixturesAsset.cf("test", "1000", LocalDate.of(2014, 11, 18), LocalDate.of(2014, 11, 20)).save(rep);
30 | fixturesAsset.cf("test", "-2000", LocalDate.of(2014, 11, 19), LocalDate.of(2014, 11, 21)).save(rep);
31 | fixturesAsset.cio("test", "8000", true).save(rep);
32 |
33 | assertThat(
34 | Asset.by("test").canWithdraw(rep, "JPY", new BigDecimal("1000"), LocalDate.of(2014, 11, 21)),
35 | is(true));
36 | assertThat(
37 | Asset.by("test").canWithdraw(rep, "JPY", new BigDecimal("1001"), LocalDate.of(2014, 11, 21)),
38 | is(false));
39 | });
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/micro-asset/src/test/java/sample/microasset/model/asset/CashBalanceTest.java:
--------------------------------------------------------------------------------
1 | package sample.microasset.model.asset;
2 |
3 | import static org.hamcrest.Matchers.*;
4 | import static org.junit.Assert.assertThat;
5 |
6 | import java.math.BigDecimal;
7 | import java.time.LocalDate;
8 |
9 | import org.junit.Test;
10 |
11 | import sample.EntityTestSupport;
12 | import sample.microasset.model.asset.CashBalance;
13 |
14 | //low: 簡易な正常系検証のみ
15 | public class CashBalanceTest extends EntityTestSupport {
16 |
17 | @Override
18 | protected void setupPreset() {
19 | targetEntities(CashBalance.class);
20 | }
21 |
22 | @Test
23 | public void 現金残高を追加する() {
24 | LocalDate baseDay = businessDay.day();
25 | tx(() -> {
26 | CashBalance cb = fixturesAsset.cb("test1", baseDay, "USD", "10.02").save(rep);
27 |
28 | // 10.02 + 11.51 = 21.53
29 | assertThat(cb.add(rep, new BigDecimal("11.51")).getAmount(), is(new BigDecimal("21.53")));
30 |
31 | // 21.53 + 11.516 = 33.04 (端数切捨確認)
32 | assertThat(cb.add(rep, new BigDecimal("11.516")).getAmount(), is(new BigDecimal("33.04")));
33 |
34 | // 33.04 - 41.51 = -8.47 (マイナス値/マイナス残許容)
35 | assertThat(cb.add(rep, new BigDecimal("-41.51")).getAmount(), is(new BigDecimal("-8.47")));
36 | });
37 | }
38 |
39 | @Test
40 | public void 現金残高を取得する() {
41 | LocalDate baseDay = businessDay.day();
42 | LocalDate baseMinus1Day = businessDay.day(-1);
43 | tx(() -> {
44 | fixturesAsset.cb("test1", baseDay, "JPY", "1000").save(rep);
45 | fixturesAsset.cb("test2", baseMinus1Day, "JPY", "3000").save(rep);
46 |
47 | // 存在している残高の検証
48 | CashBalance cbNormal = CashBalance.getOrNew(rep, "test1", "JPY");
49 | assertThat(cbNormal, allOf(
50 | hasProperty("accountId", is("test1")),
51 | hasProperty("baseDay", is(baseDay)),
52 | hasProperty("amount", is(new BigDecimal("1000")))));
53 |
54 | // 基準日に存在していない残高の繰越検証
55 | CashBalance cbRoll = CashBalance.getOrNew(rep, "test2", "JPY");
56 | assertThat(cbRoll, allOf(
57 | hasProperty("accountId", is("test2")),
58 | hasProperty("baseDay", is(baseDay)),
59 | hasProperty("amount", is(new BigDecimal("3000")))));
60 |
61 | // 残高を保有しない口座の生成検証
62 | CashBalance cbNew = CashBalance.getOrNew(rep, "test3", "JPY");
63 | assertThat(cbNew, allOf(
64 | hasProperty("accountId", is("test3")),
65 | hasProperty("baseDay", is(baseDay)),
66 | hasProperty("amount", is(BigDecimal.ZERO))));
67 | });
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/micro-asset/src/test/java/sample/support/MockDomainHelper.java:
--------------------------------------------------------------------------------
1 | package sample.support;
2 |
3 | import java.time.Clock;
4 | import java.util.*;
5 |
6 | import sample.context.*;
7 | import sample.context.actor.ActorSession;
8 |
9 | /** モックテスト用のドメインヘルパー */
10 | public class MockDomainHelper extends DomainHelper {
11 |
12 | private Map settingMap = new HashMap<>();
13 |
14 | public MockDomainHelper() {
15 | this(Clock.systemDefaultZone());
16 | }
17 |
18 | public MockDomainHelper(final Clock mockClock) {
19 | setActorSession(new ActorSession());
20 | setTime(new Timestamper(mockClock));
21 | setSettingHandler(new AppSettingHandler(settingMap));
22 | }
23 |
24 | public MockDomainHelper setting(String id, String value) {
25 | settingMap.put(id, value);
26 | return this;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/micro-asset/src/test/resources/application-test.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: test
4 |
5 | logging.config: classpath:logback.xml
6 |
7 | eureka.client.enabled: false
8 |
9 | extension:
10 | datasource:
11 | default:
12 | url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
13 | username:
14 | password:
15 | jpa:
16 | show-sql: true
17 | hibernate.ddl-auto: create-drop
18 | system:
19 | url: jdbc:h2:mem:system;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
20 | username:
21 | password:
22 | jpa:
23 | show-sql: true
24 | hibernate.ddl-auto: create-drop
25 | asset:
26 | url: jdbc:h2:mem:asset;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
27 | username:
28 | password:
29 | jpa:
30 | show-sql: true
31 | package-to-scan: sample.microasset.model.asset
32 | hibernate.ddl-auto: create-drop
33 | security.auth.enabled: false
34 | datafixture.enabled: false
35 |
--------------------------------------------------------------------------------
/micro-asset/src/test/resources/application-testweb.yml:
--------------------------------------------------------------------------------
1 | ---
2 | spring:
3 | profiles: testweb
4 |
5 | logging.config: classpath:logback.xml
6 |
7 | eureka.client.enabled: false
8 |
9 | extension:
10 | datasource:
11 | default:
12 | url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
13 | username:
14 | password:
15 | jpa.hibernate.ddl-auto: none
16 | system:
17 | url: jdbc:h2:mem:system;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
18 | username:
19 | password:
20 | jpa.hibernate.ddl-auto: none
21 | asset:
22 | url: jdbc:h2:mem:asset;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
23 | username:
24 | password:
25 | jpa:
26 | package-to-scan: sample.microasset.model.asset
27 | hibernate.ddl-auto: none
28 | security.auth.enabled: false
29 |
--------------------------------------------------------------------------------
/micro-asset/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/micro-core/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | .settings
3 | .classpath
4 | .project
5 | /bin
6 | /build
7 | .idea
8 | *.iml
9 |
--------------------------------------------------------------------------------
/micro-core/README.md:
--------------------------------------------------------------------------------
1 | micro-core
2 | ---
3 |
4 | 各プロセス ( micro-registry を除く ) 間で共有されるクラスをライブラリとして管理します。
5 |
6 | - `Executable Jar` でなく、単純なライブラリとしての `jar` を生成します。
7 |
--------------------------------------------------------------------------------
/micro-core/build.gradle:
--------------------------------------------------------------------------------
1 | bootJar.enabled=false
2 | jar.enabled=true
3 |
--------------------------------------------------------------------------------
/micro-core/libs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jkazama/sample-boot-micro/0e8fb571af8d0ab32d22cfba33ab2eab48836381/micro-core/libs/.gitkeep
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/ActionStatusType.java:
--------------------------------------------------------------------------------
1 | package sample;
2 |
3 | import java.util.*;
4 |
5 | /**
6 | * 何らかの行為に関わる処理ステータス概念。
7 | */
8 | public enum ActionStatusType {
9 | /** 未処理 */
10 | Unprocessed,
11 | /** 処理中 */
12 | Processing,
13 | /** 処理済 */
14 | Processed,
15 | /** 取消 */
16 | Cancelled,
17 | /** エラー */
18 | Error;
19 |
20 | /** 完了済みのステータス一覧 */
21 | public static final List finishTypes = Collections.unmodifiableList(
22 | Arrays.asList(Processed, Cancelled));
23 |
24 | /** 未完了のステータス一覧(処理中は含めない) */
25 | public static final List unprocessingTypes = Collections.unmodifiableList(
26 | Arrays.asList(Unprocessed, Error));
27 |
28 | /** 未完了のステータス一覧(処理中も含める) */
29 | public static final List unprocessedTypes = Collections.unmodifiableList(
30 | Arrays.asList(Unprocessed, Processing, Error));
31 |
32 | /** 完了済みのステータスの時はtrue */
33 | public boolean isFinish() {
34 | return finishTypes.contains(this);
35 | }
36 |
37 | /** 未完了のステータス(処理中は含めない)の時はtrue */
38 | public boolean isUnprocessing() {
39 | return unprocessingTypes.contains(this);
40 | }
41 |
42 | /** 未完了のステータス(処理中も含める)の時はtrue */
43 | public boolean isUnprocessed() {
44 | return unprocessedTypes.contains(this);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/InvocationException.java:
--------------------------------------------------------------------------------
1 | package sample;
2 |
3 | /**
4 | * 処理時の実行例外を表現します。
5 | * 復旧不可能なシステム例外をラップする目的で利用してください。
6 | */
7 | public class InvocationException extends RuntimeException {
8 |
9 | private static final long serialVersionUID = 1L;
10 |
11 | public InvocationException(String message, Throwable cause) {
12 | super(message, cause);
13 | }
14 |
15 | public InvocationException(String message) {
16 | super(message);
17 | }
18 |
19 | public InvocationException(Throwable cause) {
20 | super(cause);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/ApiClient.java:
--------------------------------------------------------------------------------
1 | package sample.api;
2 |
3 | import java.util.Optional;
4 |
5 | import org.springframework.web.client.RestTemplate;
6 |
7 | import com.fasterxml.jackson.databind.ObjectMapper;
8 |
9 | import sample.context.rest.RestInvoker;
10 |
11 | /**
12 | * Spring Cloud 標準の API クライアント要求アプローチをサポートします。
13 | *
API クライアント側の Facade で本コンポーネントから RestInvoker を取得して実行してください。
14 | */
15 | public class ApiClient {
16 |
17 | private final RestTemplate template;
18 | private final ObjectMapper mapper;
19 |
20 | public ApiClient(RestTemplate template, ObjectMapper mapper) {
21 | this.template = template;
22 | this.mapper = mapper;
23 | }
24 |
25 | /** RestInvoker を返します。 */
26 | public RestInvoker invoker(String url, String rootPath) {
27 | return new RestInvoker(this.template, this.mapper, rootUrl(url, rootPath));
28 | }
29 |
30 | /** API 接続先ルートとなる URL を返します。 */
31 | private String rootUrl(String url, String rootPath) {
32 | return url + Optional.ofNullable(rootPath).orElse("");
33 | }
34 |
35 | public static ApiClient of(RestTemplate template, ObjectMapper mapper) {
36 | return new ApiClient(template, mapper);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/ApiUtils.java:
--------------------------------------------------------------------------------
1 | package sample.api;
2 |
3 | import java.util.function.Supplier;
4 |
5 | import org.springframework.http.*;
6 |
7 | /** APIで利用されるユーティリティを表現します。 */
8 | public abstract class ApiUtils {
9 |
10 | /** 戻り値を生成して返します。(戻り値がプリミティブまたはnullを許容する時はこちらを利用してください) */
11 | public static ResponseEntity result(Supplier command) {
12 | return ResponseEntity.status(HttpStatus.OK).body(command.get());
13 | }
14 |
15 | /** 空の戻り値を生成して返します。 */
16 | public static ResponseEntity resultEmpty(Runnable command) {
17 | command.run();
18 | return ResponseEntity.status(HttpStatus.OK).build();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/admin/MasterAdminFacade.java:
--------------------------------------------------------------------------------
1 | package sample.api.admin;
2 |
3 | import java.util.*;
4 |
5 | import org.springframework.http.ResponseEntity;
6 |
7 | import sample.model.master.*;
8 | import sample.model.master.Holiday.RegHoliday;
9 |
10 | /**
11 | * マスタドメインに対する社内ユースケース API を表現します。
12 | */
13 | public interface MasterAdminFacade {
14 |
15 | String Path = "/api/admin/master";
16 |
17 | String PathGetStaff = "/staff/{staffId}/";
18 | String PathFindStaffAuthority = "/staff/{staffId}/authority";
19 | String PathRegisterHoliday = "/holiday";
20 |
21 | /** 社員を取得します。 */
22 | Staff getStaff(String staffId);
23 |
24 | /** 社員権限を取得します。 */
25 | List findStaffAuthority(String staffId);
26 |
27 | /** 休日を登録します。 */
28 | ResponseEntity registerHoliday(final RegHoliday p);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/admin/SystemAdminFacade.java:
--------------------------------------------------------------------------------
1 | package sample.api.admin;
2 |
3 | import java.util.List;
4 |
5 | import org.springframework.http.ResponseEntity;
6 |
7 | import sample.context.AppSetting;
8 | import sample.context.AppSetting.FindAppSetting;
9 | import sample.context.audit.*;
10 | import sample.context.audit.AuditActor.FindAuditActor;
11 | import sample.context.audit.AuditEvent.FindAuditEvent;
12 | import sample.context.orm.PagingList;
13 |
14 | /**
15 | * システムドメインに対する社内ユースケース API を表現します。
16 | */
17 | public interface SystemAdminFacade {
18 |
19 | String Path = "/api/admin/system";
20 |
21 | String PathFindAudiActor = "/audit/actor/";
22 | String PathFindAudiEvent = "/audit/event/";
23 | String PathFindAppSetting = "/setting/";
24 | String PathChangeAppSetting = "/setting/{id}?value={value}";
25 | String PathProcessDay = "/processDay";
26 |
27 | /** 利用者監査ログを検索します。 */
28 | PagingList findAuditActor(FindAuditActor p);
29 |
30 | /** イベント監査ログを検索します。 */
31 | PagingList findAuditEvent(FindAuditEvent p);
32 |
33 | /** アプリケーション設定一覧を検索します。 */
34 | List findAppSetting(FindAppSetting p);
35 |
36 | /** アプリケーション設定情報を変更します。 */
37 | ResponseEntity changeAppSetting(String id, String value);
38 |
39 | /** 営業日を進めます。 */
40 | ResponseEntity processDay();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/admin/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する社内 API コンポーネント。
3 | */
4 | package sample.api.admin;
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/api/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * 外部へ公開する API コンポーネント。
3 | */
4 | package sample.api;
--------------------------------------------------------------------------------
/micro-core/src/main/java/sample/context/AppSettingHandler.java:
--------------------------------------------------------------------------------
1 | package sample.context;
2 |
3 | import java.util.*;
4 |
5 | import org.springframework.beans.factory.annotation.*;
6 | import org.springframework.cache.annotation.*;
7 | import org.springframework.transaction.PlatformTransactionManager;
8 |
9 | import sample.context.orm.*;
10 |
11 | /**
12 | * アプリケーション設定情報に対するアクセス手段を提供します。
13 | */
14 | public class AppSettingHandler {
15 |
16 | @Autowired
17 | private SystemRepository rep;
18 | @Autowired
19 | @Qualifier(SystemRepository.BeanNameTx)
20 | private PlatformTransactionManager txm;
21 | /** 設定時は固定のキー/値を返すモックモードとする */
22 | private final Optional