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
17 changes: 17 additions & 0 deletions app/config/src/main/java/kr/spot/config/JacksonConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kr.spot.config;

import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JacksonConfig {

@Bean
public Jackson2ObjectMapperBuilderCustomizer longToStringCustomizer() {
return builder -> {
builder.serializerByType(Long.class, ToStringSerializer.instance);
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum ErrorStatus implements BaseErrorCode {
_STUDY_ALREADY_APPLIED(400, "STUDY4006", "이미 해당 스터디에 지원한 상태입니다."),
_STUDY_ACCESS_DENIED(403, "STUDY4032", "스터디에 접근할 권한이 없습니다."),
_INVALID_STUDY_ACCESS(403, "STUDY4033", "유효하지 않은 스터디 접근입니다."),
_STUDY_IS_FULL(400, "STUDY4007", "스터디 정원이 가득 찼습니다."),

// 게시글 관련
_POST_NOT_FOUND(404, "POST404", "게시글을 찾을 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import kr.spot.domain.enums.LoginType;

public record GetMemberInfoResponse(
long memberId,
Long memberId,
String nickname,
String profileImageUrl,
LoginType loginType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public record PostDetailResponse(
PostStatsResponse stats,
LocalDateTime createdAt,
List<CommentResponse> comments,
Integer commentCount
int commentCount
) {

public record CommentResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public record PostOverview(
Long postId,
String title,
String content,
Long commentCount,
long commentCount,
PostType postType
) {

public static PostOverview of(Long postId, String title, String content,
Long commentCount, PostType postType) {
long commentCount, PostType postType) {
return new PostOverview(postId, title, content, commentCount, postType);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package kr.spot.presentation.query.dto.response;

public record PostStatsResponse(
Long likeCount,
Long viewCount,
Long commentCount
long likeCount,
long viewCount,
long commentCount
) {

public static PostStatsResponse from(Long likeCount, Long viewCount, Long commentCount) {
public static PostStatsResponse from(long likeCount, long viewCount, long commentCount) {
return new PostStatsResponse(likeCount, viewCount, commentCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public static RecentPostResponse of(List<RecentPost> recentPosts) {
public record RecentPost(
Long postId,
String title,
Long commentCount,
long commentCount,
PostType postType
) {

public static RecentPost of(Long postId, String title, Long commentCount, PostType postType) {
public static RecentPost of(Long postId, String title, long commentCount, PostType postType) {
return new RecentPost(postId, title, commentCount, postType);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package kr.spot.post.presentation.query.dto;

public record PostStatsResponse(
Long likeCount,
Long viewCount,
Long commentCount
long likeCount,
long viewCount,
long commentCount
) {

public static PostStatsResponse from(Long likeCount, Long viewCount, Long commentCount) {
public static PostStatsResponse from(long likeCount, long viewCount, long commentCount) {
return new PostStatsResponse(likeCount, viewCount, commentCount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void createReview(long studyId, long memberId, CreateReviewRequest reques
imageUrl);

Review review = Review.of(idGenerator.nextId(), studyId, writerInfo, content,
request.isPrivateReview());
request.isPrivate());
reviewRepository.save(review);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,4 @@ public record CreateReviewRequest(
Boolean isPrivate
) {

public boolean isPrivateReview() {
return Boolean.TRUE.equals(isPrivate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public record GetReviewListResponse(
List<ReviewResponse> reviews,
boolean hasNext,
Long nextCursor,
Long totalElements
long totalElements
) {

public record ReviewResponse(
Expand Down Expand Up @@ -55,14 +55,14 @@ public static ContentResponse from(String activity, String learned, String encou
}

public record ReactionCountResponse(
Long fireCount,
Long heartCount,
Long starCount,
Long smileCount
long fireCount,
long heartCount,
long starCount,
long smileCount
) {

public static ReactionCountResponse from(Long fireCount, Long heartCount, Long starCount,
Long smileCount) {
public static ReactionCountResponse from(long fireCount, long heartCount, long starCount,
long smileCount) {
return new ReactionCountResponse(fireCount, heartCount, starCount, smileCount);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public void stopAttendance(long studyId, long scheduleId, long memberId) {

Schedule schedule = scheduleRepository.getById(scheduleId);
schedule.stopAttendance(studyId);

markAbsentForUndecidedAttendances(scheduleId);
}

private void markAbsentForUndecidedAttendances(long scheduleId) {
List<Attendance> attendances = attendanceRepository.findAllByScheduleId(scheduleId);
attendances.forEach(Attendance::markAbsentIfUndecided);
}

public void checkAttendance(String encryptedToken, long memberId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public void markAttendance(AttendanceStatus status) {
this.attendanceStatus = status;
this.attendedAt = LocalDateTime.now();
}

public void markAbsentIfUndecided() {
if (this.attendanceStatus == AttendanceStatus.UNDECIDED) {
this.attendanceStatus = AttendanceStatus.ABSENT;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public List<Schedule> findUpcomingSchedules(Long studyId, int limit) {
.selectFrom(schedule)
.where(
schedule.studyId.eq(studyId),
schedule.startAt.goe(now)
schedule.endAt.goe(now)
)
.orderBy(schedule.startAt.asc())
.limit(limit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public static GetScheduleListResponse from(List<ScheduleResponse> schedules) {
}

public record ScheduleResponse(
long scheduleId,
Long scheduleId,
String title,
LocalDateTime startAt,
LocalDateTime endAt,
boolean isNow
) {

public static ScheduleResponse from(long scheduleId, String title,
public static ScheduleResponse from(Long scheduleId, String title,
LocalDateTime startAt, LocalDateTime endAt, boolean isNow) {
return new ScheduleResponse(scheduleId, title, startAt, endAt, isNow);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public GetMyAppliedStudyResponse getMyAppliedStudy(Long memberId) {
);
}

@Deprecated(forRemoval = true)
public GetAppliesResponse getStudyApplications(Long studyId, Long requesterId) {

studyAccessValidator.validateStudyLeader(studyId, requesterId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private Statistics buildStatistics(Study study, StudyStats stats, long studyId,
private GetStudyInfoResponse toStudyInfoResponse(Study study, List<Category> categories,
Statistics statistics) {
return GetStudyInfoResponse.of(
study.getId(),
study.getName(),
study.getDescription(),
study.getImageUrl(),
Expand Down
14 changes: 14 additions & 0 deletions modules/study/src/main/java/kr/spot/study/domain/Study.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,23 @@ private static void validateMaxMembers(Integer maxMembers) {
}

public void processApplication(StudyMember application, Long requesterId, Decision decision) {
validateIsFull();
validateIsStudyOwner(requesterId);
validateIsValidStatusToProcessApply(application);
application.decide(decision);
increaseMemberCountIfApproved(decision);
}

private void validateIsFull() {
if (this.currentMembers >= this.maxMembers) {
throw new GeneralException(ErrorStatus._STUDY_IS_FULL);
}
}

private void increaseMemberCountIfApproved(Decision decision) {
if (decision == Decision.APPROVE) {
this.currentMembers += 1;
}
}

public void validateIsStudyOwner(Long requesterId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public ResponseEntity<ApiResponse<GetMyAppliedStudyResponse>> getMyAppliedStudie
getStudyApplicationService.getMyAppliedStudy(memberId)));
}

@Operation(summary = "스터디 신청 내역 조회", description = "특정 스터디의 신청 내역을 조회합니다. (스터디장 권한)")
@Deprecated
@Operation(summary = "[사용 X] 스터디 신청 내역 조회", description = "특정 스터디의 신청 내역을 조회합니다. (스터디장 권한)")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "조회 성공", content = @Content(schema = @Schema(implementation = GetAppliesResponse.class)))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
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;

@Tag(name = "스터디 조회")
@RestController
@RequestMapping("/api/studies")
@RequestMapping("/api/studies/{studyId}")
@RequiredArgsConstructor
public class StudyQueryController {

Expand All @@ -28,7 +28,7 @@ public class StudyQueryController {
description = "스터디의 상세 정보를 조회합니다.")
@GetMapping("/info")
public ResponseEntity<ApiResponse<GetStudyInfoResponse>> getStudyInfo(
@RequestParam Long studyId,
@PathVariable Long studyId,
@CurrentMember @Parameter(hidden = true) Long viewerId
) {
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._OK,
Expand All @@ -39,7 +39,7 @@ public ResponseEntity<ApiResponse<GetStudyInfoResponse>> getStudyInfo(
description = "스터디의 멤버들을 조회합니다.")
@GetMapping("/members")
public ResponseEntity<ApiResponse<GetStudyMembersResponse>> getStudyMembers(
@RequestParam Long studyId
@PathVariable Long studyId
) {
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._OK,
getStudyDetailService.getStudyMembers(studyId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import kr.spot.study.domain.enums.Category;

public record GetStudyInfoResponse(
Long id,
String title,
String description,
String thumbnailUrl,
Expand All @@ -12,13 +13,15 @@ public record GetStudyInfoResponse(
) {

public static GetStudyInfoResponse of(
Long id,
String title,
String description,
String thumbnailUrl,
List<Category> categories,
Statistics statistics
) {
return new GetStudyInfoResponse(
id,
title,
description,
thumbnailUrl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ public record GetStudyOverviewResponse(
List<StudyOverview> content,
boolean hasNext,
Long nextCursor,
Long totalElements
long totalElements
) {

public static GetStudyOverviewResponse of(
List<StudyOverview> content,
boolean hasNext,
Long nextCursor,
Long totalElements
long totalElements
) {
return new GetStudyOverviewResponse(content, hasNext, nextCursor, totalElements);
}

public record StudyOverview(
long id,
Long id,
String name,
String description,
int maxMembers,
Expand All @@ -31,7 +31,7 @@ public record StudyOverview(
) {

public static StudyOverview of(
long id,
Long id,
String title,
String description,
int totalMembers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TodoQueryController {
@GetMapping("/members/{memberId}")
public ResponseEntity<ApiResponse<GetTodoListResponse>> getTodosByDate(
@Parameter(description = "스터디 ID", required = true) @PathVariable Long studyId,
@PathVariable @Parameter(hidden = true) Long memberId,
@PathVariable Long memberId,
@Parameter(description = "조회할 날짜 (ISO 8601 표준)", example = "2025-01-15")
@RequestParam @DateTimeFormat(iso = ISO.DATE) LocalDate date) {
GetTodoListResponse response = getTodoService.getTodosByDate(studyId, memberId, date);
Expand Down
Loading