-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds support for rich 'aggregate' modeling (refactoring)
- Loading branch information
Showing
29 changed files
with
560 additions
and
343 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
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
105 changes: 0 additions & 105 deletions
105
...efaultGenerator/src/main/java/core/implementation/mongodb/imperative/ServiceImpl.java.hbs
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...nerator/src/main/java/core/implementation/partials/jpa/aggregates-commands-methodBody.hbs
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 @@ | ||
// aggregates commands |
1 change: 1 addition & 0 deletions
1
...ltGenerator/src/main/java/core/implementation/partials/jpa/aggregates-void-methodBody.hbs
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 @@ | ||
// void |
40 changes: 40 additions & 0 deletions
40
...aultGenerator/src/main/java/core/implementation/partials/jpa/entities-crud-methodBody.hbs
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,40 @@ | ||
{{assign 'entity' aggregateCommandsForMethod.entity }} | ||
{{~#if (isCrudMethod 'create' method=method entity=entity )}} | ||
log.debug("[CRUD] Request to save {{entity.className}}: {}", input); | ||
var {{entity.instanceName}} = {{asInstanceName service.name}}Mapper.update(new {{entity.className}}(), {{{mapperInputCallSignature method.parameter}}}); | ||
{{entity.instanceName}} = {{entity.instanceName}}Repository.save({{entity.instanceName}}); | ||
// TODO: you may need to reload the entity here to fetch relationships 'mapped by id' | ||
{{~> (partial '../withEvents')}} | ||
return {{wrapWithMapper entity}}; | ||
{{~else if (isCrudMethod 'update' method=method entity=entity )}} | ||
log.debug("[CRUD] Request to update {{entity.className}}: {}", input); | ||
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id); | ||
// saving is unnecessary: https://vladmihalcea.com/best-spring-data-jparepository/ | ||
{{entity.instanceName}} = {{entity.instanceName}}.map(existing{{entity.instanceName}} -> {{asInstanceName service.name}}Mapper.update(existing{{entity.instanceName}}, {{{mapperInputCallSignature method.parameter}}})); | ||
{{~> (partial '../withEvents')}} | ||
return {{wrapWithMapper entity}}; | ||
{{~else if (isCrudMethod 'list' method=method entity=entity )}} | ||
{{~#if method.options.paginated}} | ||
log.debug("[CRUD] Request list of {{entity.classNamePlural}}: {}", pageable); | ||
var {{entity.instanceNamePlural}} = {{entity.instanceName}}Repository.findAll(pageable); | ||
return {{wrapWithMapper entity}}; | ||
{{~else}} | ||
log.debug("Request list of {{entity.classNamePlural}}"); | ||
var {{entity.instanceNamePlural}} = {{entity.instanceName}}Repository.findAll(); | ||
return {{wrapWithMapper entity}}; | ||
{{~/if}} | ||
{{~else if (isCrudMethod 'search' method=method entity=entity )}} | ||
log.debug("[CRUD] Request to search {{entity.classNamePlural}}: {} - {}", input, pageable); | ||
// TODO implement this search by criteria | ||
var {{entity.instanceNamePlural}} = {{entity.instanceName}}Repository.findAll(pageable); | ||
return {{wrapWithMapper entity}}; | ||
{{~else if (isCrudMethod 'get' method=method entity=entity )}} | ||
log.debug("[CRUD] Request to get {{entity.className}} : {}", id); | ||
var {{entity.instanceName}} = {{entity.instanceName}}Repository.findById(id); | ||
return {{wrapWithMapper entity}}; | ||
{{~else if (isCrudMethod 'delete' method=method entity=entity )}} | ||
log.debug("[CRUD] Request to delete {{entity.className}} : {}", id); | ||
{{entity.instanceName}}Repository.deleteById(id); | ||
{{~> (partial '../withEvents')}} | ||
{{~/if}} | ||
|
Oops, something went wrong.