@@ -20,74 +20,75 @@ github: babyfish-ct/graphql-provider
20
20
> Due to space limitations, all * EntityMapper* s only uses a static mapping configuration similar to ORM, and does not use a more dynamic code configuration. For a complete demonstration, please refer to the example and documentation of the project itself.
21
21
22
22
1 . BookStoreMapper.kt
23
- ``` kt
24
- @Component
25
- class BookStoreMapper : EntityMapper <BookStore , UUID >() {
23
+ ``` kt
24
+ @Component
25
+ class BookStoreMapper : EntityMapper <BookStore , UUID >() {
26
26
27
- // Inverse one-to-many "BookStore.books" is the the
28
- // mirror image of many-to-one association "Book.store"
29
- mappedList(BookStore ::books, Book ::store)
27
+ // Inverse one-to-many "BookStore.books" is the the
28
+ // mirror image of many-to-one association "Book.store"
29
+ mappedList(BookStore ::books, Book ::store)
30
+ }
30
31
}
31
- }
32
- ```
32
+ ```
33
33
34
34
2 . BookMapper .kt
35
- ``` kt
36
- @Component
37
- class BookMapper : EntityMapper <Book , UUID >() {
35
+ ```kt
36
+ @Component
37
+ class BookMapper : EntityMapper <Book , UUID >() {
38
38
39
- override fun EntityTypeDSL <Book , UUID >.config () {
39
+ override fun EntityTypeDSL <Book , UUID >.config () {
40
40
41
- reference(Book ::store) // many-to-one
41
+ reference(Book ::store) // many-to-one
42
42
43
- list(Book ::authors) { // many-to-many
44
- db {
45
- middleTable {
46
- tableName = " BOOK_AUTHOR_MAPPING"
47
- joinColumnName = " BOOK_ID"
48
- targetJoinColumnName = " AUTHOR_ID"
43
+ list(Book ::authors) { // many-to-many
44
+ db {
45
+ middleTable {
46
+ tableName = " BOOK_AUTHOR_MAPPING"
47
+ joinColumnName = " BOOK_ID"
48
+ targetJoinColumnName = " AUTHOR_ID"
49
+ }
49
50
}
50
51
}
51
52
}
52
53
}
53
- }
54
- ```
54
+ ```
55
55
56
56
3 . Author .kt
57
- @Component
58
- class AuthorMapper: EntityMapper<Author, UUID>() {
57
+ ```kt
58
+ @Component
59
+ class AuthorMapper : EntityMapper <Author , UUID >() {
59
60
60
- override fun EntityTypeDSL<Author, UUID>.config() {
61
+ override fun EntityTypeDSL <Author , UUID >.config () {
61
62
62
- // Inverse many-to-many "Author.books" is the the
63
- // mirror image of many-to-many association "Book.authors"
64
- mappedList(Author::books, Book::authors)
63
+ // Inverse many-to-many "Author.books" is the the
64
+ // mirror image of many-to-many association "Book.authors"
65
+ mappedList(Author ::books, Book ::authors)
66
+ }
65
67
}
66
- }
68
+ ```
67
69
68
70
4 . BookQuery .kt
69
-
70
- ``` kt
71
- @Service
72
- class BookQuery : Query () {
73
-
74
- // Return type is Connection<Book>, not List<Book>,
75
- // that means its pagination query.
76
- fun findBooks (
77
- name : String? ,
78
- storeName : String?
79
- ): Connection < Book > =
80
- runtime.queryConnection {
81
- name?. let {
82
- db {
83
- where(table.name ilike it)
71
+ ```kt
72
+ @Service
73
+ class BookQuery : Query () {
74
+
75
+ // Return type is Connection<Book>, not List<Book>,
76
+ // that means its pagination query.
77
+ fun findBooks (
78
+ name : String? ,
79
+ storeName : String?
80
+ ): Connection < Book > =
81
+ runtime.queryConnection {
82
+ name?. let {
83
+ db {
84
+ where(table.name ilike it)
85
+ }
84
86
}
85
- }
86
- storeName?. let {
87
- db {
88
- where(table.store.name ilike it)
87
+ storeName?. let {
88
+ db {
89
+ where(table.store.name ilike it)
90
+ }
89
91
}
90
92
}
91
- }
92
- }
93
- ```
93
+ }
94
+ ```
0 commit comments