diff --git a/skill-tree/src/main/java/com/RDS/skilltree/models/Skill.java b/skill-tree/src/main/java/com/RDS/skilltree/models/Skill.java index 19e04ff..ef0ae32 100644 --- a/skill-tree/src/main/java/com/RDS/skilltree/models/Skill.java +++ b/skill-tree/src/main/java/com/RDS/skilltree/models/Skill.java @@ -25,17 +25,9 @@ public class Skill extends TrackedProperties { @Enumerated(value = EnumType.STRING) private SkillTypeEnum type = SkillTypeEnum.ATOMIC; - // @ManyToOne - // @JoinColumn(name = "created_by", nullable = false) - // private RdsUserViewModel createdBy; - @Column(name = "created_by", nullable = false) private String createdBy; - // @ManyToOne - // @JoinColumn(name = "updated_by") - // private RdsUserViewModel updatedBy; - @Column(name = "updated_by") private String updateBy; } diff --git a/skill-tree/src/main/java/com/RDS/skilltree/services/EndorsementServiceImplementation.java b/skill-tree/src/main/java/com/RDS/skilltree/services/EndorsementServiceImplementation.java index f3456ef..0bb701d 100644 --- a/skill-tree/src/main/java/com/RDS/skilltree/services/EndorsementServiceImplementation.java +++ b/skill-tree/src/main/java/com/RDS/skilltree/services/EndorsementServiceImplementation.java @@ -12,7 +12,10 @@ import com.RDS.skilltree.repositories.SkillRepository; import com.RDS.skilltree.repositories.UserSkillRepository; import com.RDS.skilltree.services.external.RdsService; -import com.RDS.skilltree.viewmodels.*; +import com.RDS.skilltree.viewmodels.CreateEndorsementViewModel; +import com.RDS.skilltree.viewmodels.EndorsementViewModel; +import com.RDS.skilltree.viewmodels.UpdateEndorsementViewModel; +import com.RDS.skilltree.viewmodels.UserViewModel; import java.util.*; import lombok.RequiredArgsConstructor; import org.slf4j.Logger; @@ -31,10 +34,6 @@ public class EndorsementServiceImplementation implements EndorsementService { @Override public List getAllEndorsementsBySkillId(Integer skillId) { - // endorsements.forEach(endorsement -> { - // RdsGetUserDetailsResDto userDetails = rdsService.getUserDetails(endorsement.) - // }); - List endorsements = endorsementRepository.findBySkillId(skillId); // store all users data that are a part of this request @@ -57,15 +56,8 @@ public List getAllEndorsementsBySkillId(Integer skillId) { userDetails.put(endorserId, UserViewModel.toViewModel(endorserDetails.getUser())); } - UserViewModel endorseDetails = userDetails.get(endorseId); - UserViewModel endorserDetails = userDetails.get(endorserId); - - return new EndorsementViewModel( - endorsement.getId(), - SkillViewModel.toViewModel(endorsement.getSkill()), - endorseDetails, - endorserDetails, - endorsement.getMessage()); + return EndorsementViewModel.toViewModel( + endorsement, userDetails.get(endorseId), userDetails.get(endorserId)); }) .toList(); } diff --git a/skill-tree/src/main/java/com/RDS/skilltree/services/SkillServiceImplementation.java b/skill-tree/src/main/java/com/RDS/skilltree/services/SkillServiceImplementation.java index 439f612..459ea75 100644 --- a/skill-tree/src/main/java/com/RDS/skilltree/services/SkillServiceImplementation.java +++ b/skill-tree/src/main/java/com/RDS/skilltree/services/SkillServiceImplementation.java @@ -70,11 +70,6 @@ public SkillRequestsDto getAllRequests() { endorsements.forEach( endorsement -> { - // String endorserId = - // endorsement.getEndorser().getId(); - // String endorserRdsUserId = - // endorsement.getEndorser().getId(); - String endorserId = endorsement.getEndorserId(); if (!userDetails.containsKey(endorserId)) { diff --git a/skill-tree/src/main/java/com/RDS/skilltree/viewmodels/EndorsementViewModel.java b/skill-tree/src/main/java/com/RDS/skilltree/viewmodels/EndorsementViewModel.java index 35eabe8..bfa7d1a 100644 --- a/skill-tree/src/main/java/com/RDS/skilltree/viewmodels/EndorsementViewModel.java +++ b/skill-tree/src/main/java/com/RDS/skilltree/viewmodels/EndorsementViewModel.java @@ -1,13 +1,13 @@ package com.RDS.skilltree.viewmodels; import com.RDS.skilltree.models.Endorsement; -import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.Setter; @Getter @Setter -@AllArgsConstructor +@Builder public class EndorsementViewModel { private Integer id; private SkillViewModel skill; @@ -17,18 +17,13 @@ public class EndorsementViewModel { public static EndorsementViewModel toViewModel( Endorsement endorsement, UserViewModel endorse, UserViewModel endorser) { - // EndorsementViewModel viewModel = new EndorsementViewModel(); - // BeanUtils.copyProperties(endorsement, viewModel); - // viewModel.setSkill(SkillViewModel.toViewModel(endorsement.getSkill())); - // viewModel.setEndorse(endorse); - // viewModel.setEndorser(endorser); - - return new EndorsementViewModel( - endorsement.getId(), - SkillViewModel.toViewModel(endorsement.getSkill()), - endorse, - endorser, - endorsement.getMessage()); + return EndorsementViewModel.builder() + .id(endorsement.getId()) + .skill(SkillViewModel.toViewModel((endorsement.getSkill()))) + .endorse(endorse) + .endorser(endorser) + .message(endorsement.getMessage()) + .build(); } }