Jhipsterのアプリケーションの作成
アプリケーションの拡張
Jhipsterでプロジェクトを生成したのでアプリケーションを拡張していきます
Entityの作成
http://www.jhipster.tech/creating-an-entity/
どうやら、entityの実行をオプションなしで実行すると基本的なCRUDのすべてをバックエンド&フロントエンドで全部作ってくれるらしい。しかし、サービス層は作成されない。
サービス層を作るかentity追加時に聞かれた。
[takumiMac:jhipster]./node_modules/.bin/yo jhipster:entity author (git)-[p_1] The entity author is being created. Generating field #1 ? Do you want to add a field to your entity? Yes ? What is the name of your field? name ? What is the type of your field? String ? Do you want to add validation rules to your field? Yes ? Which validation rules do you want to add? Maximum length ? What is the maximum length of your field? 100 ================= Author ================= Fields name (String) maxlength='100' Generating field #2 ? Do you want to add a field to your entity? Yes ? What is the name of your field? birthDate ? What is the type of your field? LocalDate ? Do you want to add validation rules to your field? Yes ? Which validation rules do you want to add? Required ================= Author ================= Fields name (String) maxlength='100' birthDate (LocalDate) required Generating field #3 ? Do you want to add a field to your entity? No ================= Author ================= Fields name (String) maxlength='100' birthDate (LocalDate) required Generating relationships to other entities ? Do you want to add a relationship to another entity? No ================= Author ================= Fields name (String) maxlength='100' birthDate (LocalDate) required ? Do you want to use separate service class for your business logic? Yes, generate a separate service class ? Do you want to use a Data Transfer Object (DTO)? No, use the entity directly ? Do you want to add filtering? Not needed ? Do you want pagination on your entity? Yes, with pagination links
生成されたファイル
create mode 100644 .jhipster/Author.json create mode 100644 src/main/java/jp/co/corp/jhipster/domain/Author.java create mode 100644 src/main/java/jp/co/corp/jhipster/repository/AuthorRepository.java create mode 100644 src/main/java/jp/co/corp/jhipster/repository/search/AuthorSearchRepository.java create mode 100644 src/main/java/jp/co/corp/jhipster/service/AuthorService.java create mode 100644 src/main/java/jp/co/corp/jhipster/web/rest/AuthorResource.java create mode 100644 src/main/resources/config/liquibase/changelog/20180122091305_added_entity_Author.xml create mode 100644 src/main/webapp/app/entities/author/author-delete-dialog.component.html create mode 100644 src/main/webapp/app/entities/author/author-delete-dialog.component.ts create mode 100644 src/main/webapp/app/entities/author/author-detail.component.html create mode 100644 src/main/webapp/app/entities/author/author-detail.component.ts create mode 100644 src/main/webapp/app/entities/author/author-dialog.component.html create mode 100644 src/main/webapp/app/entities/author/author-dialog.component.ts create mode 100644 src/main/webapp/app/entities/author/author-popup.service.ts create mode 100644 src/main/webapp/app/entities/author/author.component.html create mode 100644 src/main/webapp/app/entities/author/author.component.ts create mode 100644 src/main/webapp/app/entities/author/author.model.ts create mode 100644 src/main/webapp/app/entities/author/author.module.ts create mode 100644 src/main/webapp/app/entities/author/author.route.ts create mode 100644 src/main/webapp/app/entities/author/author.service.t create mode 100644 src/main/webapp/app/entities/author/index.ts create mode 100644 src/main/webapp/i18n/en/author.json create mode 100644 src/main/webapp/i18n/ja/author.json create mode 100644 src/test/gatling/user-files/simulations/AuthorGatlingTest.scala create mode 100644 src/test/java/jp/co/corp/jhipster/web/rest/AuthorResourceIntTest.java create mode 100644 src/test/javascript/e2e/entities/author.spec.ts create mode 100644 src/test/javascript/spec/app/entities/author/author-delete-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/author/author-detail.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/author/author-dialog.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/author/author.component.spec.ts create mode 100644 src/test/javascript/spec/app/entities/author/author.service.spec.ts
バックエンド側はドメイン、リポジトリ、サービス、コントローラが生成された。
サービスが生成された理由は、entity生成時に「サービスを生成する」を選択したから。たぶん中身は大したことしてない。検証のためにまずはサービスなしで生成すればよかった。。。
SpringContorollerの作成
http://www.jhipster.tech/creating-a-spring-controller/
[takumiMac:jhipster]./node_modules/.bin/jhipster spring-controller takumi (git)-[p_1] Using JHipster version installed globally Executing jhipster:spring-controller takumi Options: The spring-controller takumi is being created. ? Do you want to add an action to your controller? Yes ? What is the name of your action? takumi ? What is the HTTP method of your action? GET ? Do you want to add an action to your controller? No adding Get action 'takumi' for /api/takumi/takumi create src/main/java/jp/co/corp/jhipster/web/rest/TakumiResource.java create src/test/java/jp/co/corp/jhipster/web/rest/TakumiResourceIntTest.java Congratulations, JHipster execution is complete!
生成されたファイル
create src/main/java/jp/co/corp/jhipster/web/rest/TakumiResource.java create src/test/java/jp/co/corp/jhipster/web/rest/TakumiResourceIntTest.java
controllerクラス、そのテストクラスが生成された。
SpringServiceの生成
http://www.jhipster.tech/creating-a-spring-service/
Entityの生成時に一緒に生成できたので今回は飛ばします。 複数のデータソースを扱うようなビジネスロジックを作成するときに使うんでしょう。(たぶん)
次回はJDLを試してみます。 そのまえに公式ドキュメントをもう少しちゃんと読んできます・・・