Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c27d664
[refactor] 게시물 공통 인터페이스 CountUpdatable로 이름 변경 (#159)
hd0rable Aug 6, 2025
51a57c8
[feat] 관련 에러 코드 추가 (#159)
hd0rable Aug 6, 2025
9756e36
[feat] 게시물 도메인 좋아요 업데이트 함수 구현 (#159)
hd0rable Aug 6, 2025
08305f9
[feat] 피드 좋아요 상태 변경 컨트롤러 작성 (#159)
hd0rable Aug 6, 2025
52a6f6f
[feat] 피드 좋아요 상태 변경 request dto 작성 (#159)
hd0rable Aug 6, 2025
633a964
[feat] 피드 좋아요 상태 변경 reponse dto 작성 (#159)
hd0rable Aug 6, 2025
e987799
[refactor] 게시물 공통 인터페이스 CountUpdatable로 이름 변경 (#159)
hd0rable Aug 6, 2025
b2d746d
[feat] 게시물 테스트용 좋아요 업데이트 함수 추가 (#159)
hd0rable Aug 6, 2025
c83cdf4
[feat] 게시글 좋아요 접근 정책 인터페이스 작성(#159)
hd0rable Aug 6, 2025
142649f
[feat] 게시글 좋아요 접근 정책 config 작성 (#159)
hd0rable Aug 6, 2025
c66515a
[feat] 피드 좋아요 접근 정책 구현 (#159)
hd0rable Aug 6, 2025
5e0456e
[feat] 게시글 좋아요 상태 변경 command 작성 (#159)
hd0rable Aug 6, 2025
6e6f0d2
[feat] 게시글 좋아요 상태 변경 PostIsLikeResult 작성 (#159)
hd0rable Aug 6, 2025
455d85a
[feat] 게시글 좋아요 접근 정책 PostLikeAuthorizationValidator 작성(#159)
hd0rable Aug 6, 2025
6c9b7dc
[feat] PostLikeCommandPersistenceAdapter 관련 함수 추가(#159)
hd0rable Aug 6, 2025
f539ee3
[feat] PostLikeCommandPort 관련 함수 추가(#159)
hd0rable Aug 6, 2025
0440180
[feat] PostLikeJpaRepository 관련 함수 추가(#159)
hd0rable Aug 6, 2025
879df31
[feat] PostLikeQueryPersistenceAdapter.isLikedPostByUser 함수 추가(#159)
hd0rable Aug 6, 2025
b8a54ba
[feat] PostLikeQueryPort.isLikedPostByUser 함수 추가(#159)
hd0rable Aug 6, 2025
0d812fd
[feat] 게시글 좋아요 상태 변경 PostLikeUseCase 유즈케이스 작성 (#159)
hd0rable Aug 6, 2025
7854ac9
[feat] 게시글 좋아요 상태 변경 유즈케이스 구현체 서비스 작성 (#159)
hd0rable Aug 6, 2025
626d4e1
[refactor] 안쓰는 함수 삭제 (#159)
hd0rable Aug 6, 2025
ffd4a20
[feat] 방 게시글 좋아요 상태 변경 컨트롤러 작성 (#163)
hd0rable Aug 6, 2025
2af4c79
[refactor] 게시물 공통 인터페이스 CountUpdatable로 이름 변경 (#159)
hd0rable Aug 6, 2025
36234fe
[refactor] 게시물 공통 인터페이스 CountUpdatable로 이름 변경 (#159)
hd0rable Aug 6, 2025
369a6d4
[feat] 방 게시물 좋아요 상태 변경 request dto 작성 (#159)
hd0rable Aug 6, 2025
b12f92a
[feat] 방 게시물 좋아요 상태 변경 response dto 작성 (#159)
hd0rable Aug 6, 2025
951fa12
[feat] 방 게시물 좋아요 접근 정책 작성 (#159)
hd0rable Aug 6, 2025
d2a74a2
[feat] 방 게시물타입 enum 작성 (#159)
hd0rable Aug 6, 2025
1083e7e
[feat] 관련 api 스웨거 에러코드 추가 (#159)
hd0rable Aug 6, 2025
97f7fac
[test] 피드 좋아요 상태 변경 통합 테스트 코드 작성 (#159)
hd0rable Aug 6, 2025
ece397c
[test] 피드 좋아요 상태 변경 관련 피드 도메인 단위 테스트 코드 작성 (#159)
hd0rable Aug 6, 2025
a55267e
[test] 관련 팩토리 메서드 추가 (#159)
hd0rable Aug 6, 2025
c49896b
[test] 방 게시물 좋아요 상태 변경 통합 테스트 코드 작성 (#163)
hd0rable Aug 6, 2025
d66129e
[test] 방 게시물 좋아요 상태 변경 관련 컨트롤러단위 테스트 코드 작성 (#163)
hd0rable Aug 6, 2025
cd7881b
[test] 방 게시물 좋아요 상태 변경 관련 레코드 도메인 단위 테스트 코드 작성 (#163)
hd0rable Aug 6, 2025
7d1959e
[test] 방 게시물 좋아요 상태 변경 관련 투표 도메인 단위 테스트 코드 작성 (#163)
hd0rable Aug 6, 2025
9f46344
[refactor] 변수 이름 변경 (#163)
hd0rable Aug 6, 2025
fc9421e
[refactor] 스트림 대신 적은 수의경우 직접 비교 성능 최적화(#163)
hd0rable Aug 6, 2025
5a926bd
[refactor] feedId 오타 수정 (#163)
hd0rable Aug 6, 2025
27e85d9
[refactor] roomPost 오타 수정 (#163)
hd0rable Aug 6, 2025
3b2e896
[refactor] 비공개 게시글 일 경우 댓글,좋아요 검증 함수 합치기 (#163)
hd0rable Aug 6, 2025
96e7bb2
[docs] 진행중인 방 상세보기 명세 수정 (#159)
buzz0331 Aug 7, 2025
c15a9f5
[refactor] 게시물 수 증가 도메인 서비스 작성(#159)
hd0rable Aug 7, 2025
09f81bd
[refactor] 게시물 수 증가 도메인 서비스 이용한 로직으로 수정 (#159)
hd0rable Aug 7, 2025
1daf813
[refactor] 테스트코드 수정 (#159)
hd0rable Aug 7, 2025
e6fcdbe
[fix] 스웨거 허용 주소 추가
hd0rable Aug 7, 2025
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 @@ -6,7 +6,7 @@
import konkuk.thip.comment.application.service.validator.CommentAuthorizationValidator;
import konkuk.thip.comment.domain.Comment;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import konkuk.thip.common.post.PostType;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -34,7 +34,7 @@ public Long createComment(CommentCreateCommand command) {
PostType type = PostType.from(command.postType());

// 2. 게시물 타입에 맞게 조회
CommentCountUpdatable post = postHandler.findPost(type, command.postId());
CountUpdatable post = postHandler.findPost(type, command.postId());
// 2-1. 게시글 타입에 따른 댓글 생성 권한 검증
commentAuthorizationValidator.validateUserCanAccessPostForComment(type, post, command.userId());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import konkuk.thip.comment.application.port.out.CommentLikeCommandPort;
import konkuk.thip.comment.application.service.validator.CommentAuthorizationValidator;
import konkuk.thip.comment.domain.Comment;
import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -28,7 +28,7 @@ public Long deleteComment(Long commentId, Long userId) {
// 1. 댓글 조회 및 권한 검증
Comment comment = commentCommandPort.getByIdOrThrow(commentId);
// 1-1. 게시글 타입에 따른 댓글 삭제 권한 검증
CommentCountUpdatable post = postHandler.findPost(comment.getPostType(), comment.getTargetPostId());
CountUpdatable post = postHandler.findPost(comment.getPostType(), comment.getTargetPostId());
commentAuthorizationValidator.validateUserCanAccessPostForComment(comment.getPostType(), post, userId);

// 2. 댓글 삭제 권한 검증 및 소프트 딜리트
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import konkuk.thip.comment.application.port.out.CommentLikeQueryPort;
import konkuk.thip.comment.application.service.validator.CommentAuthorizationValidator;
import konkuk.thip.comment.domain.Comment;
import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -32,7 +32,7 @@ public CommentIsLikeResult changeLikeStatusComment(CommentIsLikeCommand command)
// 1. 댓글 조회 및 검증 (존재 여부)
Comment comment = commentCommandPort.getByIdOrThrow(command.commentId());
// 1-1. 게시글 타입에 따른 댓글 좋아요 권한 검증
CommentCountUpdatable post = postHandler.findPost(comment.getPostType(), comment.getTargetPostId());
CountUpdatable post = postHandler.findPost(comment.getPostType(), comment.getTargetPostId());
commentAuthorizationValidator.validateUserCanAccessPostForComment(comment.getPostType(), post, command.userId());

// 2. 유저가 해당 댓글에 대해 좋아요 했는지 조회
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package konkuk.thip.comment.application.service.policy;

import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;

public interface CommentAccessPolicy {
void validateCommentAccess(CommentCountUpdatable post, Long userId);
void validateCommentAccess(CountUpdatable post, Long userId);
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package konkuk.thip.comment.application.service.policy;

import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.feed.domain.Feed;
import org.springframework.stereotype.Component;

@Component
public class FeedCommentAccessPolicy implements CommentAccessPolicy {

@Override
public void validateCommentAccess(CommentCountUpdatable post, Long userId) {
public void validateCommentAccess(CountUpdatable post, Long userId) {
Feed feed = (Feed) post;
feed.validateCreateComment(userId);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package konkuk.thip.comment.application.service.policy;

import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.room.application.service.validator.RoomParticipantValidator;
import konkuk.thip.room.domain.RoomPost;
import lombok.RequiredArgsConstructor;
Expand All @@ -13,7 +13,7 @@ public class RoomPostCommentAccessPolicy implements CommentAccessPolicy {
private final RoomParticipantValidator roomParticipantValidator;

@Override
public void validateCommentAccess(CommentCountUpdatable post, Long userId) {
public void validateCommentAccess(CountUpdatable post, Long userId) {
RoomPost roomPost = (RoomPost) post;
roomParticipantValidator.validateUserIsRoomMember(roomPost.getRoomId(), userId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import konkuk.thip.comment.application.service.policy.CommentAccessPolicy;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.PostType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
Expand All @@ -15,14 +15,14 @@
@RequiredArgsConstructor
public class CommentAuthorizationValidator {

private final Map<PostType, CommentAccessPolicy> policyMap;
private final Map<PostType, CommentAccessPolicy> commentAccessPolicyMap;

public void validateUserCanAccessPostForComment(PostType type, CommentCountUpdatable post, Long userId) {
public void validateUserCanAccessPostForComment(PostType type, CountUpdatable post, Long userId) {
getPolicy(type).validateCommentAccess(post, userId);
}

private CommentAccessPolicy getPolicy(PostType type) {
CommentAccessPolicy policy = policyMap.get(type);
CommentAccessPolicy policy = commentAccessPolicyMap.get(type);
if (policy == null) {
throw new InvalidStateException(POST_TYPE_NOT_MATCH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public enum ErrorCode implements ResponseCode {
ROOM_MEMBER_COUNT_EXCEEDED(HttpStatus.BAD_REQUEST, 100006, "방의 최대 인원 수를 초과했습니다."),
ROOM_MEMBER_COUNT_UNDERFLOW(HttpStatus.BAD_REQUEST, 100007, "방의 인원 수가 1 이하(방장 포함)입니다."),
ROOM_IS_EXPIRED(HttpStatus.BAD_REQUEST, 100008, "방이 만료되었습니다."),
ROOM_POST_TYPE_NOT_MATCH(HttpStatus.BAD_REQUEST, 100009, "일치하는 방 게시물 타입 이름이 없습니다. [RECORD, VOTE] 중 하나여야 합니다."),

/**
* 110000 : vote error
Expand Down Expand Up @@ -167,6 +168,14 @@ public enum ErrorCode implements ResponseCode {
*/
POST_TYPE_NOT_MATCH(HttpStatus.BAD_REQUEST, 180000, "일치하는 게시물 타입 이름이 없습니다. [FEED, RECORD, VOTE] 중 하나여야 합니다."),

/**
* 185000 : PostLike error
*
*/
POST_LIKE_COUNT_UNDERFLOW(HttpStatus.BAD_REQUEST, 185000, "좋아요 수는 0 이하로 감소할 수 없습니다."),
POST_ALREADY_LIKED(HttpStatus.BAD_REQUEST, 185001, "사용자가 이미 좋아요한 게시물입니다."),
POST_NOT_LIKED_CANNOT_CANCEL(HttpStatus.BAD_REQUEST, 185002, "사용자가 좋아요하지 않은 게시물은 좋아요 취소 할 수 없습니다."),

/**
* 190000 : Comment error
*/
Expand Down

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/konkuk/thip/common/post/CountUpdatable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package konkuk.thip.common.post;

import konkuk.thip.post.domain.service.PostCountService;

public interface CountUpdatable { //TODO 패키지 구조 충돌안나게 한번에 옮기기
void increaseCommentCount();
void decreaseCommentCount();
void updateLikeCount(PostCountService postCountService, boolean isLike);
Long getId();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p3: getId는 어차피 공통으로 getter를 사용하는 것 같아서 굳이 없어도 될 것 같습니다!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 이거 공통로직시에 updatable에서 뽑아올때 필요합니닷!!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 흐음 이건 어쩔수 없이 열어둬야 될 것 같네여 🤔

}
12 changes: 0 additions & 12 deletions src/main/java/konkuk/thip/common/post/PostType.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,4 @@ public static PostType from(String type) {
new InvalidStateException(POST_TYPE_NOT_MATCH)
);
}

public boolean isFeed() {
return this == FEED;
}

public boolean isRecord() {
return this == RECORD;
}

public boolean isVote() {
return this == VOTE;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package konkuk.thip.common.post.service;

import konkuk.thip.common.annotation.HelperService;
import konkuk.thip.common.post.CommentCountUpdatable;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.PostType;
import konkuk.thip.feed.application.port.out.FeedCommandPort;
import konkuk.thip.feed.domain.Feed;
Expand All @@ -19,15 +19,15 @@ public class PostHandler {
private final RecordCommandPort recordCommandPort;
private final VoteCommandPort voteCommandPort;

public CommentCountUpdatable findPost(PostType type, Long postId) {
public CountUpdatable findPost(PostType type, Long postId) {
return switch (type) {
case FEED -> feedCommandPort.getByIdOrThrow(postId);
case RECORD -> recordCommandPort.getByIdOrThrow(postId);
case VOTE -> voteCommandPort.getByIdOrThrow(postId);
};
}

public void updatePost(PostType type, CommentCountUpdatable post) {
public void updatePost(PostType type, CountUpdatable post) {
switch (type) {
case FEED -> feedCommandPort.update((Feed) post);
case RECORD -> recordCommandPort.update((Record) post);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public enum SwaggerResponseDescription {
ROOM_GET_DEADLINE_POPULAR(new LinkedHashSet<>(Set.of(
CATEGORY_NOT_MATCH
))),
CHANGE_ROOM_LIKE_STATE(new LinkedHashSet<>(Set.of(
USER_NOT_FOUND,
RECORD_NOT_FOUND,
VOTE_NOT_FOUND,
POST_ALREADY_LIKED,
POST_NOT_LIKED_CANNOT_CANCEL,
POST_LIKE_COUNT_UNDERFLOW,
ROOM_ACCESS_FORBIDDEN,
ROOM_POST_TYPE_NOT_MATCH
))),


// Record
Expand Down Expand Up @@ -174,6 +184,14 @@ public enum SwaggerResponseDescription {
BOOK_NOT_FOUND,
FEED_CAN_NOT_SHOW_PRIVATE_ONE
))),
CHANGE_FEED_LIKE_STATE(new LinkedHashSet<>(Set.of(
USER_NOT_FOUND,
FEED_NOT_FOUND,
POST_ALREADY_LIKED,
POST_NOT_LIKED_CANNOT_CANCEL,
POST_LIKE_COUNT_UNDERFLOW,
FEED_ACCESS_FORBIDDEN
))),

// Comment
COMMENT_CREATE(new LinkedHashSet<>(Set.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import konkuk.thip.comment.application.service.policy.FeedCommentAccessPolicy;
import konkuk.thip.comment.application.service.policy.RoomPostCommentAccessPolicy;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.application.service.policy.FeedLikeAccessPolicy;
import konkuk.thip.post.application.service.policy.PostLikeAccessPolicy;
import konkuk.thip.post.application.service.policy.RoomPostLikeAccessPolicy;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -12,11 +15,14 @@

@Configuration
@RequiredArgsConstructor
public class CommentAccessPolicyConfig {
public class PostAccessPolicyConfig {

private final FeedCommentAccessPolicy feedCommentPolicy;
private final RoomPostCommentAccessPolicy roomCommentPolicy;

private final FeedLikeAccessPolicy feedLikePolicy;
private final RoomPostLikeAccessPolicy roomPostLikePolicy;

@Bean
public Map<PostType, CommentAccessPolicy> commentAccessPolicyMap() {
return Map.of(
Expand All @@ -25,4 +31,13 @@ public Map<PostType, CommentAccessPolicy> commentAccessPolicyMap() {
PostType.VOTE, roomCommentPolicy
);
}

@Bean
public Map<PostType, PostLikeAccessPolicy> postLikeAccessPolicyMap() {
return Map.of(
PostType.FEED, feedLikePolicy,
PostType.RECORD, roomPostLikePolicy,
PostType.VOTE, roomPostLikePolicy
);
}
}
Comment on lines +35 to 43
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

11 changes: 8 additions & 3 deletions src/main/java/konkuk/thip/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public class SecurityConfig {
@Value("${server.web-domain-url}")
private String webDomainUrl;

@Value("${server.https-url}")
private String httpsUrl;


private final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private final CustomOAuth2UserService customOAuth2UserService;
Expand Down Expand Up @@ -68,7 +72,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
)
.exceptionHandling(handler -> handler.authenticationEntryPoint(jwtAuthenticationEntryPoint))
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
;
;

return http.build();
}
Expand All @@ -90,7 +94,8 @@ public CorsConfigurationSource corsConfigurationSource() {
config.setAllowedOrigins(List.of(
"http://localhost:5173",
webUrl,
webDomainUrl
webDomainUrl,
httpsUrl
));
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
config.setAllowedHeaders(Collections.singletonList("*"));
Expand All @@ -104,5 +109,5 @@ public CorsConfigurationSource corsConfigurationSource() {

return source;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import konkuk.thip.common.security.annotation.UserId;
import konkuk.thip.common.swagger.annotation.ExceptionDescription;
import konkuk.thip.feed.adapter.in.web.request.FeedCreateRequest;
import konkuk.thip.feed.adapter.in.web.request.FeedIsLikeRequest;
import konkuk.thip.feed.adapter.in.web.request.FeedIsSavedRequest;
import konkuk.thip.feed.adapter.in.web.request.FeedUpdateRequest;
import konkuk.thip.feed.adapter.in.web.response.FeedIdResponse;
import konkuk.thip.feed.adapter.in.web.response.FeedIsLikeResponse;
import konkuk.thip.feed.adapter.in.web.response.FeedIsSavedResponse;
import konkuk.thip.feed.application.port.in.FeedCreateUseCase;
import konkuk.thip.feed.application.port.in.FeedSavedUseCase;
import konkuk.thip.feed.application.port.in.FeedUpdateUseCase;
import konkuk.thip.post.application.port.in.PostLikeUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
Expand All @@ -31,6 +34,7 @@ public class FeedCommandController {
private final FeedCreateUseCase feedCreateUseCase;
private final FeedUpdateUseCase feedUpdateUseCase;
private final FeedSavedUseCase feedSavedUseCase;
private final PostLikeUseCase postLikeUseCase;

@Operation(
summary = "피드 작성",
Expand Down Expand Up @@ -74,4 +78,17 @@ public BaseResponse<FeedIsSavedResponse> changeSavedFeed(
return BaseResponse.ok(FeedIsSavedResponse.of(feedSavedUseCase.changeSavedFeed(FeedIsSavedRequest.toCommand(userId,feedId,request.type()))));
}

@Operation(
summary = "피드 좋아요 상태 변경",
description = "사용자가 피드의 좋아요 상태를 변경합니다. (true -> 좋아요, false -> 좋아요 취소)"
)
@ExceptionDescription(CHANGE_FEED_LIKE_STATE)
@PostMapping("/feeds/{feedId}/likes")
public BaseResponse<FeedIsLikeResponse> likeFeed(
@RequestBody @Valid final FeedIsLikeRequest request,
@Parameter(description = "좋아요 상태를 변경하려는 피드 ID", example = "1")@PathVariable("feedId") final Long feedId,
@Parameter(hidden = true) @UserId final Long userId) {
return BaseResponse.ok(FeedIsLikeResponse.of(postLikeUseCase.changeLikeStatusPost(request.toCommand(userId, feedId))));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package konkuk.thip.feed.adapter.in.web.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import konkuk.thip.post.application.port.in.dto.PostIsLikeCommand;

import static konkuk.thip.common.post.PostType.FEED;

@Schema(description = "피드 좋아요 상태 변경 요청 DTO")
public record FeedIsLikeRequest(
@Schema(description = "좋아요 여부 type (true -> 좋아요, false -> 좋아요 취소)", example = "true")
@NotNull(message = "좋아요 여부는 필수입니다.")
Boolean type
) {
public PostIsLikeCommand toCommand(Long userId, Long feedId) {
return new PostIsLikeCommand(userId, feedId, FEED ,type);
}
}
Comment on lines +9 to +18
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 이렇게 상수로 넣어주었군요!! 굿굿 좋습니다!

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package konkuk.thip.feed.adapter.in.web.response;

import konkuk.thip.post.application.port.in.dto.PostIsLikeResult;

public record FeedIsLikeResponse(
Long feedId,
boolean isLiked
) {
public static FeedIsLikeResponse of(PostIsLikeResult postIsLikeResult) {
return new FeedIsLikeResponse(postIsLikeResult.postId(), postIsLikeResult.isLiked());
}
}
Loading