-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build a
skills/requests
api & create a rds service to get user deta…
…ils (#139) * create a model to store user_skill and add remove unused columns in users and skills model * create a model to store user_skill and add/remove unused columns in users and skills model * change id to integer * check if a skill already exists before creating one, make `updated_at` optional in TrackedProperties * remove unit and integration test and remove skill service & skill service implementation * add todo * rename SkillType to SkillTypeEnum * set logging level debug in application-dev instead of application * add todo * remove endorsements list * add reference to user table in skills modal * Build api to create a new endorsement * create api to update an endorsement * remove unused files * remove unused code in endorsement controller * chagne import order * change the skills project structure to match the new one * rename exceptions folder to small case exceptions and create user not found and skill already exists exceptions * create enums folder and move skill type enum to the folder * rename Conifg to config, move generic response and jwtAuthenticationFilter to utils * add api to get all endorsements for a skill using skill id in skillsapi * remove skills package * fix build error * move api to create a endorsement to the new folder structure * add api to update endorsement in apis/endorsements api and remove old Endorsement folder * move health check api to the api folder & metric service inside the services folder * fix formatting * create annotation and aspect to handle authorized roles to an api * add authorizred roles annotation to skillsapi & endorsementsapi class * set authorized role for creating a skill to only superuser * fix formatting * create api to get all skill requests * apply spotless * set endorsement id * run spotlesscheck * remove comments * add super user role check in skills/requests api * build the `skill/requests` api to get all skill requests and their endorsements * fix duplicate data issue when getting all skill requests * improve comment * change data to requests in SkillRequestDto * fix formatting * fix wrong id being set in endorserDetails * fix formatting error * change yoe to float from int in RdsUserViewModel * add try catch block to getUserDetails * add try catch and create a constructor in SkillRequestViewModel
- Loading branch information
Showing
18 changed files
with
329 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
13 changes: 13 additions & 0 deletions
13
skill-tree/src/main/java/com/RDS/skilltree/config/AppConfig.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.RDS.skilltree.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Configuration | ||
public class AppConfig { | ||
@Bean | ||
public RestTemplate restTemplate() { | ||
return new RestTemplate(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
skill-tree/src/main/java/com/RDS/skilltree/dtos/SkillRequestsDto.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.RDS.skilltree.dtos; | ||
|
||
import com.RDS.skilltree.viewmodels.SkillRequestViewModel; | ||
import com.RDS.skilltree.viewmodels.UserViewModel; | ||
import java.util.List; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
public class SkillRequestsDto { | ||
private List<SkillRequestViewModel> requests; | ||
private List<UserViewModel> users; | ||
|
||
public static SkillRequestsDto toDto( | ||
List<SkillRequestViewModel> skillRequests, List<UserViewModel> users) { | ||
SkillRequestsDto skillRequestsDto = new SkillRequestsDto(); | ||
skillRequestsDto.setRequests(skillRequests); | ||
skillRequestsDto.setUsers(users); | ||
|
||
return skillRequestsDto; | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
skill-tree/src/main/java/com/RDS/skilltree/repositories/EndorsementRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.RDS.skilltree.repositories; | ||
|
||
import com.RDS.skilltree.models.Endorsement; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface EndorsementRepository extends JpaRepository<Endorsement, Integer> { | ||
Page<Endorsement> findBySkillId(Integer skillId, Pageable pageable); | ||
List<Endorsement> findBySkillId(Integer skillId); | ||
|
||
List<Endorsement> findByEndorseIdAndSkillId(String endorseId, Integer skillId); | ||
} |
12 changes: 12 additions & 0 deletions
12
skill-tree/src/main/java/com/RDS/skilltree/repositories/UserSkillRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.RDS.skilltree.repositories; | ||
|
||
import com.RDS.skilltree.User.UserSkillStatusEnum; | ||
import com.RDS.skilltree.User.UserSkillsModel; | ||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserSkillRepository extends JpaRepository<UserSkillsModel, Integer> { | ||
List<UserSkillsModel> findByStatus(UserSkillStatusEnum status); | ||
|
||
List<UserSkillsModel> findByUserIdAndSkillId(String userId, Integer skillId); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
skill-tree/src/main/java/com/RDS/skilltree/services/external/RdsService.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.RDS.skilltree.services.external; | ||
|
||
import com.RDS.skilltree.viewmodels.RdsUserViewModel; | ||
|
||
public interface RdsService { | ||
RdsUserViewModel getUserDetails(String id); | ||
} |
32 changes: 32 additions & 0 deletions
32
skill-tree/src/main/java/com/RDS/skilltree/services/external/RdsServiceImplementation.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.RDS.skilltree.services.external; | ||
|
||
import com.RDS.skilltree.viewmodels.RdsUserViewModel; | ||
import lombok.RequiredArgsConstructor; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestClientException; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RdsServiceImplementation implements RdsService { | ||
private static final Logger log = LoggerFactory.getLogger(RdsServiceImplementation.class); | ||
private final RestTemplate restTemplate; | ||
|
||
@Value("${rds.backendBaseUrl}") | ||
private String rdsBackendBaseUrl; | ||
|
||
@Override | ||
public RdsUserViewModel getUserDetails(String id) { | ||
String url = rdsBackendBaseUrl + "/users?id=" + id; | ||
|
||
try { | ||
return restTemplate.getForObject(url, RdsUserViewModel.class); | ||
} catch (RestClientException error) { | ||
log.error("Error calling url: {}, Error : {}", url, error.getMessage()); | ||
throw new RuntimeException("Failed to communicate with RDS backend"); | ||
} | ||
} | ||
} |
Oops, something went wrong.