Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into feat/34/mypage-schedule
Browse files Browse the repository at this point in the history
# 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
nohy6630 committed May 16, 2024
2 parents e8ae83c + ba01817 commit f422082
Show file tree
Hide file tree
Showing 38 changed files with 1,001 additions and 110 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ dependencies {

//MongoDB
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'

//S3
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
}

tasks.named('test') {
Expand Down
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);
}
}
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<>();
}
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();
}
}
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)
{

}
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();
}
}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.meetup.teame.backend.domain.chatroom.entity.DirectChatRoom;
import com.meetup.teame.backend.domain.chatroom.entity.GroupChatRoom;
import com.meetup.teame.backend.domain.experience.entity.ExperienceType;
import com.meetup.teame.backend.domain.like.entity.ActivityLike;
import com.meetup.teame.backend.domain.personality.Personality;
import jakarta.persistence.*;
Expand All @@ -25,6 +26,13 @@ public class Activity {
@Comment("활동 제목")
private String title;

@Comment("활동 제공 기관")
private String agency;

@Comment("기관 유형")
@Enumerated(EnumType.STRING)
private AgencyType agencyType;

@Comment("활동 장소")
private String location;

Expand All @@ -43,6 +51,10 @@ public class Activity {
@Comment("썸네일 이미지")
private String imageUrl;

@ElementCollection
@Comment("활동 사진들")
private List<String> activityImgs;

@ElementCollection
@Enumerated(EnumType.STRING)
private List<Personality> personalities;
Expand Down
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);
}

}
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);
}
Loading

0 comments on commit f422082

Please sign in to comment.