-
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.
Browse files
Browse the repository at this point in the history
* feat: add api of seeing missions of joined workspace * feat: add api of checking duplication of workspace name * fix: add resolver and validation * feat: add api of entering workspace * refactor: separate method
- Loading branch information
Showing
13 changed files
with
320 additions
and
16 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package gymmi.response; | ||
|
||
import gymmi.entity.User; | ||
import gymmi.entity.Worker; | ||
import gymmi.entity.Workspace; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class InsideWorkspaceResponse { | ||
|
||
private final String name; | ||
private final Integer headCount; | ||
private final String status; | ||
private final Integer goalScore; | ||
private final String description; | ||
private final Integer achievementScore; | ||
private final List<WorkerResponse> workers; | ||
|
||
@Builder | ||
public InsideWorkspaceResponse( | ||
Workspace workspace, Integer achievementScore, | ||
List<Worker> sortedWorkers, List<Integer> workerRanks, | ||
User loginedUser | ||
) { | ||
this.name = workspace.getName(); | ||
this.headCount = workspace.getHeadCount(); | ||
this.status = workspace.getStatus().name(); | ||
this.goalScore = workspace.getGoalScore(); | ||
this.description = workspace.getDescription(); | ||
this.achievementScore = achievementScore; | ||
this.workers = getWorkerResponse(sortedWorkers, workerRanks, workspace.getCreator(), loginedUser); | ||
} | ||
|
||
private List<WorkerResponse> getWorkerResponse( | ||
List<Worker> sortedWorkers, List<Integer> workerRanks, | ||
User creator, User loginedUser | ||
) { | ||
List<WorkerResponse> workerResponses = new ArrayList<>(); | ||
for (int i = 0; i < sortedWorkers.size(); i++) { | ||
Worker worker = sortedWorkers.get(i); | ||
WorkerResponse response = WorkerResponse.builder() | ||
.worker(worker) | ||
.rank(workerRanks.get(i)) | ||
.isCreator(creator.equals(worker.getUser())) | ||
.isMyself(worker.getUser().equals(loginedUser)) | ||
.build(); | ||
workerResponses.add(response); | ||
} | ||
return workerResponses; | ||
} | ||
|
||
} |
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,20 @@ | ||
package gymmi.response; | ||
|
||
import gymmi.entity.Mission; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MissionResponse { | ||
|
||
private final Long id; | ||
private final String mission; | ||
private final Integer score; | ||
|
||
public MissionResponse(Mission mission) { | ||
this.id = mission.getId(); | ||
this.mission = mission.getName(); | ||
this.score = mission.getScore(); | ||
} | ||
|
||
} |
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,27 @@ | ||
package gymmi.response; | ||
|
||
import gymmi.entity.Worker; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class WorkerResponse { | ||
|
||
private final Long id; | ||
private final String name; | ||
private final Integer contributeScore; | ||
private final Integer rank; | ||
private final Boolean isCreator; | ||
private final Boolean isMyself; | ||
|
||
@Builder | ||
public WorkerResponse(Worker worker, Integer rank, boolean isCreator, boolean isMyself) { | ||
this.id = worker.getId(); | ||
this.name = worker.getNickname(); | ||
this.contributeScore = worker.getScore(); | ||
this.rank = rank; | ||
this.isCreator = isCreator; | ||
this.isMyself = isMyself; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/gymmi/service/WorkspaceNameDuplicationCheck.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 gymmi.service; | ||
|
||
import gymmi.entity.Workspace; | ||
import gymmi.global.DuplicationCheckType; | ||
import gymmi.repository.WorkspaceRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class WorkspaceNameDuplicationCheck implements DuplicationCheck { | ||
|
||
private final WorkspaceRepository workspaceRepository; | ||
|
||
@Override | ||
public boolean supports(DuplicationCheckType type) { | ||
return type == DuplicationCheckType.WORKSPACE_NAME; | ||
} | ||
|
||
@Override | ||
public boolean isDuplicate(String value) { | ||
Workspace.validateName(value); | ||
return workspaceRepository.findWorkspaceByByName(value).isPresent(); | ||
} | ||
} |
Oops, something went wrong.