Skip to content

Commit

Permalink
[#125] feat: 모임 홈 개선 - 모임 둘러보기 API 개발
Browse files Browse the repository at this point in the history
  • Loading branch information
rdd9223 committed Feb 20, 2024
1 parent 0bc31eb commit a888fbc
Show file tree
Hide file tree
Showing 13 changed files with 241 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.hibernate.annotations.Type;
import org.sopt.makers.crew.main.entity.apply.Apply;
import org.sopt.makers.crew.main.entity.meeting.converter.MeetingCategoryConverter;
import org.sopt.makers.crew.main.entity.meeting.enums.EnMeetingStatus;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart;
import org.sopt.makers.crew.main.entity.meeting.vo.ImageUrlVO;
Expand Down Expand Up @@ -99,7 +100,7 @@ public class Meeting {
* 모집 인원
*/
@Column(name = "capacity", nullable = false)
private int capacity;
private Integer capacity;

/**
* 모임 소개
Expand Down Expand Up @@ -147,19 +148,19 @@ public class Meeting {
* 멘토 필요 여부
*/
@Column(name = "isMentorNeeded", nullable = false)
private boolean isMentorNeeded;
private Boolean isMentorNeeded;

/**
* 활동 기수만 참여 가능한지 여부
*/
@Column(name = "canJoinOnlyActiveGeneration", nullable = false)
private boolean canJoinOnlyActiveGeneration;
private Boolean canJoinOnlyActiveGeneration;

/**
* 모임 기수
*/
@Column(name = "createdGeneration", nullable = false)
private int createdGeneration;
private Integer createdGeneration;

/**
* 대상 활동 기수
Expand All @@ -170,17 +171,10 @@ public class Meeting {
/**
* 모임 참여 가능한 파트
*/
@Type(
value = EnumArrayType.class,
parameters = @Parameter(
name = AbstractArrayType.SQL_ARRAY_TYPE,
value = "meeting_joinableparts_enum"
)
)
@Column(
name = "joinableParts",
columnDefinition = "meeting_joinableparts_enum[]"
)
@Type(value = EnumArrayType.class,
parameters = @Parameter(name = AbstractArrayType.SQL_ARRAY_TYPE,
value = "meeting_joinableparts_enum"))
@Column(name = "joinableParts", columnDefinition = "meeting_joinableparts_enum[]")
private MeetingJoinablePart[] joinableParts;

/**
Expand All @@ -190,13 +184,11 @@ public class Meeting {
private List<Post> posts;

@Builder
public Meeting(User user, int userId, String title, MeetingCategory category,
List<ImageUrlVO> imageURL, LocalDateTime startDate, LocalDateTime endDate, int capacity,
String desc,
String processDesc, LocalDateTime mStartDate, LocalDateTime mEndDate, String leaderDesc,
String targetDesc,
String note, boolean isMentorNeeded, boolean canJoinOnlyActiveGeneration,
int createdGeneration,
public Meeting(User user, Integer userId, String title, MeetingCategory category,
List<ImageUrlVO> imageURL, LocalDateTime startDate, LocalDateTime endDate, Integer capacity,
String desc, String processDesc, LocalDateTime mStartDate, LocalDateTime mEndDate,
String leaderDesc, String targetDesc, String note, Boolean isMentorNeeded,
Boolean canJoinOnlyActiveGeneration, Integer createdGeneration,
Integer targetActiveGeneration, MeetingJoinablePart[] joinableParts) {
this.user = user;
this.userId = userId;
Expand Down Expand Up @@ -227,4 +219,20 @@ public void addApply(Apply apply) {
public void addPost(Post post) {
posts.add(post);
}

/**
* 모임 모집상태 확인
*
* @return 모임 모집상태
*/
public Integer getMeetingStatus() {
LocalDateTime now = LocalDateTime.now();
if (now.isBefore(startDate)) {
return EnMeetingStatus.BEFORE_START.getValue();
} else if (now.isBefore(endDate)) {
return EnMeetingStatus.APPLY_ABLE.getValue();
} else {
return EnMeetingStatus.RECRUITMENT_COMPLETE.getValue();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.sopt.makers.crew.main.entity.meeting.enums;

import java.util.Arrays;
import org.sopt.makers.crew.main.common.exception.BadRequestException;

/** 모임 상태 */
public enum EnMeetingStatus {
/** 시작 전 */
BEFORE_START(0),

/** 지원 가능 */
APPLY_ABLE(1),

/** 모집 완료 */
RECRUITMENT_COMPLETE(2);

private final int value;

EnMeetingStatus(int value) {
this.value = value;
}

public static EnMeetingStatus ofValue(int dbData) {
return Arrays.stream(EnMeetingStatus.values()).filter(v -> v.getValue() == (dbData)).findFirst()
.orElseThrow(() -> new BadRequestException(
String.format("EnMeetingStatus 클래스에 value = [%s] 값을 가진 enum 객체가 없습니다.", dbData)));
}

public int getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

import java.util.Arrays;
import org.sopt.makers.crew.main.common.exception.BadRequestException;
import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus;

public enum MeetingCategory {
STUDY("스터디"),
LECTURE("강연"),
LIGHTNING("번개"),
EVENT("행사");

private final String value;

MeetingCategory(String value) {
this.value = value;
}

public static MeetingCategory ofValue(String dbData) {
return Arrays.stream(MeetingCategory.values())
.filter(v -> v.getValue().equals(dbData))
.findFirst()
.orElseThrow(() -> new BadRequestException(
String.format("MeetingCategory 클래스에 value = [%s] 값을 가진 enum 객체가 없습니다.", dbData)));
}

public String getValue() {
return value;
}
STUDY("스터디"),

LECTURE("강연"),

LIGHTNING("번개"),

EVENT("행사");

private final String value;

MeetingCategory(String value) {
this.value = value;
}

public static MeetingCategory ofValue(String dbData) {
return Arrays.stream(MeetingCategory.values()).filter(v -> v.getValue().equals(dbData))
.findFirst().orElseThrow(() -> new BadRequestException(
String.format("MeetingCategory 클래스에 value = [%s] 값을 가진 enum 객체가 없습니다.", dbData)));
}

public String getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
@RequiredArgsConstructor
public class ImageUrlVO {

private final Integer id;
private final String url;
private Integer id;
private String url;
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ public class Post {
private List<Report> reports;

@Builder
public Post(String title, String contents,
String[] images, User user, Meeting meeting) {
public Post(String title, String contents, String[] images, User user, Meeting meeting) {
this.title = title;
this.contents = contents;
this.viewCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ public interface UserRepository extends JpaRepository<User, Integer> {
Optional<User> findByOrgId(Integer orgId);

default User findByIdOrThrow(Integer userId) {
return findById(userId)
.orElseThrow(() -> new UnAuthorizedException());
return findById(userId).orElseThrow(() -> new UnAuthorizedException());
}

default User findByOrgIdOrThrow(Integer orgUserId) {
return findByOrgId(orgUserId)
.orElseThrow(() -> new UnAuthorizedException());
return findByOrgId(orgUserId).orElseThrow(() -> new UnAuthorizedException());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@ToString
public class UserActivityVO {

private final String part;
private final int generation;
private String part;
private int generation;

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ public class PushNotificationService {
private final PushNotificationServerClient pushServerClient;

public void sendPushNotification(PushNotificationRequestDto request) {
PushNotificationResponseDto response = pushServerClient.sendPushNotification(
pushNotificationApiKey,
PUSH_NOTIFICATION_ACTION.getValue(),
UUID.randomUUID().toString(),
service,
request
);
PushNotificationResponseDto response =
pushServerClient.sendPushNotification(pushNotificationApiKey,
PUSH_NOTIFICATION_ACTION.getValue(), UUID.randomUUID().toString(), service, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import java.security.Principal;
import java.util.List;
import org.sopt.makers.crew.main.common.util.UserUtil;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto;
import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetAllMeetingByOrgUserDto;
import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetMeetingBannerResponseDto;
import org.sopt.makers.crew.main.meeting.v2.service.MeetingV2Service;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -30,17 +34,24 @@ public class MeetingV2Controller {
@Operation(summary = "플레이그라운드 마이페이지 내 모임 정보 조회")
@GetMapping("/org-user")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "204", description = "참여했던 모임이 없습니다.", content = @Content),
})
@Parameters({
@Parameter(name = "page", description = "페이지, default = 1", example = "1"),
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "204", description = "참여했던 모임이 없습니다.", content = @Content),})
@Parameters({@Parameter(name = "page", description = "페이지, default = 1", example = "1"),
@Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50"),
@Parameter(name = "orgUserId", description = "플레이그라운드 유저 id", example = "0")
})
@Parameter(name = "orgUserId", description = "플레이그라운드 유저 id", example = "0")})
public ResponseEntity<MeetingV2GetAllMeetingByOrgUserDto> getAllMeetingByOrgUser(
@ModelAttribute @Parameter(hidden = true) MeetingV2GetAllMeetingByOrgUserQueryDto queryDto) {
return ResponseEntity.ok(meetingV2Service.getAllMeetingByOrgUser(queryDto));
}

@Operation(summary = "모임 둘러보기 조회")
@GetMapping("/banner")
@ResponseStatus(HttpStatus.OK)
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(responseCode = "204", description = "모임이 없습니다.", content = @Content),})
public ResponseEntity<List<MeetingV2GetMeetingBannerResponseDto>> getMeetingBanner(
Principal principal) {
UserUtil.getUserId(principal);
return ResponseEntity.ok(meetingV2Service.getMeetingBanner());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.sopt.makers.crew.main.meeting.v2.dto.response;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingCategory;
import org.sopt.makers.crew.main.entity.meeting.enums.MeetingJoinablePart;
import org.sopt.makers.crew.main.entity.meeting.vo.ImageUrlVO;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(staticName = "of")
public class MeetingV2GetMeetingBannerResponseDto {

/** 모임 ID */
private Integer id;
/** 유저 Crew ID */
private Integer userId;
/** 모임 제목 */
private String title;
/**
* 모임 카테고리
*
* @apiNote '스터디', '행사'
*/
private MeetingCategory category;
/**
* 썸네일 이미지
*
* @apiNote 여러개여도 첫번째 이미지만 사용
*/
private List<ImageUrlVO> imageURL;
/** 모임 지원 시작일 */
private LocalDateTime startDate;
/** 모임 지원 종료일 */
private LocalDateTime endDate;
/** 모임 활동 시작일 */
private LocalDateTime mStartDate;
/** 모임 활동 종료일 */
private LocalDateTime mEndDate;
/** 모임 인원 */
private Integer capacity;
/** 최근 활동 일자 */
private Optional<LocalDateTime> recentActivityDate;
/** 모임 타겟 기수 */
private Integer targetActiveGeneration;
/** 모임 타겟 파트 */
private MeetingJoinablePart[] joinableParts;
/** 지원자 수 */
private Integer applicantCount;
/** 가입된 지원자 수 */
private Integer approvedUserCount;
/** 개설자 정보 */
private Optional<MeetingV2GetMeetingBannerResponseUserDto> user;
/** 미팅 상태 */
private Integer status;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.makers.crew.main.meeting.v2.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor(staticName = "of")
public class MeetingV2GetMeetingBannerResponseUserDto {
/** 개설자 crew ID */
private Integer id;
/** 개설자 */
private String name;
/** 개설자 playground ID */
private Integer orgId;
/** 프로필 사진 */
private String profileImage;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.sopt.makers.crew.main.meeting.v2.service;

import java.util.List;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto;
import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetAllMeetingByOrgUserDto;
import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetMeetingBannerResponseDto;

public interface MeetingV2Service {

MeetingV2GetAllMeetingByOrgUserDto getAllMeetingByOrgUser(
MeetingV2GetAllMeetingByOrgUserQueryDto queryDto);

List<MeetingV2GetMeetingBannerResponseDto> getMeetingBanner();
}
Loading

0 comments on commit a888fbc

Please sign in to comment.