Skip to content

Commit

Permalink
Add input-dto/null-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
babyfish-ct committed Apr 27, 2024
1 parent 26d63d0 commit 12156fb
Show file tree
Hide file tree
Showing 14 changed files with 713 additions and 46 deletions.
3 changes: 2 additions & 1 deletion docs/graphql/mutation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ After compilation, the following Input DTO will be generated automatically:
<TabItem value="java" label="Java">

```java title="BookInput.java"
@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookInput implements Input<Book> { ❶

@Nullable
Expand Down Expand Up @@ -111,6 +111,7 @@ public class BookInput implements Input<Book> { ❶
<TabItem value="kotlin" label="Kotlin">

```kotlin title="BookInput.kt"
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookInput(
val id: Long? = null,
val name: String = "",
Expand Down
3 changes: 2 additions & 1 deletion docs/mutation/save-command/input-dto/dto-lang.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ package com.yourcompany.yourpoject.model.dto;
import com.yourcompany.yourpoject.model.Book;
import org.babyfish.jimmer.Input;
@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookInput implements Input<Book> {
@Nullable
Expand Down Expand Up @@ -139,6 +139,7 @@ package com.yourcompany.yourpoject.model.dto
import com.yourcompany.yourpoject.model.Book
import org.babyfish.jimmer.Input
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookInput(
val id: Long? = null, ❶
val name: String = "",
Expand Down
2 changes: 1 addition & 1 deletion docs/mutation/save-command/input-dto/mapstruct.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
title: Using MapStruct
---

Expand Down
4 changes: 4 additions & 0 deletions docs/mutation/save-command/input-dto/null-handling.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
sidebar_position: 4
title: Handle Null Values
---
5 changes: 2 additions & 3 deletions docs/query/object-fetcher/dto.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ package com.yourcompany.yourpoject.model.dto;
import com.yourcompany.yourpoject.model.Book;
import org.babyfish.jimmer.View;
@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookDetailView implements View<Book> {
private long id;
Expand All @@ -98,7 +98,6 @@ public class BookDetailView implements View<Book> {
// highlight-next-line
private List<TargetOf_authors> authors;
@lombok.Data
// highlight-next-line
public static class TargetOf_store implements View<BookStore> {
Expand All @@ -112,7 +111,6 @@ public class BookDetailView implements View<Book> {
...other members omitted...
}
@lombok.Data
// highlight-next-line
public static class TargetOf_authors implements View<Author> {
Expand Down Expand Up @@ -140,6 +138,7 @@ package com.yourcompany.yourpoject.model.dto
import com.yourcompany.yourpoject.model.Book
import org.babyfish.jimmer.View
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookDetailView(
val id: Long = 0,
val name: String = "",
Expand Down
5 changes: 2 additions & 3 deletions docs/spring/repository/dto.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ package com.yourcompany.yourpoject.model.dto;
import com.yourcompany.yourpoject.model.Book;
import org.babyfish.jimmer.View;
@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookDetailView implements Input<Book> {
private long id;
Expand All @@ -94,7 +94,6 @@ public class BookDetailView implements Input<Book> {
// highlight-next-line
private List<TargetOf_authors> authors;
@lombok.Data
// highlight-next-line
public static class TargetOf_store implements Input<BookStore> {
Expand All @@ -108,7 +107,6 @@ public class BookDetailView implements Input<Book> {
...Omitted other members...
}
@lombok.Data
// highlight-next-line
public static class TargetOf_authors implements Input<Author> {
Expand Down Expand Up @@ -136,6 +134,7 @@ package com.yourcompany.yourpoject.model.dto
import com.yourcompany.yourpoject.model.Book
import org.babyfish.jimmer.View
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookDetailView(
val id: Long = 0,
val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Jimmer提供了两种定义Input DTO的方式
<TabItem value="java" label="Java">

```java title="BookInput.java"
@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookInput implements Input<Book> { ❶

@Nullable
Expand Down Expand Up @@ -111,6 +111,7 @@ public class BookInput implements Input<Book> { ❶
<TabItem value="kotlin" label="Kotlin">

```kotlin title="BookInput.kt"
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookInput(
val id: Long? = null,
val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,6 @@ alter table learning_link

- 构建实体对象时,只能设置原始属性,不能设置视图属性。

这和[@IdView](./id-view)不同,对于[@IdView](./id-view)而言,原始属性和试图属性都可以设置
这和[@IdView](./id-view)不同,对于[@IdView](./id-view)而言,原始属性和视图属性都可以设置

- 无论原始属性,还是试图属性,预编译器都会生成与之配套的代码,所以二者都可以在[对象抓取器](../../../query/object-fetcher)和强类型SQL DSL中使用
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ package com.yourcompany.yourpoject.model.dto;
import com.yourcompany.yourpoject.model.Book;
import org.babyfish.jimmer.Input;

@lombok.Data
@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
public class BookInput implements Input<Book> {

@Nullable
Expand Down Expand Up @@ -138,6 +138,7 @@ package com.yourcompany.yourpoject.model.dto
import com.yourcompany.yourpoject.model.Book
import org.babyfish.jimmer.Input

@GenertedBy(file = "<your_project>/src/main/dto/Book.dto")
data class BookInput(
val id: Long? = null, ❶
val name: String = "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
title: 使用MapStruct
---

Expand Down
Loading

0 comments on commit 12156fb

Please sign in to comment.