eva4j 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/skill-creator/LICENSE.txt +202 -0
- package/.agents/skills/skill-creator/SKILL.md +485 -0
- package/.agents/skills/skill-creator/agents/analyzer.md +274 -0
- package/.agents/skills/skill-creator/agents/comparator.md +202 -0
- package/.agents/skills/skill-creator/agents/grader.md +223 -0
- package/.agents/skills/skill-creator/assets/eval_review.html +146 -0
- package/.agents/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.agents/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.agents/skills/skill-creator/references/schemas.md +430 -0
- package/.agents/skills/skill-creator/scripts/__init__.py +0 -0
- package/.agents/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.agents/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.agents/skills/skill-creator/scripts/improve_description.py +247 -0
- package/.agents/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.agents/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.agents/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.agents/skills/skill-creator/scripts/run_loop.py +328 -0
- package/.agents/skills/skill-creator/scripts/utils.py +47 -0
- package/AGENTS.md +268 -6
- package/COMMAND_EVALUATION.md +15 -16
- package/DOMAIN_YAML_GUIDE.md +430 -14
- package/FUTURE_FEATURES.md +1627 -1168
- package/README.md +461 -13
- package/bin/eva4j.js +32 -14
- package/config/defaults.json +1 -0
- package/docs/commands/EVALUATE_SYSTEM.md +746 -261
- package/docs/commands/EXPORT_DIAGRAM.md +153 -0
- package/docs/commands/GENERATE_ENTITIES.md +599 -6
- package/docs/commands/INDEX.md +7 -0
- package/examples/domain-events.yaml +166 -20
- package/examples/domain-listeners.yaml +212 -0
- package/examples/domain-one-to-many.yaml +1 -0
- package/examples/domain-one-to-one.yaml +1 -0
- package/examples/domain-ports.yaml +414 -0
- package/examples/domain-soft-delete.yaml +47 -44
- package/examples/system/notification.yaml +147 -0
- package/examples/system/product.yaml +185 -0
- package/examples/system/system.yaml +112 -0
- package/examples/system-report.html +971 -0
- package/examples/system.yaml +46 -3
- package/package.json +2 -1
- package/src/agents/design-reviewer.agent.md +163 -0
- package/src/commands/build.js +714 -0
- package/src/commands/create.js +1 -0
- package/src/commands/detach.js +149 -108
- package/src/commands/evaluate-system.js +234 -8
- package/src/commands/export-diagram.js +522 -0
- package/src/commands/generate-entities.js +685 -66
- package/src/commands/generate-http-exchange.js +2 -0
- package/src/commands/generate-kafka-event.js +43 -10
- package/src/generators/base-generator.js +18 -6
- package/src/generators/postman-generator.js +188 -0
- package/src/generators/shared-generator.js +12 -2
- package/src/skills/build-system-yaml/SKILL.md +323 -0
- package/src/skills/build-system-yaml/references/domain-yaml-spec.md +410 -0
- package/src/skills/build-system-yaml/references/module-spec.md +367 -0
- package/src/skills/build-system-yaml/references/system-yaml-spec.md +178 -0
- package/src/utils/config-manager.js +54 -0
- package/src/utils/context-builder.js +1 -0
- package/src/utils/domain-diagram.js +192 -0
- package/src/utils/domain-validator.js +1020 -0
- package/src/utils/fake-data.js +376 -0
- package/src/utils/system-validator.js +319 -199
- package/src/utils/yaml-to-entity.js +272 -7
- package/templates/aggregate/AggregateMapper.java.ejs +3 -2
- package/templates/aggregate/AggregateRepository.java.ejs +3 -2
- package/templates/aggregate/AggregateRepositoryImpl.java.ejs +6 -5
- package/templates/aggregate/AggregateRoot.java.ejs +60 -2
- package/templates/aggregate/DomainEventHandler.java.ejs +4 -1
- package/templates/aggregate/DomainEventRecord.java.ejs +24 -8
- package/templates/aggregate/DomainEventSnapshot.java.ejs +46 -0
- package/templates/aggregate/JpaAggregateRoot.java.ejs +6 -0
- package/templates/base/docker/Dockerfile.ejs +21 -0
- package/templates/base/gradle/build.gradle.ejs +3 -2
- package/templates/base/root/AGENTS.md.ejs +306 -45
- package/templates/crud/ApplicationMapper.java.ejs +4 -0
- package/templates/crud/Controller.java.ejs +4 -4
- package/templates/crud/CreateCommand.java.ejs +4 -0
- package/templates/crud/CreateCommandHandler.java.ejs +3 -6
- package/templates/crud/CreateItemDto.java.ejs +4 -0
- package/templates/crud/CreateValueObjectDto.java.ejs +4 -0
- package/templates/crud/DeleteCommandHandler.java.ejs +12 -6
- package/templates/crud/EndpointsController.java.ejs +6 -6
- package/templates/crud/FindByQuery.java.ejs +1 -1
- package/templates/crud/FindByQueryHandler.java.ejs +3 -9
- package/templates/crud/GetQueryHandler.java.ejs +2 -5
- package/templates/crud/ListQuery.java.ejs +1 -1
- package/templates/crud/ListQueryHandler.java.ejs +8 -14
- package/templates/crud/ScaffoldCommandHandler.java.ejs +2 -4
- package/templates/crud/ScaffoldQuery.java.ejs +3 -2
- package/templates/crud/ScaffoldQueryHandler.java.ejs +5 -6
- package/templates/crud/SubEntityAddCommand.java.ejs +4 -0
- package/templates/crud/SubEntityAddCommandHandler.java.ejs +2 -6
- package/templates/crud/SubEntityRemoveCommandHandler.java.ejs +2 -7
- package/templates/crud/TransitionCommandHandler.java.ejs +2 -6
- package/templates/crud/UpdateCommand.java.ejs +4 -0
- package/templates/crud/UpdateCommandHandler.java.ejs +2 -5
- package/templates/evaluate/report.html.ejs +394 -2
- package/templates/kafka-event/DomainEventHandlerMethod.ejs +3 -1
- package/templates/kafka-event/Event.java.ejs +9 -0
- package/templates/kafka-listener/KafkaController.java.ejs +1 -1
- package/templates/kafka-listener/KafkaListenerClass.java.ejs +1 -1
- package/templates/kafka-listener/ListenerClass.java.ejs +65 -0
- package/templates/kafka-listener/ListenerCommand.java.ejs +31 -0
- package/templates/kafka-listener/ListenerCommandHandler.java.ejs +25 -0
- package/templates/kafka-listener/ListenerIntegrationEvent.java.ejs +37 -0
- package/templates/kafka-listener/ListenerMethod.java.ejs +1 -1
- package/templates/kafka-listener/ListenerNestedType.java.ejs +28 -0
- package/templates/mock/MockEvent.java.ejs +10 -0
- package/templates/mock/MockMessageBrokerImpl.java.ejs +35 -0
- package/templates/mock/MockMessageBrokerImplMethod.java.ejs +6 -0
- package/templates/mock/SpringEventListener.java.ejs +61 -0
- package/templates/ports/PortDomainModel.java.ejs +35 -0
- package/templates/ports/PortFeignAdapter.java.ejs +67 -0
- package/templates/ports/PortFeignClient.java.ejs +45 -0
- package/templates/ports/PortFeignConfig.java.ejs +24 -0
- package/templates/ports/PortInterface.java.ejs +45 -0
- package/templates/ports/PortNestedType.java.ejs +28 -0
- package/templates/ports/PortRequestDto.java.ejs +30 -0
- package/templates/ports/PortResponseDto.java.ejs +28 -0
- package/templates/postman/Collection.json.ejs +1 -1
- package/templates/postman/UnifiedCollection.json.ejs +185 -0
- package/templates/shared/annotations/LogAfter.java.ejs +2 -0
- package/templates/shared/annotations/LogBefore.java.ejs +2 -0
- package/templates/shared/annotations/LogExceptions.java.ejs +2 -0
- package/templates/shared/annotations/LogLevel.java.ejs +8 -0
- package/templates/shared/annotations/LogTimer.java.ejs +1 -0
- package/templates/shared/annotations/Loggable.java.ejs +17 -0
- package/templates/shared/configurations/eventPublicationConfig/EventPublicationSchemaConfig.java.ejs +109 -0
- package/templates/shared/configurations/loggerConfig/HandlerLogs.java.ejs +120 -32
- package/templates/shared/errorMessage/ErrorResponse.java.ejs +23 -0
- package/templates/shared/handlerException/HandlerExceptions.java.ejs +99 -79
- package/src/commands/generate-system.js +0 -243
- package/templates/base/root/skill-build-domain-yaml-references-generate-entities.md.ejs +0 -1103
- package/templates/base/root/skill-build-domain-yaml.ejs +0 -292
- package/templates/base/root/skill-build-system-yaml.ejs +0 -252
- package/templates/shared/errorMessage/ErrorMessage.java.ejs +0 -5
- package/templates/shared/errorMessage/FullErrorMessage.java.ejs +0 -9
- package/templates/shared/errorMessage/ShortErrorMessage.java.ejs +0 -6
|
@@ -36,7 +36,7 @@ import <%= packageName %>.<%= moduleName %>.application.commands.Delete<%= aggre
|
|
|
36
36
|
import <%= packageName %>.<%= moduleName %>.application.queries.Get<%= aggregateName %>Query;
|
|
37
37
|
<% } -%>
|
|
38
38
|
<% if (hasFindAll) { -%>
|
|
39
|
-
import <%= packageName %>.<%= moduleName %>.application.queries.FindAll<%=
|
|
39
|
+
import <%= packageName %>.<%= moduleName %>.application.queries.FindAll<%= aggregateNamePlural %>Query;
|
|
40
40
|
<% } -%>
|
|
41
41
|
<% customCmdUCs.forEach(function(op) { -%>
|
|
42
42
|
import <%= packageName %>.<%= moduleName %>.application.commands.<%= op.useCase %>Command;
|
|
@@ -56,7 +56,7 @@ import <%= packageName %>.<%= moduleName %>.application.commands.<%= op.useCase
|
|
|
56
56
|
<% findByOps.forEach(function(op) { -%>
|
|
57
57
|
import <%= packageName %>.<%= moduleName %>.application.queries.<%= op.useCase %>Query;
|
|
58
58
|
<% }); -%>
|
|
59
|
-
<% if (hasGetById || hasFindAll || hasFindBy) { -%>
|
|
59
|
+
<% if (hasGetById || hasFindAll || hasFindBy || customQueryUCs.length > 0) { -%>
|
|
60
60
|
import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %>ResponseDto;
|
|
61
61
|
<% } -%>
|
|
62
62
|
<% if (hasFindAll || hasFindBy) { -%>
|
|
@@ -105,9 +105,9 @@ public class <%= controllerName %> {
|
|
|
105
105
|
@RequestParam(defaultValue = "20") int size,
|
|
106
106
|
@RequestParam(defaultValue = "id") String sortBy,
|
|
107
107
|
@RequestParam(defaultValue = "ASC") String sortDirection) {
|
|
108
|
-
log.info("Finding all <%=
|
|
108
|
+
log.info("Finding all <%= aggregateNamePlural %> — page={}, size={}, sortBy={}, sortDirection={}",
|
|
109
109
|
page, size, sortBy, sortDirection);
|
|
110
|
-
return useCaseMediator.dispatch(new FindAll<%=
|
|
110
|
+
return useCaseMediator.dispatch(new FindAll<%= aggregateNamePlural %>Query(page, size, sortBy, sortDirection));
|
|
111
111
|
}
|
|
112
112
|
<% } else if (op.isStandard && op.standardType === 'delete') { %>
|
|
113
113
|
public void <%= op.methodName %>(@PathVariable <%- idType %> id) {
|
|
@@ -168,8 +168,8 @@ public class <%= controllerName %> {
|
|
|
168
168
|
useCaseMediator.dispatch(command);
|
|
169
169
|
}
|
|
170
170
|
<% } else { %>
|
|
171
|
-
// TODO: Review the parameters in <%= op.useCase %>Query and
|
|
172
|
-
public
|
|
171
|
+
// TODO: Review the parameters in <%= op.useCase %>Query and adapt the return type if needed
|
|
172
|
+
public <%- op.returnType %> <%= op.methodName %>(<% if (op.hasPathVar) { %>@PathVariable <%- op.idType %> <%= op.pathVarName %><% } %>) {
|
|
173
173
|
log.info("Handling <%= op.useCase %>");
|
|
174
174
|
return useCaseMediator.dispatch(new <%= op.useCase %>Query(<% if (op.hasPathVar) { %><%= op.pathVarName %><% } %>));
|
|
175
175
|
}
|
|
@@ -6,7 +6,7 @@ import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* <%= useCaseName %>Query
|
|
9
|
-
* Returns a paginated list of <%=
|
|
9
|
+
* Returns a paginated list of <%= aggregateNamePlural %> filtered by <%= fieldName %>.
|
|
10
10
|
*/
|
|
11
11
|
public record <%= useCaseName %>Query(
|
|
12
12
|
<%- fieldJavaType %> <%= fieldName %>,
|
|
@@ -7,8 +7,8 @@ import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregate
|
|
|
7
7
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
8
8
|
import <%= packageName %>.shared.application.dtos.PagedResponse;
|
|
9
9
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
10
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
10
11
|
import <%= packageName %>.shared.domain.interfaces.QueryHandler;
|
|
11
|
-
import lombok.extern.slf4j.Slf4j;
|
|
12
12
|
import org.springframework.data.domain.Page;
|
|
13
13
|
import org.springframework.data.domain.PageRequest;
|
|
14
14
|
import org.springframework.data.domain.Pageable;
|
|
@@ -19,10 +19,9 @@ import java.util.List;
|
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* <%= useCaseName %>QueryHandler
|
|
22
|
-
* Returns paginated <%=
|
|
22
|
+
* Returns paginated <%= aggregateNamePlural %> filtered by <%= fieldName %>.
|
|
23
23
|
* Calls repository.<%= jpaMethodName %>(<%= fieldName %>, pageable).
|
|
24
24
|
*/
|
|
25
|
-
@Slf4j
|
|
26
25
|
@ApplicationComponent
|
|
27
26
|
public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseName %>Query, PagedResponse<<%= aggregateName %>ResponseDto>> {
|
|
28
27
|
|
|
@@ -37,10 +36,8 @@ public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseN
|
|
|
37
36
|
|
|
38
37
|
@Override
|
|
39
38
|
@Transactional(readOnly = true)
|
|
39
|
+
@LogExceptions
|
|
40
40
|
public PagedResponse<<%= aggregateName %>ResponseDto> handle(<%= useCaseName %>Query query) {
|
|
41
|
-
log.info("Handling <%= useCaseName %>Query — <%= fieldName %>={}, page={}, size={}",
|
|
42
|
-
query.<%= fieldName %>(), query.page(), query.size());
|
|
43
|
-
|
|
44
41
|
Sort sort = Sort.by(Sort.Direction.fromString(query.sortDirection()), query.sortBy());
|
|
45
42
|
Pageable pageable = PageRequest.of(query.page(), query.size(), sort);
|
|
46
43
|
|
|
@@ -49,9 +46,6 @@ public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseN
|
|
|
49
46
|
.map(mapper::toDto)
|
|
50
47
|
.toList();
|
|
51
48
|
|
|
52
|
-
log.info("<%= useCaseName %> retrieved — page={}/{}, totalElements={}",
|
|
53
|
-
page.getNumber() + 1, page.getTotalPages(), page.getTotalElements());
|
|
54
|
-
|
|
55
49
|
return PagedResponse.of(content, page.getNumber(), page.getSize(), page.getTotalElements());
|
|
56
50
|
}
|
|
57
51
|
}
|
|
@@ -6,16 +6,15 @@ import <%= packageName %>.<%= moduleName %>.application.mappers.<%= aggregateNam
|
|
|
6
6
|
import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregateName %>;
|
|
7
7
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
8
8
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
9
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
9
10
|
import <%= packageName %>.shared.domain.customExceptions.NotFoundException;
|
|
10
11
|
import <%= packageName %>.shared.domain.interfaces.QueryHandler;
|
|
11
|
-
import lombok.extern.slf4j.Slf4j;
|
|
12
12
|
import org.springframework.transaction.annotation.Transactional;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get<%= aggregateName %>QueryHandler
|
|
16
16
|
* Handles retrieval of a single <%= aggregateName %> by ID
|
|
17
17
|
*/
|
|
18
|
-
@Slf4j
|
|
19
18
|
@ApplicationComponent
|
|
20
19
|
public class Get<%= aggregateName %>QueryHandler implements QueryHandler<Get<%= aggregateName %>Query, <%= aggregateName %>ResponseDto> {
|
|
21
20
|
|
|
@@ -30,13 +29,11 @@ public class Get<%= aggregateName %>QueryHandler implements QueryHandler<Get<%=
|
|
|
30
29
|
|
|
31
30
|
@Override
|
|
32
31
|
@Transactional(readOnly = true)
|
|
32
|
+
@LogExceptions
|
|
33
33
|
public <%= aggregateName %>ResponseDto handle(Get<%= aggregateName %>Query query) {
|
|
34
|
-
log.info("Handling Get<%= aggregateName %>Query for id: {}", query.id());
|
|
35
|
-
|
|
36
34
|
<%= aggregateName %> entity = repository.findById(query.id())
|
|
37
35
|
.orElseThrow(() -> new NotFoundException("<%= aggregateName %> not found with id: " + query.id()));
|
|
38
36
|
|
|
39
|
-
log.info("<%= aggregateName %> retrieved successfully with id: {}", query.id());
|
|
40
37
|
return mapper.toDto(entity);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
@@ -4,7 +4,7 @@ import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %
|
|
|
4
4
|
import <%= packageName %>.shared.application.dtos.PagedResponse;
|
|
5
5
|
import <%= packageName %>.shared.domain.interfaces.Query;
|
|
6
6
|
|
|
7
|
-
public record FindAll<%=
|
|
7
|
+
public record FindAll<%= aggregateNamePlural %>Query(
|
|
8
8
|
int page,
|
|
9
9
|
int size,
|
|
10
10
|
String sortBy,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
package <%= packageName %>.<%= moduleName %>.application.usecases;
|
|
2
2
|
|
|
3
|
-
import <%= packageName %>.<%= moduleName %>.application.queries.FindAll<%=
|
|
3
|
+
import <%= packageName %>.<%= moduleName %>.application.queries.FindAll<%= aggregateNamePlural %>Query;
|
|
4
4
|
import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %>ResponseDto;
|
|
5
5
|
import <%= packageName %>.<%= moduleName %>.application.mappers.<%= aggregateName %>ApplicationMapper;
|
|
6
6
|
import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregateName %>;
|
|
7
7
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
8
8
|
import <%= packageName %>.shared.application.dtos.PagedResponse;
|
|
9
9
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
10
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
10
11
|
import <%= packageName %>.shared.domain.interfaces.QueryHandler;
|
|
11
|
-
import lombok.extern.slf4j.Slf4j;
|
|
12
12
|
import org.springframework.data.domain.Page;
|
|
13
13
|
import org.springframework.data.domain.PageRequest;
|
|
14
14
|
import org.springframework.data.domain.Pageable;
|
|
@@ -18,17 +18,16 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
18
18
|
import java.util.List;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* FindAll<%=
|
|
22
|
-
* Handles retrieval of all <%=
|
|
21
|
+
* FindAll<%= aggregateNamePlural %>QueryHandler
|
|
22
|
+
* Handles retrieval of all <%= aggregateNamePlural %> (paginated)
|
|
23
23
|
*/
|
|
24
|
-
@Slf4j
|
|
25
24
|
@ApplicationComponent
|
|
26
|
-
public class FindAll<%=
|
|
25
|
+
public class FindAll<%= aggregateNamePlural %>QueryHandler implements QueryHandler<FindAll<%= aggregateNamePlural %>Query, PagedResponse<<%= aggregateName %>ResponseDto>> {
|
|
27
26
|
|
|
28
27
|
private final <%= aggregateName %>Repository repository;
|
|
29
28
|
private final <%= aggregateName %>ApplicationMapper mapper;
|
|
30
29
|
|
|
31
|
-
public FindAll<%=
|
|
30
|
+
public FindAll<%= aggregateNamePlural %>QueryHandler(<%= aggregateName %>Repository repository,
|
|
32
31
|
<%= aggregateName %>ApplicationMapper mapper) {
|
|
33
32
|
this.repository = repository;
|
|
34
33
|
this.mapper = mapper;
|
|
@@ -36,10 +35,8 @@ public class FindAll<%= aggregateName %>sQueryHandler implements QueryHandler<Fi
|
|
|
36
35
|
|
|
37
36
|
@Override
|
|
38
37
|
@Transactional(readOnly = true)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
query.page(), query.size(), query.sortBy(), query.sortDirection());
|
|
42
|
-
|
|
38
|
+
@LogExceptions
|
|
39
|
+
public PagedResponse<<%= aggregateName %>ResponseDto> handle(FindAll<%= aggregateNamePlural %>Query query) {
|
|
43
40
|
Sort sort = Sort.by(Sort.Direction.fromString(query.sortDirection()), query.sortBy());
|
|
44
41
|
Pageable pageable = PageRequest.of(query.page(), query.size(), sort);
|
|
45
42
|
|
|
@@ -48,9 +45,6 @@ public class FindAll<%= aggregateName %>sQueryHandler implements QueryHandler<Fi
|
|
|
48
45
|
.map(mapper::toDto)
|
|
49
46
|
.toList();
|
|
50
47
|
|
|
51
|
-
log.info("FindAll<%= aggregateName %>s retrieved — page={}/{}, totalElements={}",
|
|
52
|
-
page.getNumber() + 1, page.getTotalPages(), page.getTotalElements());
|
|
53
|
-
|
|
54
48
|
return PagedResponse.of(content, page.getNumber(), page.getSize(), page.getTotalElements());
|
|
55
49
|
}
|
|
56
50
|
}
|
|
@@ -3,8 +3,8 @@ package <%= packageName %>.<%= moduleName %>.application.usecases;
|
|
|
3
3
|
import <%= packageName %>.<%= moduleName %>.application.commands.<%= useCaseName %>Command;
|
|
4
4
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
5
5
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
6
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
6
7
|
import <%= packageName %>.shared.domain.interfaces.CommandHandler;
|
|
7
|
-
import lombok.extern.slf4j.Slf4j;
|
|
8
8
|
import org.springframework.transaction.annotation.Transactional;
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -16,7 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
16
16
|
* 2. Call the appropriate domain method (e.g. entity.someBusinessMethod())
|
|
17
17
|
* 3. Persist the result via repository.save(entity)
|
|
18
18
|
*/
|
|
19
|
-
@Slf4j
|
|
20
19
|
@ApplicationComponent
|
|
21
20
|
public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useCaseName %>Command> {
|
|
22
21
|
|
|
@@ -28,9 +27,8 @@ public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useC
|
|
|
28
27
|
|
|
29
28
|
@Override
|
|
30
29
|
@Transactional
|
|
30
|
+
@LogExceptions
|
|
31
31
|
public void handle(<%= useCaseName %>Command command) {
|
|
32
|
-
log.info("Handling <%= useCaseName %>Command: {}", command);
|
|
33
|
-
|
|
34
32
|
// TODO: Implement business logic
|
|
35
33
|
// Example:
|
|
36
34
|
// <%= aggregateName %> entity = repository.findById(command.id())
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
package <%= packageName %>.<%= moduleName %>.application.queries;
|
|
2
2
|
|
|
3
|
+
import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %>ResponseDto;
|
|
3
4
|
import <%= packageName %>.shared.domain.interfaces.Query;
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* <%= useCaseName %>Query
|
|
7
|
-
* TODO: Add the parameters required by this query and
|
|
8
|
+
* TODO: Add the parameters required by this query and adapt the return type if needed.
|
|
8
9
|
*/
|
|
9
10
|
public record <%= useCaseName %>Query(
|
|
10
11
|
// TODO: Replace with actual query parameters
|
|
11
12
|
String id
|
|
12
|
-
) implements Query
|
|
13
|
+
) implements Query<<%= aggregateName %>ResponseDto> {}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
package <%= packageName %>.<%= moduleName %>.application.usecases;
|
|
2
2
|
|
|
3
|
+
import <%= packageName %>.<%= moduleName %>.application.dtos.<%= aggregateName %>ResponseDto;
|
|
3
4
|
import <%= packageName %>.<%= moduleName %>.application.queries.<%= useCaseName %>Query;
|
|
4
5
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
5
6
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
7
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
6
8
|
import <%= packageName %>.shared.domain.interfaces.QueryHandler;
|
|
7
|
-
import lombok.extern.slf4j.Slf4j;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* <%= useCaseName %>QueryHandler
|
|
@@ -15,9 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
15
16
|
* 2. Retrieve data from the repository
|
|
16
17
|
* 3. Map the result to a DTO and return it
|
|
17
18
|
*/
|
|
18
|
-
@Slf4j
|
|
19
19
|
@ApplicationComponent
|
|
20
|
-
public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseName %>Query,
|
|
20
|
+
public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseName %>Query, <%= aggregateName %>ResponseDto> {
|
|
21
21
|
|
|
22
22
|
private final <%= aggregateName %>Repository repository;
|
|
23
23
|
|
|
@@ -26,9 +26,8 @@ public class <%= useCaseName %>QueryHandler implements QueryHandler<<%= useCaseN
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
@Override
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
@LogExceptions
|
|
30
|
+
public <%= aggregateName %>ResponseDto handle(<%= useCaseName %>Query query) {
|
|
32
31
|
// TODO: Implement query logic
|
|
33
32
|
// Example:
|
|
34
33
|
// return repository.findById(query.id())
|
|
@@ -4,6 +4,7 @@ package <%= packageName %>.<%= moduleName %>.application.commands;
|
|
|
4
4
|
<%- imp %>
|
|
5
5
|
<% }); %>
|
|
6
6
|
import <%= packageName %>.shared.domain.interfaces.Command;
|
|
7
|
+
import io.swagger.v3.oas.annotations.media.Schema;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* <%= useCaseName %>Command
|
|
@@ -12,6 +13,9 @@ import <%= packageName %>.shared.domain.interfaces.Command;
|
|
|
12
13
|
public record <%= useCaseName %>Command(
|
|
13
14
|
<%- idType %> id<% if (entityFields && entityFields.length > 0) { %>,<% } %>
|
|
14
15
|
<% (entityFields || []).forEach(function(field, idx) { %>
|
|
16
|
+
<% if (field.schemaExample) { %>
|
|
17
|
+
@Schema(example = "<%= field.schemaExample %>")
|
|
18
|
+
<% } %>
|
|
15
19
|
<%- field.javaType %> <%= field.name %><% if (idx < entityFields.length - 1) { %>,<% } %>
|
|
16
20
|
<% }); %>
|
|
17
21
|
) implements Command {}
|
|
@@ -5,9 +5,9 @@ import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregate
|
|
|
5
5
|
import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= entityName %>;
|
|
6
6
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
7
7
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
8
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
8
9
|
import <%= packageName %>.shared.domain.customExceptions.NotFoundException;
|
|
9
10
|
import <%= packageName %>.shared.domain.interfaces.CommandHandler;
|
|
10
|
-
import lombok.extern.slf4j.Slf4j;
|
|
11
11
|
import org.springframework.transaction.annotation.Transactional;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -16,7 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
16
16
|
*
|
|
17
17
|
* The aggregate root must expose: <%= addMethodName %>(<%= entityName %> item)
|
|
18
18
|
*/
|
|
19
|
-
@Slf4j
|
|
20
19
|
@ApplicationComponent
|
|
21
20
|
public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useCaseName %>Command> {
|
|
22
21
|
|
|
@@ -28,16 +27,13 @@ public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useC
|
|
|
28
27
|
|
|
29
28
|
@Override
|
|
30
29
|
@Transactional
|
|
30
|
+
@LogExceptions
|
|
31
31
|
public void handle(<%= useCaseName %>Command command) {
|
|
32
|
-
log.info("Handling <%= useCaseName %>Command for <%= aggregateName %> id: {}", command.id());
|
|
33
|
-
|
|
34
32
|
<%= aggregateName %> entity = repository.findById(command.id())
|
|
35
33
|
.orElseThrow(() -> new NotFoundException("<%= aggregateName %> not found with id: " + command.id()));
|
|
36
34
|
|
|
37
35
|
<%= entityName %> item = new <%= entityName %>(<% (entityFields || []).forEach(function(field, idx) { %>command.<%= field.name %>()<% if (idx < entityFields.length - 1) { %>, <% } %><% }); %>);
|
|
38
36
|
entity.<%= addMethodName %>(item);
|
|
39
37
|
repository.save(entity);
|
|
40
|
-
|
|
41
|
-
log.info("<%= entityName %> added to <%= aggregateName %> id: {}", command.id());
|
|
42
38
|
}
|
|
43
39
|
}
|
|
@@ -4,9 +4,9 @@ import <%= packageName %>.<%= moduleName %>.application.commands.<%= useCaseName
|
|
|
4
4
|
import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregateName %>;
|
|
5
5
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
6
6
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
7
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
7
8
|
import <%= packageName %>.shared.domain.customExceptions.NotFoundException;
|
|
8
9
|
import <%= packageName %>.shared.domain.interfaces.CommandHandler;
|
|
9
|
-
import lombok.extern.slf4j.Slf4j;
|
|
10
10
|
import org.springframework.transaction.annotation.Transactional;
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
15
15
|
*
|
|
16
16
|
* The aggregate root must expose: <%= removeMethodName %>(String itemId)
|
|
17
17
|
*/
|
|
18
|
-
@Slf4j
|
|
19
18
|
@ApplicationComponent
|
|
20
19
|
public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useCaseName %>Command> {
|
|
21
20
|
|
|
@@ -27,16 +26,12 @@ public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useC
|
|
|
27
26
|
|
|
28
27
|
@Override
|
|
29
28
|
@Transactional
|
|
29
|
+
@LogExceptions
|
|
30
30
|
public void handle(<%= useCaseName %>Command command) {
|
|
31
|
-
log.info("Handling <%= useCaseName %>Command for <%= aggregateName %> id: {}, itemId: {}",
|
|
32
|
-
command.id(), command.itemId());
|
|
33
|
-
|
|
34
31
|
<%= aggregateName %> entity = repository.findById(command.id())
|
|
35
32
|
.orElseThrow(() -> new NotFoundException("<%= aggregateName %> not found with id: " + command.id()));
|
|
36
33
|
|
|
37
34
|
entity.<%= removeMethodName %>(command.itemId());
|
|
38
35
|
repository.save(entity);
|
|
39
|
-
|
|
40
|
-
log.info("<%= entityName %> id: {} removed from <%= aggregateName %> id: {}", command.itemId(), command.id());
|
|
41
36
|
}
|
|
42
37
|
}
|
|
@@ -4,16 +4,15 @@ import <%= packageName %>.<%= moduleName %>.application.commands.<%= useCaseName
|
|
|
4
4
|
import <%= packageName %>.<%= moduleName %>.domain.models.entities.<%= aggregateName %>;
|
|
5
5
|
import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateName %>Repository;
|
|
6
6
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
7
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
7
8
|
import <%= packageName %>.shared.domain.customExceptions.NotFoundException;
|
|
8
9
|
import <%= packageName %>.shared.domain.interfaces.CommandHandler;
|
|
9
|
-
import lombok.extern.slf4j.Slf4j;
|
|
10
10
|
import org.springframework.transaction.annotation.Transactional;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* <%= useCaseName %>CommandHandler
|
|
14
14
|
* Loads the <%= aggregateName %> aggregate and calls entity.<%= domainMethod %>() to execute the transition.
|
|
15
15
|
*/
|
|
16
|
-
@Slf4j
|
|
17
16
|
@ApplicationComponent
|
|
18
17
|
public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useCaseName %>Command> {
|
|
19
18
|
|
|
@@ -25,15 +24,12 @@ public class <%= useCaseName %>CommandHandler implements CommandHandler<<%= useC
|
|
|
25
24
|
|
|
26
25
|
@Override
|
|
27
26
|
@Transactional
|
|
27
|
+
@LogExceptions
|
|
28
28
|
public void handle(<%= useCaseName %>Command command) {
|
|
29
|
-
log.info("Handling <%= useCaseName %>Command for id: {}", command.id());
|
|
30
|
-
|
|
31
29
|
<%= aggregateName %> entity = repository.findById(command.id())
|
|
32
30
|
.orElseThrow(() -> new NotFoundException("<%= aggregateName %> not found with id: " + command.id()));
|
|
33
31
|
|
|
34
32
|
entity.<%= domainMethod %>();
|
|
35
33
|
repository.save(entity);
|
|
36
|
-
|
|
37
|
-
log.info("<%= aggregateName %> id: {} transitioned via <%= domainMethod %>()", command.id());
|
|
38
34
|
}
|
|
39
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package <%= packageName %>.<%= moduleName %>.application.commands;
|
|
2
2
|
|
|
3
3
|
import <%= packageName %>.shared.domain.interfaces.Command;
|
|
4
|
+
import io.swagger.v3.oas.annotations.media.Schema;
|
|
4
5
|
<% if (hasValueObjects) { %>
|
|
5
6
|
import <%= packageName %>.<%= moduleName %>.domain.models.valueObjects.*;
|
|
6
7
|
<% } %>
|
|
@@ -34,6 +35,9 @@ import <%= packageName %>.<%= moduleName %>.application.dtos.Create<%= rel.targe
|
|
|
34
35
|
public record Update<%= aggregateName %>Command(
|
|
35
36
|
<%- idType %> id<% if (commandFields && commandFields.length > 0) { %>,<% } %>
|
|
36
37
|
<% commandFields.forEach((field, idx) => { %>
|
|
38
|
+
<% if (field.schemaExample) { %>
|
|
39
|
+
@Schema(example = "<%= field.schemaExample %>")
|
|
40
|
+
<% } %>
|
|
37
41
|
<%- field.javaType %> <%= field.name %><% if (idx < commandFields.length - 1 || (oneToManyRelationships && oneToManyRelationships.length > 0) || (oneToOneRelationships && oneToOneRelationships.length > 0)) { %>,<% } %>
|
|
38
42
|
<% }); %>
|
|
39
43
|
<% if (oneToManyRelationships && oneToManyRelationships.length > 0) { %>
|
|
@@ -7,9 +7,9 @@ import <%= packageName %>.<%= moduleName %>.domain.repositories.<%= aggregateNam
|
|
|
7
7
|
import <%= packageName %>.<%= moduleName %>.application.mappers.<%= aggregateName %>ApplicationMapper;
|
|
8
8
|
<% } %>
|
|
9
9
|
import <%= packageName %>.shared.domain.annotations.ApplicationComponent;
|
|
10
|
+
import <%= packageName %>.shared.domain.annotations.LogExceptions;
|
|
10
11
|
import <%= packageName %>.shared.domain.customExceptions.NotFoundException;
|
|
11
12
|
import <%= packageName %>.shared.domain.interfaces.CommandHandler;
|
|
12
|
-
import lombok.extern.slf4j.Slf4j;
|
|
13
13
|
import org.springframework.transaction.annotation.Transactional;
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -20,7 +20,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
20
20
|
* Non-null command fields override the current value; null fields are preserved
|
|
21
21
|
* from the loaded entity. No setters are required on the domain entity.
|
|
22
22
|
*/
|
|
23
|
-
@Slf4j
|
|
24
23
|
@ApplicationComponent
|
|
25
24
|
public class Update<%= aggregateName %>CommandHandler implements CommandHandler<Update<%= aggregateName %>Command> {
|
|
26
25
|
|
|
@@ -42,9 +41,8 @@ public class Update<%= aggregateName %>CommandHandler implements CommandHandler<
|
|
|
42
41
|
|
|
43
42
|
@Override
|
|
44
43
|
@Transactional
|
|
44
|
+
@LogExceptions
|
|
45
45
|
public void handle(Update<%= aggregateName %>Command command) {
|
|
46
|
-
log.info("Handling Update<%= aggregateName %>Command for id: {}", command.id());
|
|
47
|
-
|
|
48
46
|
<%= aggregateName %> existing = repository
|
|
49
47
|
.findById(command.id())
|
|
50
48
|
.orElseThrow(() -> new NotFoundException("<%= aggregateName %> not found with id: " + command.id()));
|
|
@@ -100,6 +98,5 @@ public class Update<%= aggregateName %>CommandHandler implements CommandHandler<
|
|
|
100
98
|
<% } %>
|
|
101
99
|
|
|
102
100
|
repository.save(updated);
|
|
103
|
-
log.info("<%= aggregateName %> updated successfully with id: {}", command.id());
|
|
104
101
|
}
|
|
105
102
|
}
|