-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/get crew home] 크루홈 조회 api 구현 #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0a86005
:sparkles: edit : edit get crew home and info page status code
jeeheaG fd92bbe
:recycle: refactor : rename CommandCrewService
jeeheaG 65d0106
:sparkles: feat : make dtos for UpdateCrewInfo api
jeeheaG 0138dc5
:sparkles: feat : make exception and error code for UpdateCrewInfo api
jeeheaG 34fe056
:sparkles: feat : make use case and service logic for UpdateCrewInfo api
jeeheaG cda039d
:sparkles: feat : make UpdateCrewInfo api
jeeheaG 5204e5f
:recycle: refactor : move crew owner checking logic to CommandCrewSer…
jeeheaG 5960a64
Merge branch 'main' of https://github.com/Run-Us/Run-Us-server into J…
jeeheaG 0f705e6
:bug: solve merge conflict
jeeheaG 6cf221f
:sparkles: make update crew join rule api
jeeheaG 707bbce
:sparkles: make close crew api
jeeheaG 7894813
:sparkles: add : make monthlyRecord field
jeeheaG 8e862b2
:sparkles: add : make type field in RunningPreview
jeeheaG c2d5a50
:sparkles: add : make RunTopMessage logic by strategy pattern
jeeheaG b8a83ac
:sparkles: add : make findFirstForCrewCard query method
jeeheaG 3719ea5
:sparkles: add : make existsByCrewIdAndStatus query method
jeeheaG a67cde6
:sparkles: add : make getUserByInternalId method
jeeheaG 4fab857
:sparkles: add : move validate logic to CrewValidator
jeeheaG a84760a
:sparkles: add : make getCrewCardRun service logic
jeeheaG a0bb901
:sparkles: add : make existNewJoinRequest service logic
jeeheaG b2fc5e4
:sparkles: feat : make getCrewHome api
jeeheaG 3472c5f
:sparkles: edit : change to use @CurrentUser
jeeheaG b9f082c
:bug: fix : add exception throwing when user profile is null
jeeheaG 4fc6d5f
:bug: fix : use service model UpdateCrewInfo instead of request dto
jeeheaG 1f2838e
:bulb: comment : delete TODO comment
jeeheaG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/run_us/server/domains/crew/controller/QueryCrewController.java
This file contains hidden or 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,31 @@ | ||
| package com.run_us.server.domains.crew.controller; | ||
|
|
||
| import com.run_us.server.domains.crew.controller.model.response.GetCrewHomeResponse; | ||
| import com.run_us.server.domains.crew.service.usecase.QueryCrewUseCase; | ||
| import com.run_us.server.global.common.SuccessResponse; | ||
| import com.run_us.server.global.security.annotation.CurrentUser; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @Slf4j | ||
| @RestController | ||
| @RequestMapping("/crews") | ||
| @RequiredArgsConstructor | ||
| public class QueryCrewController { | ||
| private final QueryCrewUseCase queryCrewUseCase; | ||
|
|
||
| @GetMapping("/{crewPublicId}/home") | ||
| public ResponseEntity<SuccessResponse<GetCrewHomeResponse>> getCrewHome( | ||
| @PathVariable String crewPublicId, | ||
| @CurrentUser String currentUserPublicId) { | ||
| log.info("action=get_crew_home crew_public_id={}, user_id={}", crewPublicId, currentUserPublicId); | ||
|
|
||
| SuccessResponse<GetCrewHomeResponse> response = queryCrewUseCase.getCrewHome(crewPublicId, currentUserPublicId); | ||
| return ResponseEntity.ok().body(response); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
28 changes: 28 additions & 0 deletions
28
...n/java/com/run_us/server/domains/crew/controller/model/request/UpdateCrewInfoRequest.java
This file contains hidden or 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.run_us.server.domains.crew.controller.model.request; | ||
|
|
||
| import com.run_us.server.domains.crew.domain.CrewDescription; | ||
| import com.run_us.server.domains.crew.domain.enums.CrewThemeType; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class UpdateCrewInfoRequest { | ||
| private String title; | ||
| private String intro; | ||
| private String location; | ||
| private String profileImageUrl; | ||
| private CrewThemeType crewType; | ||
|
|
||
| public CrewDescription from(CrewDescription old) { | ||
| return CrewDescription.builder() | ||
| .title(this.title) | ||
| .intro(this.intro) | ||
| .location(this.location) | ||
| .profileImageUrl(this.profileImageUrl) | ||
| .themeType(this.crewType) | ||
| .joinQuestion(old.getJoinQuestion()) | ||
| .build(); | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...va/com/run_us/server/domains/crew/controller/model/request/UpdateCrewJoinTypeRequest.java
This file contains hidden or 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,15 @@ | ||
| package com.run_us.server.domains.crew.controller.model.request; | ||
|
|
||
| import com.run_us.server.domains.crew.domain.CrewDescription; | ||
| import com.run_us.server.domains.crew.domain.enums.CrewJoinType; | ||
| import com.run_us.server.domains.crew.domain.enums.CrewThemeType; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class UpdateCrewJoinTypeRequest { | ||
| private CrewJoinType joinType; | ||
| private String joinQuestion; | ||
| } |
25 changes: 25 additions & 0 deletions
25
...main/java/com/run_us/server/domains/crew/controller/model/response/CloseCrewResponse.java
This file contains hidden or 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.run_us.server.domains.crew.controller.model.response; | ||
|
|
||
| import com.run_us.server.domains.crew.domain.Crew; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class CloseCrewResponse { | ||
| private String crewPublicId; | ||
|
|
||
| @Builder | ||
| private CloseCrewResponse(String crewPublicId) { | ||
| this.crewPublicId = crewPublicId; | ||
| } | ||
|
|
||
| public static CloseCrewResponse from(Crew crew) { | ||
| return CloseCrewResponse.builder() | ||
| .crewPublicId(crew.getPublicId()) | ||
| .build(); | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
...in/java/com/run_us/server/domains/crew/controller/model/response/CrewThisMonthRecord.java
This file contains hidden or 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 com.run_us.server.domains.crew.controller.model.response; | ||
|
|
||
| import com.run_us.server.domains.crew.domain.CrewMonthlyRecord; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class CrewThisMonthRecord { | ||
| private Integer totalRunningCount; | ||
| private Integer totalDistance; | ||
| private Integer totalTime; | ||
|
|
||
| @Builder | ||
| CrewThisMonthRecord(Integer totalRunningCount, Integer totalDistance, Integer totalTime){ | ||
| this.totalRunningCount = totalRunningCount; | ||
| this.totalDistance = totalDistance; | ||
| this.totalTime = totalTime; | ||
| } | ||
|
|
||
| public static CrewThisMonthRecord from(CrewMonthlyRecord monthlyRecord){ | ||
| return CrewThisMonthRecord.builder() | ||
| .totalRunningCount(monthlyRecord.getTotalRunningCount()) | ||
| .totalDistance(monthlyRecord.getTotalDistance()) | ||
| .totalTime(monthlyRecord.getTotalTime()) | ||
| .build(); | ||
| } | ||
| } |
87 changes: 87 additions & 0 deletions
87
...in/java/com/run_us/server/domains/crew/controller/model/response/GetCrewHomeResponse.java
This file contains hidden or 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,87 @@ | ||
| package com.run_us.server.domains.crew.controller.model.response; | ||
|
|
||
| import com.run_us.server.domains.crew.domain.Crew; | ||
| import com.run_us.server.domains.crew.domain.CrewDescription; | ||
| import com.run_us.server.domains.crew.domain.enums.CrewJoinType; | ||
| import com.run_us.server.domains.crew.domain.enums.CrewThemeType; | ||
| import com.run_us.server.domains.crew.service.model.CrewRunCardInfo; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import java.time.ZonedDateTime; | ||
|
|
||
| @Getter | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class GetCrewHomeResponse { | ||
| private String crewPublicId; | ||
| private String title; | ||
| private String profileImg; | ||
| private String location; | ||
| private String intro; | ||
| private CrewJoinType joinType; | ||
| private String joinQuestion; | ||
| private CrewThemeType crewType; | ||
| private Integer memberCount; | ||
| private ZonedDateTime createdAt; | ||
| private SimpleUserInfo crewOwner; | ||
| private Boolean existNewJoinRequest; | ||
| private CrewThisMonthRecord thisMonthRecord; | ||
| private RunCardInfo regularRunning; | ||
| private RunCardInfo irregularRunning; | ||
|
|
||
| @Builder | ||
| public GetCrewHomeResponse( // TODO : 가독성 이게 최선인가.. | ||
| String crewPublicId, String title, String profileImg, String location, String intro, | ||
| CrewJoinType joinType, String joinQuestion, CrewThemeType crewType, | ||
| Integer memberCount, ZonedDateTime createdAt, SimpleUserInfo crewOwner, | ||
| Boolean existNewJoinRequest, CrewThisMonthRecord thisMonthRecord, | ||
| RunCardInfo regularRunning, RunCardInfo irregularRunning | ||
| ) { | ||
| this.crewPublicId = crewPublicId; | ||
| this.title = title; | ||
| this.profileImg = profileImg; | ||
| this.location = location; | ||
| this.intro = intro; | ||
| this.joinType = joinType; | ||
| this.joinQuestion = joinQuestion; | ||
| this.crewType = crewType; | ||
| this.memberCount = memberCount; | ||
| this.createdAt = createdAt; | ||
| this.crewOwner = crewOwner; | ||
| this.existNewJoinRequest = existNewJoinRequest; | ||
| this.thisMonthRecord = thisMonthRecord; | ||
| this.regularRunning = regularRunning; | ||
| this.irregularRunning = irregularRunning; | ||
| } | ||
|
|
||
|
|
||
| public static GetCrewHomeResponse from(Crew crew, boolean existNewJoinRequest, CrewRunCardInfo cardRunInfo) { | ||
| CrewDescription description = crew.getCrewDescription(); | ||
|
|
||
| GetCrewHomeResponseBuilder builder = GetCrewHomeResponse.builder() | ||
| .crewPublicId(crew.getPublicId()) | ||
| .title(description.getTitle()) | ||
| .profileImg(description.getProfileImageUrl()) | ||
| .location(description.getLocation()) | ||
| .intro(description.getIntro()) | ||
| .joinType(crew.getJoinType()) | ||
| .joinQuestion(description.getJoinQuestion()) | ||
| .crewType(description.getThemeType()) | ||
| .memberCount(crew.getMemberCount()) | ||
| .createdAt(crew.getCreatedAt()) | ||
|
|
||
| .crewOwner(SimpleUserInfo.from(crew.getOwner())) | ||
| .existNewJoinRequest(existNewJoinRequest) | ||
| .thisMonthRecord(CrewThisMonthRecord.from(crew.getMonthlyRecord())); | ||
|
|
||
| if (cardRunInfo.getIrregularRunCard() != null) { | ||
| builder.irregularRunning(cardRunInfo.getIrregularRunCard()); | ||
| } | ||
| if (cardRunInfo.getRegularRunCard() != null) { | ||
| builder.regularRunning(cardRunInfo.getRegularRunCard()); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
| } | ||
55 changes: 55 additions & 0 deletions
55
src/main/java/com/run_us/server/domains/crew/controller/model/response/RunCardInfo.java
This file contains hidden or 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 com.run_us.server.domains.crew.controller.model.response; | ||
|
|
||
| import com.run_us.server.domains.running.run.domain.Run; | ||
| import com.run_us.server.domains.running.run.domain.RunPace; | ||
| import com.run_us.server.domains.running.run.domain.RunningPreview; | ||
| import com.run_us.server.domains.user.domain.User; | ||
| import com.run_us.server.global.common.GlobalConst; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
|
|
||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.List; | ||
|
|
||
| @Getter | ||
| public class RunCardInfo { | ||
| private String runningPublicId; | ||
| private String topMessage; | ||
| private String title; | ||
| private String description; | ||
| private String startAt; | ||
| private List<RunPace> paceList; | ||
| private Integer participantCount; | ||
| private SimpleUserInfo createdBy; | ||
|
|
||
|
|
||
| @Builder | ||
| private RunCardInfo( | ||
| String runningPublicId, | ||
| String topMessage, String title, String description, String startAt, | ||
| List<RunPace> paceList, Integer participantCount, SimpleUserInfo createdBy) { | ||
| this.runningPublicId = runningPublicId; | ||
| this.topMessage = topMessage; | ||
| this.title = title; | ||
| this.description = description; | ||
| this.startAt = startAt; | ||
| this.paceList = paceList; | ||
| this.participantCount = participantCount; | ||
| this.createdBy = createdBy; | ||
| } | ||
|
|
||
| public static RunCardInfo from(Run run, String topMessage, User createdUser) { | ||
| RunningPreview preview = run.getPreview(); | ||
|
|
||
| return RunCardInfo.builder() | ||
| .runningPublicId(run.getPublicId()) | ||
| .topMessage(topMessage) | ||
| .title(preview.getTitle()) | ||
| .description(preview.getDescription()) | ||
| .startAt(preview.getBeginTime().format(DateTimeFormatter.ofPattern(GlobalConst.TIME_FORMAT_PATTERN))) | ||
| .paceList(run.getPaceCategories()) | ||
| .createdBy(SimpleUserInfo.from(createdUser)) | ||
| .build(); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.