feat: Add Dynamic REST Controller and Service for PySpringModel #1
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces dynamic RESTful API support for
PySpringModelentities, significantly simplifying CRUD operations and resource management. By incorporating aPySpringModelRestControllerand aPySpringModelRestService, the framework now provides an extensible mechanism to handle model-based API endpoints dynamically.Key Changes
Controller:
PySpringModelRestController, which dynamically registers CRUD routes for all models registered with the framework.GET,POST,PUT, andDELETEfor single and multiple records.Service:
PySpringModelRestServiceto encapsulate database operations forPySpringModelentities.Provider Update:
PySpringModelProviderto includePySpringModelRestControllerandPySpringModelRestServiceas injectable components.Dynamic Routing:
Motivation
The new REST capabilities enhance the framework's usability, allowing developers to quickly expose APIs for their models without repetitive manual configuration. This change aligns with the framework's goal of providing seamless and intuitive integrations.
Example Usage
Once a model is registered with the framework, the REST controller will automatically expose endpoints such as:
GET /{model_name}/{id}: Fetch a single record by ID.POST /{model_name}: Create a new record.PUT /{model_name}/{id}: Update an existing record.DELETE /{model_name}/{id}: Delete a record by ID.How to Test
PySpringModelentity in the framework.Checklist
PySpringModelRestControllerfor dynamic route registration.PySpringModelRestServicefor CRUD logic.PySpringModelProviderto inject new components.Related Issues
None.
Additional Notes
This update sets the foundation for further extensions, such as advanced query support, custom validation, and role-based access control for model APIs.