-
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.
Merge remote-tracking branch 'origin/dev' into feat/34/mypage-schedule
# Conflicts: # src/main/java/com/meetup/teame/backend/domain/user/controller/UserController.java # src/main/java/com/meetup/teame/backend/domain/user/service/UserService.java
- Loading branch information
Showing
38 changed files
with
1,001 additions
and
110 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
71 changes: 71 additions & 0 deletions
71
src/main/java/com/meetup/teame/backend/domain/activity/controller/ActivityController.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,71 @@ | ||
package com.meetup.teame.backend.domain.activity.controller; | ||
|
||
import com.meetup.teame.backend.domain.activity.dto.request.ReadActivitiesReq; | ||
import com.meetup.teame.backend.domain.activity.dto.response.ActivityDetailsRes; | ||
import com.meetup.teame.backend.domain.activity.dto.response.ReadActivitiesRes; | ||
import com.meetup.teame.backend.domain.activity.service.ActivityService; | ||
import com.meetup.teame.backend.domain.auth.jwt.SecurityContextProvider; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@Tag(name = "activity", description = "활동 관련 api") | ||
public class ActivityController { | ||
|
||
private final ActivityService activityService; | ||
|
||
@Operation(summary = "활동 상세 정보 조회", description = """ | ||
활동 id로 활동의 상세 정보를 조회합니다. | ||
""") | ||
//activityId로 특정 활동 불러오기 | ||
@GetMapping("/{activityId}/activity-details") | ||
public ResponseEntity<ActivityDetailsRes> getActivityDetails(@PathVariable Long activityId) { | ||
ActivityDetailsRes activityDetailsRes = activityService.getActivityDetails(activityId); | ||
return ResponseEntity.ok().body(activityDetailsRes); | ||
} | ||
|
||
@Operation(summary = "전체 활동 불러오기", description = """ | ||
활동 참여하기에 들어가면 제일 처음 볼 수 있는 페이지를 위한 기능입니다. | ||
전체 활동들을 페이지 단위로 불러옵니다. | ||
page : 조회할 페이지 (0페이지 부터 시작) | ||
agencyType : 활동 기관 유형 (우선 기관 하나만 입력하는 것으로 만들었습니다.) | ||
personalities : 활동 성격 유형 (복수 선택 가능합니다, String List로 보내주시면 됩니다.) | ||
""") | ||
//전체 활동 불러오기 | ||
@GetMapping("/activities") | ||
public ResponseEntity<ReadActivitiesRes> getActivities(@ModelAttribute ReadActivitiesReq request) { | ||
ReadActivitiesRes activities = activityService.findActivities(request); | ||
return ResponseEntity.ok().body(activities); | ||
} | ||
|
||
@Operation(summary = "관심 활동 목록 조회", description = """ | ||
관심 활동들을 조회하는 api입니다. | ||
userId를 api 주소에 넣어주세요. | ||
관심 활동들을 페이지 단위로 불러옵니다. | ||
page : 조회할 페이지 (0페이지 부터 시작) | ||
agencyType : 활동 기관 유형 (우선 기관 하나만 입력하는 것으로 만들었습니다.) | ||
personalities : 활동 성격 유형 (복수 선택 가능합니다, String List로 보내주시면 됩니다.) | ||
""") | ||
//관심 활동 불러오기 | ||
@GetMapping("/activities/liked") | ||
public ResponseEntity<ReadActivitiesRes> getLikedActivities(@ModelAttribute ReadActivitiesReq request) { | ||
ReadActivitiesRes activities = activityService.findlikedActivities(request); | ||
return ResponseEntity.ok().body(activities); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/meetup/teame/backend/domain/activity/dto/request/ReadActivitiesReq.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.meetup.teame.backend.domain.activity.dto.request; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.Min; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
public class ReadActivitiesReq { | ||
|
||
@NotBlank(message = "page is required") | ||
@Min(value = 0, message = "page must be greater than or equal to 0") | ||
@Schema(example = "0") | ||
private long page; | ||
|
||
private String agencyType; | ||
|
||
private List<String> personalities = new ArrayList<>(); | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityDetailsRes.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,54 @@ | ||
package com.meetup.teame.backend.domain.activity.dto.response; | ||
|
||
import com.meetup.teame.backend.domain.activity.entity.Activity; | ||
import com.meetup.teame.backend.domain.personality.Personality; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.Comment; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
public class ActivityDetailsRes { | ||
|
||
private Long id; | ||
|
||
private String title; | ||
|
||
private String agency; | ||
|
||
private String agencyType; | ||
|
||
private String location; | ||
|
||
private LocalDateTime time; | ||
|
||
private Long currentParticipants; | ||
|
||
private Long maxParticipants; | ||
|
||
private List<Personality> personalities; | ||
|
||
private List<String> activityImgs; | ||
|
||
public static ActivityDetailsRes of(Activity activity) { | ||
return ActivityDetailsRes.builder() | ||
.id(activity.getId()) | ||
.title(activity.getTitle()) | ||
.agency(activity.getAgency()) | ||
.agency(activity.getAgencyType().getDescription()) | ||
.location(activity.getLocation()) | ||
.time(activity.getTime()) | ||
.currentParticipants(activity.getCurrentParticipants()) | ||
.maxParticipants(activity.getMaxParticipants()) | ||
.personalities(activity.getPersonalities()) | ||
.activityImgs(activity.getActivityImgs()) | ||
.build(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivityPageRes.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.meetup.teame.backend.domain.activity.dto.response; | ||
|
||
import java.util.List; | ||
|
||
public record ActivityPageRes( | ||
List<ActivitySummaryRes> activities, | ||
int totalPages, | ||
long totalElements) | ||
{ | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ActivitySummaryRes.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,54 @@ | ||
package com.meetup.teame.backend.domain.activity.dto.response; | ||
|
||
import com.meetup.teame.backend.domain.activity.entity.Activity; | ||
import com.meetup.teame.backend.domain.like.repository.ActivityLikeRepository; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import lombok.*; | ||
import org.hibernate.annotations.Comment; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
public class ActivitySummaryRes { | ||
|
||
private Long id; | ||
|
||
private String title; | ||
|
||
private String agency; | ||
|
||
private String agencyType; | ||
|
||
private String location; | ||
|
||
private LocalDateTime time; | ||
|
||
private String activityThumbnail; | ||
|
||
private boolean isLiked = false; | ||
|
||
public static ActivitySummaryRes of(Activity activity, boolean isLiked) { | ||
|
||
List<String> activityImgs = activity.getActivityImgs(); | ||
String activityThumbnail = null; | ||
//String activityThumbnail = activityImgs.get(0); | ||
if (!activityImgs.isEmpty()) { | ||
activityThumbnail = activityImgs.get(0); | ||
} | ||
|
||
return ActivitySummaryRes.builder() | ||
.id(activity.getId()) | ||
.title(activity.getTitle()) | ||
.agency(activity.getAgency()) | ||
.agencyType(activity.getAgencyType().getDescription()) | ||
.time(activity.getTime()) | ||
.activityThumbnail(activityThumbnail) | ||
.isLiked(isLiked) | ||
.build(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/meetup/teame/backend/domain/activity/dto/response/ReadActivitiesRes.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.meetup.teame.backend.domain.activity.dto.response; | ||
|
||
import com.meetup.teame.backend.domain.activity.entity.Activity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
public class ReadActivitiesRes { | ||
private Long curPage; | ||
private Long pageCount; | ||
private List<ActivitySummaryRes> activitySummaries; | ||
|
||
public static ReadActivitiesRes of(Long curPage, Long pageCount, List<ActivitySummaryRes> activitySummaries) { | ||
return ReadActivitiesRes.builder() | ||
.curPage(curPage) | ||
.pageCount(pageCount) | ||
.activitySummaries(activitySummaries) | ||
.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
30 changes: 30 additions & 0 deletions
30
src/main/java/com/meetup/teame/backend/domain/activity/entity/AgencyType.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,30 @@ | ||
package com.meetup.teame.backend.domain.activity.entity; | ||
|
||
import com.meetup.teame.backend.global.exception.CustomException; | ||
import com.meetup.teame.backend.global.exception.ExceptionContent; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Getter | ||
public enum AgencyType { | ||
CULTURAL_CENTER("문화센터"), | ||
WELFARE_CENTER("복지관"), | ||
CLUB("동호회"), | ||
VOLUNTEER_WORK("자원봉사"), | ||
ONE_DAY_CLASS("원데이 클래스"), | ||
ETC("기타") | ||
; | ||
|
||
private final String description; | ||
|
||
public static AgencyType of(String description) { | ||
for (AgencyType agencyType : AgencyType.values()) { | ||
if (agencyType.getDescription().equals(description)) { | ||
return agencyType; | ||
} | ||
} | ||
throw new CustomException(ExceptionContent.BAD_REQUEST_AGENCY_TYPE); | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
.../com/meetup/teame/backend/domain/activity/repository/custom/ActivityRepositoryCustom.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 |
---|---|---|
@@ -1,10 +1,18 @@ | ||
package com.meetup.teame.backend.domain.activity.repository.custom; | ||
|
||
import com.meetup.teame.backend.domain.activity.entity.Activity; | ||
import com.meetup.teame.backend.domain.activity.entity.AgencyType; | ||
import com.meetup.teame.backend.domain.personality.Personality; | ||
import com.meetup.teame.backend.domain.user.entity.User; | ||
|
||
import java.util.List; | ||
|
||
public interface ActivityRepositoryCustom { | ||
List<Activity> findActivitiesForUser(User user); | ||
|
||
List<Activity> findByAgencyAndPersonalities(long offset, long limit, AgencyType agencyType, List<Personality> personalities); | ||
|
||
List<Activity> findLikedActivities(Long userId, long offset, long limit, AgencyType agencyType, List<Personality> personalities); | ||
|
||
Long countActivities(AgencyType agencyType, List<Personality> personalities); | ||
} |
Oops, something went wrong.