-
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.
- Loading branch information
1 parent
1f34452
commit 43da4fd
Showing
16 changed files
with
150 additions
and
61 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
services/users/src/main/java/com/workup/users/commands/ClientGetPhotoCommand.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.ClientGetPhotoRequest; | ||
import com.workup.shared.commands.users.responses.ClientGetPhotoResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Client; | ||
import java.util.Optional; | ||
|
||
public class ClientGetPhotoCommand | ||
extends UserCommand<ClientGetPhotoRequest, ClientGetPhotoResponse> { | ||
|
||
@Override | ||
public ClientGetPhotoResponse Run(ClientGetPhotoRequest request) { | ||
Optional<Client> clientOptional = clientRepository.findById(request.user_id); | ||
|
||
if (!clientOptional.isPresent()) { | ||
return ClientGetPhotoResponse.builder() | ||
.withStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR) | ||
.build(); | ||
} | ||
|
||
Client client = clientOptional.get(); | ||
|
||
return ClientGetPhotoResponse.builder() | ||
.withStatusCode(HttpStatusCode.OK) | ||
.withPhotoLink(client.getPhoto_link()) | ||
.build(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
services/users/src/main/java/com/workup/users/commands/ClientSetPhotoCommand.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.ClientSetPhotoRequest; | ||
import com.workup.shared.commands.users.responses.ClientSetPhotoResponse; | ||
import com.workup.shared.enums.HttpStatusCode; | ||
import com.workup.users.db.Client; | ||
import java.util.Optional; | ||
|
||
public class ClientSetPhotoCommand | ||
extends UserCommand<ClientSetPhotoRequest, ClientSetPhotoResponse> { | ||
|
||
@Override | ||
public ClientSetPhotoResponse Run(ClientSetPhotoRequest request) { | ||
|
||
Optional<Client> clientOption = clientRepository.findById(request.user_id); | ||
|
||
if (!clientOption.isPresent()) { | ||
throw new RuntimeException("User not found"); | ||
} | ||
|
||
Client client = clientOption.get(); | ||
|
||
client.setPhoto_link(request.photoLink); | ||
|
||
clientRepository.save(client); | ||
|
||
return ClientSetPhotoResponse.builder().withStatusCode(HttpStatusCode.OK).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
13 changes: 13 additions & 0 deletions
13
shared/src/main/java/com/workup/shared/commands/users/requests/ClientGetPhotoRequest.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.workup.shared.commands.users.requests; | ||
|
||
import com.workup.shared.commands.CommandRequest; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Getter | ||
@SuperBuilder(setterPrefix = "with") | ||
@Jacksonized | ||
public class ClientGetPhotoRequest extends CommandRequest { | ||
public String user_id; | ||
} |
14 changes: 14 additions & 0 deletions
14
shared/src/main/java/com/workup/shared/commands/users/requests/ClientSetPhotoRequest.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,14 @@ | ||
package com.workup.shared.commands.users.requests; | ||
|
||
import com.workup.shared.commands.CommandRequest; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Getter | ||
@SuperBuilder(setterPrefix = "with") | ||
@Jacksonized | ||
public class ClientSetPhotoRequest extends CommandRequest { | ||
public String user_id; | ||
public String photoLink; | ||
} |
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
shared/src/main/java/com/workup/shared/commands/users/responses/ClientGetPhotoResponse.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.workup.shared.commands.users.responses; | ||
|
||
import com.workup.shared.commands.CommandResponse; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Getter | ||
@SuperBuilder(setterPrefix = "with") | ||
@Jacksonized | ||
public class ClientGetPhotoResponse extends CommandResponse { | ||
public String photoLink; | ||
} |
11 changes: 11 additions & 0 deletions
11
shared/src/main/java/com/workup/shared/commands/users/responses/ClientSetPhotoResponse.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,11 @@ | ||
package com.workup.shared.commands.users.responses; | ||
|
||
import com.workup.shared.commands.CommandResponse; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
import lombok.extern.jackson.Jacksonized; | ||
|
||
@Getter | ||
@SuperBuilder(setterPrefix = "with") | ||
@Jacksonized | ||
public class ClientSetPhotoResponse extends CommandResponse {} |
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