-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'users-command-implementation' of github.com:Ahmad45123/…
…workup into users-command-implementation
- Loading branch information
Showing
71 changed files
with
1,266 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED |
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
36 changes: 36 additions & 0 deletions
36
services/users/src/main/java/com/workup/users/commands/AddFreelancerAchievementCommand.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,36 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.AddFreelancerAchievementRequest; | ||
import com.workup.shared.commands.users.responses.AddFreelancerAchievementResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Achievement; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.Optional; | ||
|
||
public class AddFreelancerAchievementCommand | ||
extends UserCommand<AddFreelancerAchievementRequest, AddFreelancerAchievementResponse> { | ||
@Override | ||
public AddFreelancerAchievementResponse Run(AddFreelancerAchievementRequest request) { | ||
Optional<Freelancer> freelancerOptional = | ||
freelancerRepository.findById(request.getFreelancer_id()); | ||
if (freelancerOptional.isEmpty()) | ||
return AddFreelancerAchievementResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
Achievement newAchievement = | ||
Achievement.builder() | ||
.withAchievement_description(request.getAchievement_description()) | ||
.withAchievement_name(request.getAchievement_name()) | ||
.withAward_date(request.getAward_date()) | ||
.withAwarded_by(request.getAwarded_by()) | ||
.build(); | ||
newAchievement = achievementRepository.save(newAchievement); | ||
freelancer.getAchievements().add(newAchievement); | ||
freelancerRepository.save(freelancer); | ||
return AddFreelancerAchievementResponse.builder() | ||
.withStatusCode(HttpStatusCode.CREATED) | ||
.build(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
services/users/src/main/java/com/workup/users/commands/AddFreelancerEducationCommand.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,39 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.AddFreelancerEducationRequest; | ||
import com.workup.shared.commands.users.responses.AddFreelancerEducationResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Education; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.Optional; | ||
|
||
public class AddFreelancerEducationCommand | ||
extends UserCommand<AddFreelancerEducationRequest, AddFreelancerEducationResponse> { | ||
|
||
@Override | ||
public AddFreelancerEducationResponse Run(AddFreelancerEducationRequest request) { | ||
Optional<Freelancer> freelancerOptional = | ||
freelancerRepository.findById(request.getFreelancer_id()); | ||
if (freelancerOptional.isEmpty()) | ||
return AddFreelancerEducationResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
Education newEducation = | ||
Education.builder() | ||
.withCity(request.getCity()) | ||
.withDegree(request.getDegree()) | ||
.withEducation_description(request.getEducation_description()) | ||
.withEducation_start_date(request.getEducation_start_date()) | ||
.withEnd_date(request.getEnd_date()) | ||
.withGrade(request.getGrade()) | ||
.withMajor(request.getMajor()) | ||
.withSchool_name(request.getSchool_name()) | ||
.build(); | ||
newEducation = educationRepository.save(newEducation); | ||
freelancer.getEducations().add(newEducation); | ||
freelancerRepository.save(freelancer); | ||
return AddFreelancerEducationResponse.builder().withStatusCode(HttpStatusCode.CREATED).build(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
services/users/src/main/java/com/workup/users/commands/AddFreelancerExperienceCommand.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,36 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.AddFreelancerExperienceRequest; | ||
import com.workup.shared.commands.users.responses.AddFreelancerExperienceResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Experience; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.Optional; | ||
|
||
public class AddFreelancerExperienceCommand | ||
extends UserCommand<AddFreelancerExperienceRequest, AddFreelancerExperienceResponse> { | ||
@Override | ||
public AddFreelancerExperienceResponse Run(AddFreelancerExperienceRequest request) { | ||
Optional<Freelancer> freelancerOptional = | ||
freelancerRepository.findById(request.getFreelancerId()); | ||
if (freelancerOptional.isEmpty()) | ||
return AddFreelancerExperienceResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
Experience newExperience = | ||
Experience.builder() | ||
.withExperience_description(request.getExperience_description()) | ||
.withCity(request.getCity()) | ||
.withCompany_name(request.getCompany_name()) | ||
.withEmployment_end(request.getEmployment_end()) | ||
.withEmployment_start(request.getEmployment_start()) | ||
.withJob_title(request.getJob_title()) | ||
.build(); | ||
newExperience = experienceRepository.save(newExperience); | ||
freelancer.getExperiences().add(newExperience); | ||
freelancerRepository.save(freelancer); | ||
return AddFreelancerExperienceResponse.builder().withStatusCode(HttpStatusCode.CREATED).build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
services/users/src/main/java/com/workup/users/commands/AddFreelancerLanguageCommand.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,25 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.AddFreelancerLanguageRequest; | ||
import com.workup.shared.commands.users.responses.AddFreelancerLanguageResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.Optional; | ||
|
||
public class AddFreelancerLanguageCommand | ||
extends UserCommand<AddFreelancerLanguageRequest, AddFreelancerLanguageResponse> { | ||
|
||
@Override | ||
public AddFreelancerLanguageResponse Run(AddFreelancerLanguageRequest request) { | ||
Optional<Freelancer> freelancerOptional = freelancerRepository.findById(request.getUser_id()); | ||
if (freelancerOptional.isEmpty()) | ||
return AddFreelancerLanguageResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
freelancer.getLanguages().add(request.getNewLanguage()); | ||
freelancerRepository.save(freelancer); | ||
return AddFreelancerLanguageResponse.builder().withStatusCode(HttpStatusCode.CREATED).build(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
services/users/src/main/java/com/workup/users/commands/AddFreelancerSkillCommand.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,28 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.AddFreelancerSkillRequest; | ||
import com.workup.shared.commands.users.responses.AddFreelancerSkillResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class AddFreelancerSkillCommand | ||
extends UserCommand<AddFreelancerSkillRequest, AddFreelancerSkillResponse> { | ||
|
||
@Override | ||
public AddFreelancerSkillResponse Run(AddFreelancerSkillRequest request) { | ||
Optional<Freelancer> freelancerOptional = freelancerRepository.findById(request.getUser_id()); | ||
if (freelancerOptional.isEmpty()) | ||
return AddFreelancerSkillResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
String newSkill = request.getNewSkill(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
List<String> skills = freelancer.getSkills(); | ||
if (!skills.contains(newSkill)) skills.add(newSkill); | ||
freelancerRepository.save(freelancer); | ||
return AddFreelancerSkillResponse.builder().withStatusCode(HttpStatusCode.CREATED).build(); | ||
} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
services/users/src/main/java/com/workup/users/commands/GetFreelancerAchievementsCommand.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,29 @@ | ||
package com.workup.users.commands; | ||
|
||
import com.workup.shared.commands.users.requests.GetFreelancerAchievementsRequest; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.commands.responses.GetFreelancerAchievementsResponse; | ||
import com.workup.users.db.Achievement; | ||
import com.workup.users.db.Freelancer; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class GetFreelancerAchievementsCommand | ||
extends UserCommand<GetFreelancerAchievementsRequest, GetFreelancerAchievementsResponse> { | ||
@Override | ||
public GetFreelancerAchievementsResponse Run(GetFreelancerAchievementsRequest request) { | ||
Optional<Freelancer> freelancerOptional = | ||
freelancerRepository.findById(request.getFreelancer_id()); | ||
if (freelancerOptional.isEmpty()) | ||
return GetFreelancerAchievementsResponse.builder() | ||
.withStatusCode(HttpStatusCode.NOT_FOUND) | ||
.withErrorMessage("Freelancer Doesn't Exist") | ||
.build(); | ||
Freelancer freelancer = freelancerOptional.get(); | ||
List<Achievement> achievements = freelancer.getAchievements(); | ||
return GetFreelancerAchievementsResponse.builder() | ||
.withStatusCode(HttpStatusCode.OK) | ||
.withAchievements(achievements) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.