Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ public class Meeting extends BaseTimeEntity {
/**
* 진행방식 소개
*/
@Column(name = "processDesc", nullable = false)
@Column(name = "processDesc")
private String processDesc;

/**
* 모임 시작 기간
*/
@Column(name = "mStartDate", nullable = false, columnDefinition = "TIMESTAMP")
@Column(name = "mStartDate", columnDefinition = "TIMESTAMP")
@Getter(AccessLevel.NONE)
private LocalDateTime mStartDate;

/**
* 모임 마감 기간
*/
@Column(name = "mEndDate", nullable = false, columnDefinition = "TIMESTAMP")
@Column(name = "mEndDate", columnDefinition = "TIMESTAMP")
@Getter(AccessLevel.NONE)
private LocalDateTime mEndDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,10 @@ public class MeetingResponseDto {
private final LocalDateTime endDate;

@Schema(description = "모임 활동 시작일", example = "2024-07-31T15:30:00", name = "mStartDate")
@NotNull
@Getter(AccessLevel.NONE)
private final LocalDateTime mStartDate;

@Schema(description = "모임 활동 종료일", example = "2024-08-25T15:30:00", name = "mEndDate")
@NotNull
@Getter(AccessLevel.NONE)
private final LocalDateTime mEndDate;

Expand All @@ -105,14 +103,6 @@ public class MeetingResponseDto {
@NotNull
private final List<String> meetingKeywordTypes;

public LocalDateTime getmStartDate() {
return mStartDate;
}

public LocalDateTime getmEndDate() {
return mEndDate;
}

public static MeetingResponseDto of(Meeting meeting, User meetingCreator, int approvedCount, LocalDateTime now,
Integer activeGeneration, Map<Integer, TagV2MeetingTagsResponseDto> allTagsResponseDto) {

Expand Down Expand Up @@ -165,4 +155,12 @@ private static List<String> extractMeetingKeywordTypes(TagV2MeetingTagsResponseD
.map(MeetingKeywordType::getValue)
.toList();
}

public LocalDateTime getmStartDate() {
return mStartDate;
}

public LocalDateTime getmEndDate() {
return mEndDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllMeetingDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllWritingPostResponseDto;
import org.sopt.makers.crew.main.internal.dto.InternalUserAppliedMeetingResponseDto;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingQueryDto;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -43,4 +45,13 @@ ResponseEntity<InternalMeetingGetAllWritingPostResponseDto> getMeetingsForWritin
@ModelAttribute @Valid @Parameter(hidden = true) PageOptionsDto pageOptionsDto
);

@Operation(summary = "[Internal] 모임 정보 조회", description = "플그 요청에 따른 맴버에 따라 크루 모임 조회를 위한 api")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "모임 목록 조회 성공")})
@Parameters(value = {
@Parameter(name = "userId", description = "찾고자 하는 userId", example = "10", required = true, schema = @Schema(type = "integer", format = "int32")),
})
ResponseEntity<InternalUserAppliedMeetingResponseDto> getAppliedMeetingInfo(
@PathVariable @Valid Integer userId
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import org.sopt.makers.crew.main.global.pagination.dto.PageOptionsDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllMeetingDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllWritingPostResponseDto;
import org.sopt.makers.crew.main.internal.dto.InternalUserAppliedMeetingResponseDto;
import org.sopt.makers.crew.main.internal.service.InternalMeetingService;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingQueryDto;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -36,4 +38,12 @@ public ResponseEntity<InternalMeetingGetAllWritingPostResponseDto> getMeetingsFo
@ModelAttribute @Valid PageOptionsDto pageOptionsDto) {
return ResponseEntity.ok().body(internalMeetingService.getMeetingsForWritingPost(pageOptionsDto));
}

@Override
@GetMapping("/{userId}")
public ResponseEntity<InternalUserAppliedMeetingResponseDto> getAppliedMeetingInfo(
@PathVariable @Valid Integer userId) {
return ResponseEntity.ok().body(
InternalUserAppliedMeetingResponseDto.from(internalMeetingService.retrieveAppliedMeetingInfo(userId)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.makers.crew.main.internal.dto;

import java.util.List;

public record InternalUserAppliedMeetingResponseDto(List<UserAppliedMeetingDto> userAppliedMeetings) {

public static InternalUserAppliedMeetingResponseDto from(List<UserAppliedMeetingDto> userAppliedMeetings) {
return new InternalUserAppliedMeetingResponseDto(userAppliedMeetings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.sopt.makers.crew.main.internal.dto;

import java.time.LocalDateTime;

import io.swagger.v3.oas.annotations.media.Schema;

public record UserAppliedMeetingDto(

@Schema(description = "모임id", example = "13")
Integer meetingId,

@Schema(description = "모임 분류, [스터디 or 행사 or 세미나 or 번쩍 or 강연]", example = "스터디")
String meetingCategory,
@Schema(description = "모임 제목", example = "오늘 21시 강남 스터디")
String meetingTitle,
@Schema(description = "모임 시작 기간")
LocalDateTime mStartTime,
@Schema(description = "모임 종료 기간")
LocalDateTime mEndTime,
@Schema(description = "스장 여부 (공동 스장도 true입니다)")
Boolean isLeader,
@Schema(description = "모임 이미지 url")
String imgUrl) {

public static UserAppliedMeetingDto of(
Integer meetingId,
String meetingCategory, String meetingTitle,
LocalDateTime mStartTime, LocalDateTime mEndTime, Boolean isLeader, String imgUrl
) {
return new UserAppliedMeetingDto(meetingId,
meetingCategory, meetingTitle, mStartTime, mEndTime, isLeader, imgUrl
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package org.sopt.makers.crew.main.internal.service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import org.sopt.makers.crew.main.entity.apply.Apply;
import org.sopt.makers.crew.main.entity.apply.ApplyRepository;
import org.sopt.makers.crew.main.entity.apply.enums.EnApplyStatus;
import org.sopt.makers.crew.main.entity.meeting.CoLeaderRepository;
import org.sopt.makers.crew.main.entity.meeting.Meeting;
import org.sopt.makers.crew.main.entity.meeting.MeetingRepository;
import org.sopt.makers.crew.main.external.playground.service.MemberBlockService;
Expand All @@ -15,6 +21,7 @@
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllMeetingDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingGetAllWritingPostResponseDto;
import org.sopt.makers.crew.main.internal.dto.InternalMeetingResponseDto;
import org.sopt.makers.crew.main.internal.dto.UserAppliedMeetingDto;
import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingQueryDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand All @@ -33,6 +40,8 @@ public class InternalMeetingService {

private final ActiveGenerationProvider activeGenerationProvider;
private final Time time;
private final CoLeaderRepository coLeaderRepository;
private final ApplyRepository applyRepository;

/**
* [for. APP BE] 모일 리스트 페이지네이션 조회 (10개)
Expand Down Expand Up @@ -88,4 +97,26 @@ public InternalMeetingGetAllWritingPostResponseDto getMeetingsForWritingPost(Pag

return InternalMeetingGetAllWritingPostResponseDto.from(meetings, pageMetaDto);
}

public List<UserAppliedMeetingDto> retrieveAppliedMeetingInfo(Integer userId) {

List<Meeting> myMeetings = meetingRepository.findAllByUserId(userId);
List<Apply> allByUserIdAndStatus = applyRepository.findAllByUserIdAndStatus(userId, EnApplyStatus.APPROVE);

return Stream.concat(myMeetings.stream(),
allByUserIdAndStatus.stream().map(Apply::getMeeting))
.map(meeting -> {
String title = meeting.getTitle();
String imgUrl = meeting.getImageURL() == null || meeting.getImageURL().isEmpty() ? null :
meeting.getImageURL().get(0).getUrl();
LocalDateTime meetingStartTIme = meeting.getmStartDate();
LocalDateTime meetingEndTIme = meeting.getmEndDate();
boolean isUserCoLeader =
coLeaderRepository.existsByMeetingIdAndUserId(meeting.getId(), userId) || meeting.getUserId()
.equals(userId);
String category = meeting.getCategory().getValue();
return UserAppliedMeetingDto.of(meeting.getId(), category, title, meetingStartTIme, meetingEndTIme,
isUserCoLeader, imgUrl);
}).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
@Mapper(componentModel = "spring")
public interface MeetingMapper {

@Mapping(source = "requestBody.files", target = "imageURL", qualifiedByName = "getImageURL")
@Mapping(source = "requestBody.category", target = "category", qualifiedByName = "getCategory")
@Mapping(source = "requestBody.startDate", target = "startDate", qualifiedByName = "getStartDate")
@Mapping(source = "requestBody.endDate", target = "endDate", qualifiedByName = "getEndDate")
@Mapping(source = "requestBody.mStartDate", target = "mStartDate", qualifiedByName = "getStartDate")
@Mapping(source = "requestBody.mEndDate", target = "mEndDate", qualifiedByName = "getEndDate")
Meeting toMeetingEntity(MeetingV2CreateAndUpdateMeetingBodyDto requestBody, Integer targetActiveGeneration,
Integer createdGeneration, User user, Integer userId);

@Named("getImageURL")
static List<ImageUrlVO> getImageURL(List<String> files) {
AtomicInteger index = new AtomicInteger(0);
Expand All @@ -44,12 +35,25 @@ static MeetingCategory getCategory(String category) {

@Named("getStartDate")
static LocalDateTime getStartDate(String date) {
if (date == null || date.isEmpty())
return null;
return LocalDateTime.parse(date + DAY_START_TIME, DateTimeFormatter.ofPattern(DAY_TIME_FORMAT));
}

@Named("getEndDate")
static LocalDateTime getEndDate(String date) {
if (date == null || date.isEmpty())
return null;
return LocalDateTime.parse(date + DAY_END_TIME, DateTimeFormatter.ofPattern(DAY_TIME_FORMAT));

}

@Mapping(source = "requestBody.files", target = "imageURL", qualifiedByName = "getImageURL")
@Mapping(source = "requestBody.category", target = "category", qualifiedByName = "getCategory")
@Mapping(source = "requestBody.startDate", target = "startDate", qualifiedByName = "getStartDate")
@Mapping(source = "requestBody.endDate", target = "endDate", qualifiedByName = "getEndDate")
@Mapping(source = "requestBody.mStartDate", target = "mStartDate", qualifiedByName = "getStartDate")
@Mapping(source = "requestBody.mEndDate", target = "mEndDate", qualifiedByName = "getEndDate")
Meeting toMeetingEntity(MeetingV2CreateAndUpdateMeetingBodyDto requestBody, Integer targetActiveGeneration,
Integer createdGeneration, User user, Integer userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,13 @@ public class MeetingV2CreateAndUpdateMeetingBodyDto {
private String desc;

@Schema(example = "소요 시간 : 1시간 예상", description = "진행 방식 소개")
@NotNull
private String processDesc;

@Schema(example = "2022.10.29", description = "모임 활동 시작 날짜", name = "mStartDate")
@NotNull
@Getter(AccessLevel.NONE)
private String mStartDate;

@Schema(example = "2022.10.30", description = "모임 활동 종료 날짜", name = "mEndDate")
@NotNull
@Getter(AccessLevel.NONE)
private String mEndDate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,18 @@ public class MeetingV2GetMeetingByIdResponseDto {
private final String desc;

@Schema(description = "진행방식 소개", example = "진행방식 설명입니다.")
@NotNull
private final String processDesc;

@Schema(description = "모임 활동 시작 시간", example = "2024-08-13T15:30:00", name = "mStartDate")
@NotNull
private final LocalDateTime mStartDate;

@Schema(description = "모임 활동 종료 시간", example = "2024-10-13T23:59:59", name = "mEndDate")
@NotNull
private final LocalDateTime mEndDate;

@Schema(description = "개설자 소개", example = "개설자 소개 입니다.")
private final String leaderDesc;

@Schema(description = "유의사항", example = "유의사항입니다.")
@NotNull
private final String note;

@Schema(description = "멘토 필요 여부", example = "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,11 @@ private Boolean checkActivityStatus(Meeting meeting) {
LocalDateTime now = time.now();
LocalDateTime mStartDate = meeting.getmStartDate();
LocalDateTime mEndDate = meeting.getmEndDate();

if (mStartDate == null || mEndDate == null) {
return true;
}

return now.isEqual(mStartDate) || (now.isAfter(mStartDate) && now.isBefore(mEndDate));
}

Expand Down