Skip to content

Refactor/mappers and dtos#32

Merged
luislh-dev merged 7 commits intomasterfrom
refactor/mappers-and-dtos
Jul 4, 2025
Merged

Refactor/mappers and dtos#32
luislh-dev merged 7 commits intomasterfrom
refactor/mappers-and-dtos

Conversation

@luislh-dev
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings July 4, 2025 02:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR consolidates boilerplate by switching many classes from individual Lombok @Getter/@Setter to @Data, removes outdated DTOs and lifecycle callbacks, and introduces a new PersonBasicDTO with corresponding mapper and service/controller updates.

  • Replaced @Getter/@Setter with @Data in entity and DTO classes
  • Removed manual @PrePersist/@PreUpdate methods in favor of Hibernate timestamp annotations
  • Added PersonBasicDTO and updated service, controller, and mapper to return it instead of the projection
  • Deleted unused create-request DTOs

Reviewed Changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
UserEntity.java Replaced Lombok getters/setters with @Data
RecordDetailCreateRequestDTO.java Switched to @Data, but left unused imports
PeopleDtoMapper.java Added toPersonBasicDto mapping method
PeopleServiceImpl.java Updated findBasicById to map projection to PersonBasicDTO
PeopleController.java Changed endpoint to return PersonBasicDTO
Other entity/DTO files Similar Lombok annotation replacements and timestamp updates
Comments suppressed due to low confidence (2)

src/main/java/com/historialplus/historialplus/internal/people/service/PeopleServiceImpl.java:128

  • Consider adding a unit test for findBasicById to verify the projection-to-DTO mapping, especially date and enum transformations in toPersonBasicDto.
        return repository.findBasicById(id).map(PeopleDtoMapper::toPersonBasicDto);

src/main/java/com/historialplus/historialplus/internal/user/entites/UserEntity.java:31

  • [nitpick] Consider avoiding @Data on JPA entities; it generates equals/hashCode including all fields, which can cause issues with lazy associations—prefer @Getter/@Setter plus a tailored @EqualsAndHashCode(onlyExplicitlyIncluded = true).
@Data

Comment on lines 8 to 9
import lombok.Getter;
import lombok.Setter;
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused lombok.Getter and lombok.Setter imports now that @Data is used to avoid stale imports.

Suggested change
import lombok.Getter;
import lombok.Setter;

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tener en cuenta que el FileDTO usar el getter y setter

.name(input.getName())
.paternalSurname(input.getPaternalSurname())
.maternalSurname(input.getMaternalSurname())
.birthdate(input.getBirthdate())
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DTO birthdate is a String but input.getBirthdate() likely returns a Date or LocalDate—add explicit formatting or conversion to avoid a type mismatch at runtime.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

@luislh-dev luislh-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️

Comment on lines 8 to 9
import lombok.Getter;
import lombok.Setter;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tener en cuenta que el FileDTO usar el getter y setter

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jul 4, 2025

@luislh-dev luislh-dev merged commit b35f0ee into master Jul 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants