Spaces:
Running
Running
okay can you change the output on the repository to be CrudRepository<> and inside that instad of long take the type from the field with name id
Browse files
script.js
CHANGED
|
@@ -128,10 +128,18 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 128 |
// Generate Repository
|
| 129 |
let repositoryCode = `package com.example.repository;\n\n`;
|
| 130 |
repositoryCode += `import com.example.entity.${className};\n`;
|
| 131 |
-
repositoryCode += `import org.springframework.data.
|
| 132 |
repositoryCode += `import org.springframework.stereotype.Repository;\n\n`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
repositoryCode += `@Repository\n`;
|
| 134 |
-
repositoryCode += `public interface ${className}Repository extends
|
| 135 |
repositoryCode += `}\n`;
|
| 136 |
// Generate Service
|
| 137 |
let serviceCode = `package com.example.accessingdatajpa;\n\n`;
|
|
|
|
| 128 |
// Generate Repository
|
| 129 |
let repositoryCode = `package com.example.repository;\n\n`;
|
| 130 |
repositoryCode += `import com.example.entity.${className};\n`;
|
| 131 |
+
repositoryCode += `import org.springframework.data.repository.CrudRepository;\n`;
|
| 132 |
repositoryCode += `import org.springframework.stereotype.Repository;\n\n`;
|
| 133 |
+
|
| 134 |
+
// Find ID type (default to Long if not found)
|
| 135 |
+
let idType = 'Long';
|
| 136 |
+
const idField = fields.find(f => f.name.toLowerCase() === 'id');
|
| 137 |
+
if (idField) {
|
| 138 |
+
idType = idField.type;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
repositoryCode += `@Repository\n`;
|
| 142 |
+
repositoryCode += `public interface ${className}Repository extends CrudRepository<${className}, ${idType}> {\n\n`;
|
| 143 |
repositoryCode += `}\n`;
|
| 144 |
// Generate Service
|
| 145 |
let serviceCode = `package com.example.accessingdatajpa;\n\n`;
|