@simplix-boot/cli 0.0.0-stage → 2.0.0
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/LICENSE +25 -0
- package/LICENSE_KO +28 -0
- package/README.md +144 -2
- package/bin/simplix-boot.js +4 -0
- package/package.json +44 -4
- package/src/cli.js +103 -0
- package/src/commands/config.js +129 -0
- package/src/commands/generate.js +291 -0
- package/src/commands/generated.js +125 -0
- package/src/commands/init.js +41 -0
- package/src/commands/promote.js +172 -0
- package/src/commands/templates.js +100 -0
- package/src/commands/version.js +134 -0
- package/src/lib/analysis/fields.js +217 -0
- package/src/lib/analysis/imports.js +76 -0
- package/src/lib/analysis/structure.js +193 -0
- package/src/lib/analysis/types.js +94 -0
- package/src/lib/args.js +69 -0
- package/src/lib/comment-extractor.js +141 -0
- package/src/lib/config/fields.js +321 -0
- package/src/lib/config/parents.js +108 -0
- package/src/lib/config/paths.js +156 -0
- package/src/lib/config/yml.js +61 -0
- package/src/lib/console.js +70 -0
- package/src/lib/controller-name.js +33 -0
- package/src/lib/entity-analyzer.js +49 -0
- package/src/lib/entity-type-resolver.js +80 -0
- package/src/lib/entity-type.js +35 -0
- package/src/lib/errors.js +17 -0
- package/src/lib/export-config.js +74 -0
- package/src/lib/file-utils.js +77 -0
- package/src/lib/generate/file-plan.js +155 -0
- package/src/lib/generate/search-fields.js +111 -0
- package/src/lib/generate/settings.js +111 -0
- package/src/lib/generate/support-classes.js +47 -0
- package/src/lib/generate/template-vars.js +183 -0
- package/src/lib/git-utils.js +18 -0
- package/src/lib/name-field.js +42 -0
- package/src/lib/project.js +121 -0
- package/src/lib/promote-files.js +132 -0
- package/src/lib/rendered-output.js +13 -0
- package/src/lib/search-operators.js +87 -0
- package/src/lib/templates.js +50 -0
- package/src/lib/tracked-render.js +200 -0
- package/src/lib/version-check.js +194 -0
- package/src/lib/version-utils.js +89 -0
- package/templates/controller/rest/EntityRestController.java.template +517 -0
- package/templates/controller/web/EntityWebController.java.template +211 -0
- package/templates/dto/EntityDTOs.java.template +981 -0
- package/templates/repository/EntityRepository.java.template +78 -0
- package/templates/service/EntityService.java.template +790 -0
- package/templates/service/EntityTreeService.java.template +352 -0
- package/templates/test/EntityServiceTest.java.template +937 -0
- package/templates/test/EntityTreeServiceTest.java.template +842 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
package <%= packagePaths['repository'] %>;
|
|
2
|
+
|
|
3
|
+
import <%= entityPackage %>.<%= entityName %>;<%
|
|
4
|
+
if (hasEmbeddedId) { %>
|
|
5
|
+
import <%= entityPackage %>.<%= entityName %>.<%= embeddedIdType %>;<%
|
|
6
|
+
} %><%
|
|
7
|
+
// Add necessary imports
|
|
8
|
+
if (importsArray && importsArray.length > 0) {
|
|
9
|
+
importsArray.forEach(importPath => { %>
|
|
10
|
+
import <%= importPath %>;<%
|
|
11
|
+
});
|
|
12
|
+
} %>
|
|
13
|
+
import dev.simplecore.simplix.core.repository.SimpliXBaseRepository;
|
|
14
|
+
import org.springframework.stereotype.Repository;<%
|
|
15
|
+
// Add Query and Param imports if sortOrderConfig is present
|
|
16
|
+
if (ymlConfig && ymlConfig.sortOrderConfig && ymlConfig.sortOrderConfig.autoIncrement) { %>
|
|
17
|
+
import org.springframework.data.jpa.repository.Query;<%
|
|
18
|
+
if (ymlConfig.sortOrderConfig.scopeFields && ymlConfig.sortOrderConfig.scopeFields.length > 0) { %>
|
|
19
|
+
import org.springframework.data.repository.query.Param;<%
|
|
20
|
+
}
|
|
21
|
+
} %>
|
|
22
|
+
|
|
23
|
+
<%
|
|
24
|
+
if (hasEmbeddedId) { %>
|
|
25
|
+
/**
|
|
26
|
+
* Note: This entity uses an embedded ID (composite key).
|
|
27
|
+
* When creating query methods, use path notation for accessing embedded ID fields.
|
|
28
|
+
*
|
|
29
|
+
* For example, with your embedded ID class <%= embeddedIdType %>:
|
|
30
|
+
* - findBy<%= embeddedFieldCapitalized %>(<%= propType1 %> <%= embeddedIdPropertyName1 %>)<%
|
|
31
|
+
if (embeddedIdPropertyName2) { %>
|
|
32
|
+
* - findBy<%= embeddedField2Capitalized %>(<%= propType2 %> <%= embeddedIdPropertyName2 %>)<%
|
|
33
|
+
} %>
|
|
34
|
+
* - findBy<%= embeddedFieldCapitalized %>And<%= otherFieldCapitalized %>(<%= propType1 %> <%= embeddedIdPropertyName1 %>, String <%= otherEntityField %>)
|
|
35
|
+
*/
|
|
36
|
+
<% } %>
|
|
37
|
+
|
|
38
|
+
@Repository
|
|
39
|
+
public interface <%= entityName %>Repository extends SimpliXBaseRepository<<%= entityName %>, <%= idType %>> {
|
|
40
|
+
<%
|
|
41
|
+
// Generate findMaxSortOrder method if sortOrderConfig is present
|
|
42
|
+
if (ymlConfig && ymlConfig.sortOrderConfig && ymlConfig.sortOrderConfig.autoIncrement) {
|
|
43
|
+
const field = ymlConfig.sortOrderConfig.field;
|
|
44
|
+
const upperField = field.charAt(0).toUpperCase() + field.slice(1);
|
|
45
|
+
const scopeFields = ymlConfig.sortOrderConfig.scopeFields || [];
|
|
46
|
+
|
|
47
|
+
if (scopeFields.length === 0) {
|
|
48
|
+
// Global scope - no parameters %>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Finds the maximum <%= field %> value across all <%= entityName %> entities.
|
|
52
|
+
* Used for auto-incrementing <%= field %> when creating new entities.
|
|
53
|
+
*
|
|
54
|
+
* @return The maximum <%= field %> value, or 0 if no entities exist
|
|
55
|
+
*/
|
|
56
|
+
@Query("SELECT COALESCE(MAX(e.<%= field %>), 0) FROM <%= entityName %> e")
|
|
57
|
+
Integer findMax<%= upperField %>();
|
|
58
|
+
<% } else {
|
|
59
|
+
// Scoped - with parameters
|
|
60
|
+
const methodSuffix = scopeFields.map(f => f.charAt(0).toUpperCase() + f.slice(1)).join('And');
|
|
61
|
+
const params = scopeFields.map(f => `@Param("${f}") String ${f}`).join(', ');
|
|
62
|
+
const whereClause = scopeFields.map(f => `e.${f} = :${f}`).join(' AND ');
|
|
63
|
+
%>
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Finds the maximum <%= field %> value scoped by <%= scopeFields.join(', ') %>.
|
|
67
|
+
* Used for auto-incrementing <%= field %> when creating new entities.
|
|
68
|
+
*
|
|
69
|
+
<% scopeFields.forEach(f => { %>
|
|
70
|
+
* @param <%= f %> The scope parameter for filtering
|
|
71
|
+
<% }); %>
|
|
72
|
+
* @return The maximum <%= field %> value within the scope, or 0 if none exist
|
|
73
|
+
*/
|
|
74
|
+
@Query("SELECT COALESCE(MAX(e.<%= field %>), 0) FROM <%= entityName %> e WHERE <%= whereClause %>")
|
|
75
|
+
Integer findMax<%= upperField %>By<%= methodSuffix %>(<%= params %>);
|
|
76
|
+
<% }
|
|
77
|
+
} %>
|
|
78
|
+
}
|