From 93699822654534ad8daf3edc52b6add76059ae4b Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 02:19:50 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[Chore]=20#282=20-=20History=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20ResponseDTO=20=ED=8C=A8=ED=82=A4=EC=A7=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/moonshot/objective/controller/ObjectiveApi.java | 2 +- .../moonshot/objective/controller/ObjectiveController.java | 2 +- .../dto/response/{ => history}/HistoryKeyResultDto.java | 2 +- .../dto/response/{ => history}/HistoryObjectiveListDto.java | 3 ++- .../dto/response/{ => history}/HistoryResponseDto.java | 2 +- .../objective/dto/response/{ => history}/HistoryTaskDto.java | 2 +- .../dto/response/{ => history}/ObjectiveGroupByYearDto.java | 3 ++- .../objective/dto/response/{ => history}/YearDto.java | 2 +- .../java/org/moonshot/objective/service/ObjectiveService.java | 4 ++-- .../org/moonshot/objective/service/ObjectiveServiceTest.java | 4 ++-- 10 files changed, 14 insertions(+), 12 deletions(-) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/HistoryKeyResultDto.java (92%) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/HistoryObjectiveListDto.java (95%) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/HistoryResponseDto.java (86%) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/HistoryTaskDto.java (86%) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/ObjectiveGroupByYearDto.java (88%) rename moonshot-api/src/main/java/org/moonshot/objective/dto/response/{ => history}/YearDto.java (88%) diff --git a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java index c24bb36b..ddd198fd 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java @@ -11,7 +11,7 @@ import org.moonshot.objective.dto.request.ModifyObjectiveRequestDto; import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; -import org.moonshot.objective.dto.response.HistoryResponseDto; +import org.moonshot.objective.dto.response.history.HistoryResponseDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.response.MoonshotResponse; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java index 3e95cef3..5b03d299 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java @@ -8,7 +8,7 @@ import org.moonshot.objective.dto.request.ModifyObjectiveRequestDto; import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; -import org.moonshot.objective.dto.response.HistoryResponseDto; +import org.moonshot.objective.dto.response.history.HistoryResponseDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.objective.service.ObjectiveService; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryKeyResultDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryKeyResultDto.java similarity index 92% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryKeyResultDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryKeyResultDto.java index 21d1ab91..a43d52b1 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryKeyResultDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryKeyResultDto.java @@ -1,4 +1,4 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import java.util.List; import org.moonshot.keyresult.model.KeyResult; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryObjectiveListDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryObjectiveListDto.java similarity index 95% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryObjectiveListDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryObjectiveListDto.java index 2461b514..b0fb32e9 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryObjectiveListDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryObjectiveListDto.java @@ -1,7 +1,8 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import java.time.format.DateTimeFormatter; import java.util.List; + import org.moonshot.objective.model.Objective; public record HistoryObjectiveListDto( diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryResponseDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryResponseDto.java similarity index 86% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryResponseDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryResponseDto.java index b064f89b..2a8d0ad1 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryResponseDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryResponseDto.java @@ -1,4 +1,4 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import java.util.List; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryTaskDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryTaskDto.java similarity index 86% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryTaskDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryTaskDto.java index 284ed854..6b58afb3 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/HistoryTaskDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/HistoryTaskDto.java @@ -1,4 +1,4 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import org.moonshot.task.model.Task; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/ObjectiveGroupByYearDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/ObjectiveGroupByYearDto.java similarity index 88% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/ObjectiveGroupByYearDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/ObjectiveGroupByYearDto.java index 416f2c5b..e3ceca04 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/ObjectiveGroupByYearDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/ObjectiveGroupByYearDto.java @@ -1,6 +1,7 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import java.util.List; + import org.moonshot.objective.model.Objective; public record ObjectiveGroupByYearDto( diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/YearDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/YearDto.java similarity index 88% rename from moonshot-api/src/main/java/org/moonshot/objective/dto/response/YearDto.java rename to moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/YearDto.java index 788b893a..5d6873b4 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/YearDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/history/YearDto.java @@ -1,4 +1,4 @@ -package org.moonshot.objective.dto.response; +package org.moonshot.objective.dto.response.history; import java.util.List; import java.util.Map; diff --git a/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java b/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java index e4750a2e..ffc00bfa 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java @@ -24,8 +24,8 @@ import org.moonshot.objective.dto.request.ModifyObjectiveRequestDto; import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; -import org.moonshot.objective.dto.response.HistoryResponseDto; -import org.moonshot.objective.dto.response.ObjectiveGroupByYearDto; +import org.moonshot.objective.dto.response.history.HistoryResponseDto; +import org.moonshot.objective.dto.response.history.ObjectiveGroupByYearDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.objective.model.IndexService; diff --git a/moonshot-api/src/test/java/org/moonshot/objective/service/ObjectiveServiceTest.java b/moonshot-api/src/test/java/org/moonshot/objective/service/ObjectiveServiceTest.java index b931a496..a8c58990 100644 --- a/moonshot-api/src/test/java/org/moonshot/objective/service/ObjectiveServiceTest.java +++ b/moonshot-api/src/test/java/org/moonshot/objective/service/ObjectiveServiceTest.java @@ -23,8 +23,8 @@ import org.moonshot.objective.dto.request.ModifyObjectiveRequestDto; import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; -import org.moonshot.objective.dto.response.HistoryResponseDto; -import org.moonshot.objective.dto.response.ObjectiveGroupByYearDto; +import org.moonshot.objective.dto.response.history.HistoryResponseDto; +import org.moonshot.objective.dto.response.history.ObjectiveGroupByYearDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.objective.model.Objective; From 37d4959cd0daa8dc4a808137862f813ce65c9f0d Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 02:23:45 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[Feat]=20#282=20-=20Social=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20ResponseDTO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/social/SocialKeyResultDto.java | 35 +++++++++++++++++++ .../response/social/SocialOKRResponseDto.java | 26 ++++++++++++++ .../response/social/SocialObjectiveDto.java | 26 ++++++++++++++ .../dto/response/social/SocialTaskDto.java | 15 ++++++++ 4 files changed, 102 insertions(+) create mode 100644 moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialKeyResultDto.java create mode 100644 moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java create mode 100644 moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialObjectiveDto.java create mode 100644 moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialTaskDto.java diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialKeyResultDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialKeyResultDto.java new file mode 100644 index 00000000..25607e86 --- /dev/null +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialKeyResultDto.java @@ -0,0 +1,35 @@ +package org.moonshot.objective.dto.response.social; + +import org.moonshot.keyresult.model.KeyResult; + +import java.time.format.DateTimeFormatter; +import java.util.List; + +public record SocialKeyResultDto( + String krTitle, + String krStartAt, + String krExpireAt, + Long keyResultId, + Integer krIdx, + Long krTarget, + String krMetric, + List taskList +) { + public static SocialKeyResultDto of(KeyResult keyResult) { + return getSocialKeyResultDto(keyResult); + } + + private static SocialKeyResultDto getSocialKeyResultDto(KeyResult keyResult) { + return new SocialKeyResultDto( + keyResult.getTitle(), + keyResult.getPeriod().getStartAt().format(DateTimeFormatter.ISO_LOCAL_DATE), + keyResult.getPeriod().getExpireAt().format(DateTimeFormatter.ISO_LOCAL_DATE), + keyResult.getId(), + keyResult.getIdx(), + keyResult.getTarget(), + keyResult.getMetric(), + keyResult.getTaskList().stream().map(SocialTaskDto::of).toList() + ); + } +} + diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java new file mode 100644 index 00000000..701d6c33 --- /dev/null +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java @@ -0,0 +1,26 @@ +package org.moonshot.objective.dto.response.social; + +import org.moonshot.objective.model.Objective; +import org.moonshot.user.model.User; + +public record SocialOKRResponseDto( + String category, + String userName, + String userImg, + Long like, + String userIntro, + SocialObjectiveDto okrTreeData +) { + public static SocialOKRResponseDto of(Objective objective, User user, SocialObjectiveDto okrTreeData) { + return new SocialOKRResponseDto( + objective.getCategory().getValue(), + user.getName(), + user.getImageUrl(), + objective.getHeartCount(), + user.getDescription(), + okrTreeData + ); + } + +} + diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialObjectiveDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialObjectiveDto.java new file mode 100644 index 00000000..d7bcebca --- /dev/null +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialObjectiveDto.java @@ -0,0 +1,26 @@ +package org.moonshot.objective.dto.response.social; + +import org.moonshot.objective.model.Objective; + +import java.time.format.DateTimeFormatter; +import java.util.List; + +public record SocialObjectiveDto( + String objTitle, + String objCategory, + String objContent, + String objStartAt, + String objExpireAt, + List krList +) { + public static SocialObjectiveDto of(Objective objective) { + return new SocialObjectiveDto( + objective.getTitle(), + objective.getCategory().getValue(), + objective.getContent(), + objective.getPeriod().getStartAt().format(DateTimeFormatter.ISO_LOCAL_DATE), + objective.getPeriod().getExpireAt().format(DateTimeFormatter.ISO_LOCAL_DATE), + objective.getKeyResultList().stream().map(SocialKeyResultDto::of).toList() + ); + } +} diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialTaskDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialTaskDto.java new file mode 100644 index 00000000..066e8ca0 --- /dev/null +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialTaskDto.java @@ -0,0 +1,15 @@ +package org.moonshot.objective.dto.response.social; + +import org.moonshot.task.model.Task; + +public record SocialTaskDto( + String taskTitle, + Integer taskIdx +) { + public static SocialTaskDto of(Task task) { + return new SocialTaskDto( + task.getTitle(), + task.getIdx() + ); + } +} From f023bfd2f93da7962f595d037a6e361a8ea392f6 Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 04:36:28 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[Fix]=20#282=20-=20OKRResponseDto=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/social/SocialOKRResponseDto.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java index 701d6c33..4d7fc343 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/dto/response/social/SocialOKRResponseDto.java @@ -11,14 +11,14 @@ public record SocialOKRResponseDto( String userIntro, SocialObjectiveDto okrTreeData ) { - public static SocialOKRResponseDto of(Objective objective, User user, SocialObjectiveDto okrTreeData) { + public static SocialOKRResponseDto of(Objective objective) { return new SocialOKRResponseDto( objective.getCategory().getValue(), - user.getName(), - user.getImageUrl(), + objective.getUser().getNickname(), + objective.getUser().getImageUrl(), objective.getHeartCount(), - user.getDescription(), - okrTreeData + objective.getUser().getDescription(), + SocialObjectiveDto.of(objective) ); } From 40872ac230795ab4d0e29913ca6986560a20325d Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 17:11:53 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[Feat]=20#282=20-=20Social=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20Repository=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ObjectiveCustomRepository.java | 2 ++ .../repository/ObjectiveCustomRepositoryImpl.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepository.java b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepository.java index 0155141f..e879fb05 100644 --- a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepository.java +++ b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepository.java @@ -9,4 +9,6 @@ public interface ObjectiveCustomRepository { List findObjectives(Long userId, Integer year, Category category, Criteria criteria); + List findSocialObjectives(); + } diff --git a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java index 3faa7e1d..2fffede8 100644 --- a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java +++ b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java @@ -66,4 +66,16 @@ private OrderSpecifier order(Criteria criteria) { return orderSpecifier; } + @Override + public List findSocialObjectives() { + return queryFactory.selectFrom(objective).distinct() + .join(objective.user).fetchJoin() + .join(objective.keyResultList, keyResult).fetchJoin() + .join(keyResult.taskList, task) + .where(objective.isPublic.eq(true)) + .orderBy(objective.heartCount.desc(), objective.id.desc()) + .limit(10) + .fetch(); + } + } From c52ab1996488afec927fe1e37d3c02449b009b5d Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 17:12:23 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[Feat]=20#282=20-=20Social=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../objective/controller/ObjectiveController.java | 12 +++++++++++- .../moonshot/objective/service/ObjectiveService.java | 10 ++++++++++ .../main/java/org/moonshot/response/SuccessType.java | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java index 5b03d299..f94d521f 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java @@ -9,6 +9,7 @@ import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; import org.moonshot.objective.dto.response.history.HistoryResponseDto; +import org.moonshot.objective.dto.response.social.SocialOKRResponseDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.objective.service.ObjectiveService; @@ -27,6 +28,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @@ -69,7 +72,14 @@ public ResponseEntity> getObjectiveHistory( @RequestParam(required = false, name = "category") final Category category, @RequestParam(required = false, name = "criteria") final Criteria criteria) { HistoryResponseDto response = objectiveService.getObjectiveHistory(userId, year, category, criteria); - return ResponseEntity.ok(MoonshotResponse.success(SuccessType.OK, response)); + return ResponseEntity.ok(MoonshotResponse.success(SuccessType.GET_HISTORY_SUCCESS, response)); + } + + @GetMapping("/social") + @Logging(item = "Social", action = "Get") + public ResponseEntity>> getObjectiveSocial(@LoginUser Long userId) { + List response = objectiveService.getObjectiveSocial(); + return ResponseEntity.ok(MoonshotResponse.success(SuccessType.GET_SOCIAL_SUCCESS, response)); } } diff --git a/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java b/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java index ffc00bfa..86536eb1 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/service/ObjectiveService.java @@ -20,12 +20,14 @@ import org.moonshot.exception.BadRequestException; import org.moonshot.exception.NotFoundException; import org.moonshot.keyresult.service.KeyResultService; +import org.moonshot.log.dto.response.LogResponseDto; import org.moonshot.objective.dto.request.ModifyIndexRequestDto; import org.moonshot.objective.dto.request.ModifyObjectiveRequestDto; import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; import org.moonshot.objective.dto.response.history.HistoryResponseDto; import org.moonshot.objective.dto.response.history.ObjectiveGroupByYearDto; +import org.moonshot.objective.dto.response.social.SocialOKRResponseDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.objective.model.IndexService; @@ -139,6 +141,14 @@ public HistoryResponseDto getObjectiveHistory(final Long userId, final Integer y return HistoryResponseDto.of(groupsSortedByCriteria, categories); } + @Transactional(readOnly = true) + public List getObjectiveSocial() { + List objectives = objectiveRepository.findSocialObjectives(); + return objectives.stream() + .map(SocialOKRResponseDto::of) + .toList(); + } + @Override public void modifyIdx(final ModifyIndexRequestDto request, final Long userId) { Long objectiveCount = objectiveRepository.countAllByUserId(userId); diff --git a/moonshot-common/src/main/java/org/moonshot/response/SuccessType.java b/moonshot-common/src/main/java/org/moonshot/response/SuccessType.java index 94ae782c..cb04619e 100644 --- a/moonshot-common/src/main/java/org/moonshot/response/SuccessType.java +++ b/moonshot-common/src/main/java/org/moonshot/response/SuccessType.java @@ -24,6 +24,7 @@ public enum SuccessType { PATCH_KR_ACHIEVE_SUCCESS(HttpStatus.OK, 2009, "KeyResult 수정 후 목표를 달성하였습니다."), POST_LOG_ACHIEVE_SUCCESS(HttpStatus.OK, 2010, "체크인 Log 생성 후 목표를 달성하였습니다."), DELETE_OBJECTIVE_SUCCESS(HttpStatus.OK, 2011, "Objective 삭제를 성공하였습니다."), + GET_SOCIAL_SUCCESS(HttpStatus.OK, 2012,"소셜 조회에 성공하였습니다."), /** * 201 CREATED (2100 ~ 2199) From b2d9a6819c5725cb31f25b52415157c8e6c29de0 Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 17:14:54 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[Fix]=20#282=20-=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/moonshot/objective/controller/ObjectiveController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java index f94d521f..ea30d327 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveController.java @@ -77,7 +77,7 @@ public ResponseEntity> getObjectiveHistory( @GetMapping("/social") @Logging(item = "Social", action = "Get") - public ResponseEntity>> getObjectiveSocial(@LoginUser Long userId) { + public ResponseEntity>> getObjectiveSocial() { List response = objectiveService.getObjectiveSocial(); return ResponseEntity.ok(MoonshotResponse.success(SuccessType.GET_SOCIAL_SUCCESS, response)); } From 772e2c79695cd132ecc4b564884e9abd5979699a Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 17:23:35 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[Feat]=20#282=20-=20Social=20API=20Swagger?= =?UTF-8?q?=20=EB=AC=B8=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../moonshot/objective/controller/ObjectiveApi.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java index ddd198fd..fbb5ba2d 100644 --- a/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java +++ b/moonshot-api/src/main/java/org/moonshot/objective/controller/ObjectiveApi.java @@ -12,6 +12,7 @@ import org.moonshot.objective.dto.request.OKRCreateRequestDto; import org.moonshot.objective.dto.response.DashboardResponseDto; import org.moonshot.objective.dto.response.history.HistoryResponseDto; +import org.moonshot.objective.dto.response.social.SocialOKRResponseDto; import org.moonshot.objective.model.Category; import org.moonshot.objective.model.Criteria; import org.moonshot.response.MoonshotResponse; @@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; +import java.util.List; + @Tag(name = "Objective", description = "Objective 관련 API") interface ObjectiveApi { @@ -71,4 +74,11 @@ ResponseEntity> getObjectiveHistory(@LoginU @RequestParam(required = false) final Category category, @RequestParam(required = false) final Criteria criteria); + @ApiResponses(value = { + @ApiResponse(responseCode = "2012", description = "소셜 조회에 성공하였습니다."), + @ApiResponse(responseCode = "4100", description = "인증토큰이 존재하지 않습니다.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = MoonshotResponse.class))) + }) + @Operation(summary = "소셜 목록 조회") + ResponseEntity>> getObjectiveSocial(); + } From 192c895247a1e7b76c005d3fed10b225a12a2a26 Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Fri, 31 May 2024 18:18:06 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[Fix]=20#282=20-=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=A0=AC=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../objective/repository/ObjectiveCustomRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java index 2fffede8..09a948b0 100644 --- a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java +++ b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java @@ -73,7 +73,7 @@ public List findSocialObjectives() { .join(objective.keyResultList, keyResult).fetchJoin() .join(keyResult.taskList, task) .where(objective.isPublic.eq(true)) - .orderBy(objective.heartCount.desc(), objective.id.desc()) + .orderBy(objective.id.desc()) .limit(10) .fetch(); } From c76966790799158f43f5150ef2a727b9a64c71b4 Mon Sep 17 00:00:00 2001 From: Choi YoungLyn Date: Sat, 1 Jun 2024 00:12:53 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[Fix]=20#282=20-=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EC=A0=95=EB=A0=AC=20=EC=A1=B0=EA=B1=B4=20=EA=B8=B0?= =?UTF-8?q?=ED=9A=8D=20=EA=B2=B0=EC=A0=95=20=EC=82=AC=ED=95=AD=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../objective/repository/ObjectiveCustomRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java index 09a948b0..2fffede8 100644 --- a/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java +++ b/moonshot-domain/src/main/java/org/moonshot/objective/repository/ObjectiveCustomRepositoryImpl.java @@ -73,7 +73,7 @@ public List findSocialObjectives() { .join(objective.keyResultList, keyResult).fetchJoin() .join(keyResult.taskList, task) .where(objective.isPublic.eq(true)) - .orderBy(objective.id.desc()) + .orderBy(objective.heartCount.desc(), objective.id.desc()) .limit(10) .fetch(); }