PRA#02_Spring-Boot-LuisLopez-CreateUserAPIRest - #8
Open
Luiscuatro wants to merge 13 commits into
Open
Conversation
…plication.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary of Changes in the Repository: PronunciationAppBack
1. User Entity Added
The
Userentity was introduced to define the basic structure for storing user data. It includes fields likeid,name,email,password, andisActive. This seemed like a reasonable starting point for managing users.2. UserRepository Implemented
A repository class (
UserRepository) was created to interact with the database. It provides basic methods such asfindAll,findById,save, anddeleteById. At this point, it was mainly focused on covering the core operations.3. UserController Created
A controller (
UserController) was developed to handle HTTP requests for user operations. This included methods for creating, retrieving, updating, and deleting users. The implementation was basic, but it covered the necessary functionality.4. H2 In-Memory Database Configured
The initial setup of the database was done using the H2 in-memory configuration, which seemed easier to work with during development. The local database setup was commented out to keep things simple at this stage.
5. Syntax Fixes
There were a few issues that needed fixing:
@GetMappingannotation of thegetUserByIdmethod inUserController.@PostMappingannotation were adjusted to ensure proper functionality.6. Annotation
@TableAddedThe
@Tableannotation was added to theUserentity to ensure it mapped correctly to theAPP_USERStable in the database. This was necessary to avoid any issues with naming.7. H2 Database Setup Adjustments
Initially, the Hibernate
ddl-autoproperty was set tocreateto let the database schema be generated automatically. Later, it was changed toupdateso that the database would retain data without resetting it every time the application restarted.8. Getter and Setter for
isActiveFixedThe
isActivefield in theUserentity wasn’t working properly at first. After some adjustments, the getter (getActive) and setter (setActive) methods were implemented correctly.9. Service Layer Implemented
A
UserServiceclass was introduced as a layer between the controller and the repository. It helped organize the business logic better and simplified the controller methods.10. Controller Refactored
The
UserControllerwas updated to:UserServicefor all operations instead of interacting with the repository directly.11. H2 Local Database Configured
The setup was updated to switch from the in-memory database to a local H2 database. This allows data to persist across application restarts, which feels more practical.
12. Endpoints Tested in Postman
The API endpoints were tested in Postman to ensure they worked correctly. This included testing
GET,POST,PUT, andDELETEoperations. The response codes and functionality were verified during the process.