sprygen add-entity
Accelerate feature development. Inside your Sprygen project, run sprygen add-entity <Name> to instantly generate the full persistence and API layer for a new domain object.
Process
The CLI prompts you to define fields iteratively:
- Field Name: e.g.,
title,price - Field Type: String, Integer, Double, Boolean, LocalDate, etc.
- Constraints: Nullable, Unique
What gets generated?
- Entity:
Product.javaextendsAbstractAuditingEntityfor auto-timestamps. - Repository:
ProductRepository.javaequipped withJpaSpecificationExecutor. - Specification Builder:
ProductSpecification.javafor dynamic query building. - DTOs: Request/Response payloads +
ProductFilter.java. - Mapper:
ProductMapper.javautilizing MapStruct. - Service:
ProductService.javahandling core business logic, mapping, and returningPage<ProductDto>. - Controller:
ProductController.javawith complete REST CRUD endpoints, auto-wired for pagination and filtering. - Test:
ProductControllerTest.javaintegration test stub. - Migration:
V2__create_product_table.sqlFlyway script (if the project has Flyway enabled).
Usage:
cd my-awesome-backend
sprygen add-entity Product