-
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.
feat: Add all freelancer profile CRUD operations (#54)
* feat: Add freelancer skills CRUD * feat: Add Freelancer language CRUD * feat: Add freelancer education CRUD * feat: Add freelancer experiences CRUD * feat: Add freelancer achievement CRUD * fix: Add db repositories * fix: Add repositories to the user command and add document collections * lint: Use linting * fix: Change withSuccess to withStatusCode * Payments `GetWallet` and `CreateWallet` unit testing (#58) * Added `GetWallet` request and response * Added `CreatePaymentRequest` request/response * Added inheritance from the Command Request and Response class to the * Added request/response * Added `createWallet` and `getWallet` unit testing --------- Co-authored-by: AhmedNasserG <ahmednasser217217@gmail.com> Co-authored-by: Abdulaziz-Hassan <abdulazizhza@gmail.com> * fix: Update user profile CRUD Update the user profile CRUD for better information hiding and move the requests and responses into the shared folder * fix: Remove duplicate files --------- Co-authored-by: Abdullah Ahmad Fouad <57245606+Abdullah204@users.noreply.github.com> Co-authored-by: AhmedNasserG <ahmednasser217217@gmail.com> Co-authored-by: Abdulaziz-Hassan <abdulazizhza@gmail.com>
- Loading branch information
1 parent
1f34452
commit d8f600b
Showing
73 changed files
with
1,270 additions
and
27 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
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
Oops, something went wrong.