-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Java support and future support for other stacks.
- Loading branch information
Showing
139 changed files
with
1,860 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
...ava/[groupIdSlashes]/[artifactIdSlashes]/domain/[nameLowerCase]/[namePascalCase].java.peb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package {{ groupId }}.{{ artifactId }}.domain.{{ nameLowerCase }}; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.With; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
@Data | ||
@With | ||
@Builder | ||
public class {{ namePascalCase }} { | ||
private int id;{%for field in fields%} | ||
@NonNull | ||
private {{ field.fieldJavaType }} {{ field.fieldNameCamelCase }};{%endfor%} | ||
@NonNull | ||
private OffsetDateTime createdAt; | ||
private OffsetDateTime updatedAt; | ||
} |
25 changes: 25 additions & 0 deletions
25
...roupIdSlashes]/[artifactIdSlashes]/domain/[nameLowerCase]/[namePascalCase]Entity.java.peb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package {{ groupId }}.{{ artifactId }}.domain.{{ nameLowerCase }}; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NonNull; | ||
import lombok.With; | ||
import org.springframework.data.relational.core.mapping.Table; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@With | ||
@Builder | ||
@Table("{{ namePluralSnakeCase }}") | ||
public class {{ namePascalCase }}Entity { | ||
@Id | ||
private Integer id;{%for field in fields%} | ||
private {{ field.fieldJavaType }} {{ field.fieldNameCamelCase }};{%endfor%} | ||
|
||
@CreatedDate | ||
private LocalDateTime createdAt; | ||
|
||
@LastModifiedDate | ||
private LocalDateTime LocalDateTime; | ||
} |
17 changes: 17 additions & 0 deletions
17
...IdSlashes]/[artifactIdSlashes]/domain/[nameLowerCase]/[namePascalCase]Repository.java.peb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package {{ groupId }}.{{ artifactId }}.domain.{{ nameLowerCase }}; | ||
|
||
import org.springframework.data.jdbc.repository.query.Query; | ||
import org.springframework.data.repository.CrudRepository; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
|
||
interface {{ namePascalCase }}Repository extends CrudRepository<{{ namePascalCase }}Entity, Integer> { | ||
|
||
@Query("SELECT * FROM {{ namePluralSnakeCase }} WHERE id IN (:ids)") | ||
List<{{ namePascalCase }}Entity> findByIds(@Param("ids") Iterable<Integer> ids); | ||
{%for field in fields%}{%if field.isFieldRelational%} | ||
@Query("SELECT * FROM {{ namePluralSnakeCase }} WHERE {{ field.fieldNameSnakeCase }} IN (:{{ field.fieldNamePluralCamelCase }})") | ||
List<{{ namePascalCase }}Entity> findBy{{ field.fieldNamePluralPascalCase }}(@Param("{{ field.fieldNamePluralCamelCase }}") Iterable<Integer> {{ field.fieldNamePluralCamelCase }}); | ||
{%endif%}{%endfor%} | ||
} |
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
...rtifactIdSlashes]/application/graphql/[nameLowerCase]/[namePascalCase]DataLoader.java.peb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package {{ groupId }}.{{ artifactId }}.application.graphql.{{ nameLowerCase }}; | ||
|
||
import com.netflix.graphql.dgs.DgsComponent; | ||
import com.netflix.graphql.dgs.DgsDataLoader; | ||
import {{ groupId }}.{{ artifactId }}.domain.{{ nameLowerCase }}.{{ namePascalCase }}; | ||
import {{ groupId }}.{{ artifactId }}.domain.{{ nameLowerCase }}.{{ namePascalCase }}Service; | ||
import lombok.RequiredArgsConstructor; | ||
import org.dataloader.MappedBatchLoader; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.concurrent.CompletableFuture.supplyAsync; | ||
|
||
@DgsComponent | ||
@RequiredArgsConstructor | ||
class {{ namePascalCase }}DataLoader { | ||
private {{ namePascalCase }}Service {{ nameCamelCase }}Service; | ||
|
||
@DgsDataLoader(name = "{{ nameCamelCase }}ById") | ||
MappedBatchLoader<Integer, {{ namePascalCase }}> {{ nameCamelCase }}ById = ids -> supplyAsync(() -> | ||
{{ nameCamelCase }}Service.findByIds(ids) | ||
.stream() | ||
.collect(Collectors.toMap({{ namePascalCase }}::getId, Function.identity()))); | ||
{%for field in fields%}{%if field.isFieldRelational%} | ||
@DgsDataLoader(name = "{{ namePluralCamelCase }}By{{ field.fieldNamePascalCase }}") | ||
MappedBatchLoader<Integer, List<{{ namePascalCase }}>> {{ namePluralCamelCase }}By{{ field.fieldNamePascalCase }} = ids -> supplyAsync(() -> | ||
{{ nameCamelCase }}Service.findBy{{ field.fieldNamePluralPascalCase }}(ids) | ||
.stream() | ||
.collect(Collectors.groupingBy({{ namePascalCase }}::get{{ field.fieldNamePascalCase }}))); | ||
{%endif%}{%endfor%} | ||
} |
Oops, something went wrong.