Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Grailsでドメイン駆動設計を実践する時の勘所

6.817 Aufrufe

Veröffentlicht am

Spring Day 2016 のスライドです。

Veröffentlicht in: Software
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Grailsでドメイン駆動設計を実践する時の勘所

  1. 1. 

  2. 2. $ grails create-app helloworld $ cd helloworld $ grails create-domain-class hello $ vi ./grails-app/domain/helloworld/ Hello.groovy
  3. 3. package helloworld class Hello { String message static constraints = { } }
  4. 4. $ grails create-controller hello $ vi ./grails-app/controllers/ helloworld/HelloController.groovy
  5. 5. package helloworld class HelloController { static scaffold = Hello }
  6. 6. $ grails run-app
  7. 7.
  8. 8.
  9. 9.
  10. 10. 
 

  11. 11. 
 
 

 
 
 

  12. 12. grails {
 exploded = true
 plugins {
 compile project(':core-domain-plugin')
 compile project(':sub-domain-plugin')
 }
 } includeFlat 'core-domain-plugin'
 includeFlat 'sub-domain-plugin'
  13. 13.
  14. 14. class IsbnUserType implements UserType {
 
 @Override
 int[] sqlTypes() {
 return [StringType.INSTANCE.sqlType()]
 }
 
 @Override
 Class returnedClass() {
 return Isbn.class
 } }
  15. 15. package com.example.domain class Isbn {
 private String isbnCode
 }
  16. 16. class Book {
 String title
 Isbn isbn
 BigDecimal standardUnitPrice
 
 static mapping = {
 isbn type: IsbnUserType
 } 
 String toString() {
 title
 }
 }
  17. 17. 
 dependencies {
 compile "org.springframework.boot:spring-boot-starter-logging"
 compile "org.springframework.boot:spring-boot-autoconfigure"
 compile "org.grails:grails-core"
 compile "org.springframework.boot:spring-boot-starter-actuator"
 compile "org.springframework.boot:spring-boot-starter-tomcat"
 
 compile "org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1"
 :
 }

  18. 18. package com.example.domain class Isbn {
 private String isbnCode
 }
  19. 19. package com.example.domain
 
 import grails.validation.Validateable
 
 class Book implements Validateable {
 Long id
 String title
 Isbn isbn
 BigDecimal standardUnitPrice Long version
 
 static constraints = {
 }
 }

  20. 20. package com.example.infrastructure
 
 import com.example.domain.Book
 import org.apache.ibatis.annotations.Mapper
 import org.apache.ibatis.annotations.Param
 
 @Mapper
 interface BookMapper {
 void register(@Param("book") Book book)
 List<Book> list()
 }
  21. 21. <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.example.infrastructure.BookMapper">
 
 <resultMap id="product" type="com.example.domain.Book">
 <id property="id" column="id"/>
 <result property=“isbn.isbnCode" column="isbn_code"/>
 <result property="title" column=“title"/> <result property="standardUnitPrice" column=“standard_unit_price”/>
 <result property="version" column="version"/>
 </resultMap>
 
 :
 </mapper>

  22. 22. package com.example
 
 class BookRepositoryService { 
 List<Book> list() { Book.findAll() } :
 }
  23. 23. package com.example.domain
 
 interface BookRepository { 
 List<Book> list()
 Book get(Long id)
 
 }
  24. 24. package com.example.infrastructure
 
 import com.example.domain.Book
 import com.example.domain.BookRepository
 import org.springframework.stereotype.Repository
 
 @Repository
 class BookDatasource implements BookRepository {
 
 @Override List<Book> list() { Book.findAll() }
 :
 }
  25. 25.

×