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 @@ -4,7 +4,7 @@
import jakarta.persistence.*;
import konkuk.thip.comment.domain.Comment;
import konkuk.thip.common.entity.BaseJpaEntity;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;
import konkuk.thip.post.adapter.out.jpa.PostJpaEntity;
import konkuk.thip.user.adapter.out.jpa.UserJpaEntity;
import lombok.*;
Expand Down Expand Up @@ -56,6 +56,7 @@ public class CommentJpaEntity extends BaseJpaEntity {
private CommentJpaEntity parent;

// 삭제용 댓글 좋아요 양방향 매핑 관계
@Builder.Default
@OneToMany(mappedBy = "commentJpaEntity", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<CommentLikeJpaEntity> commentLikeList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import konkuk.thip.comment.application.port.out.CommentCommandPort;
import konkuk.thip.comment.domain.Comment;
import konkuk.thip.common.exception.EntityNotFoundException;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;
import konkuk.thip.feed.adapter.out.persistence.repository.FeedJpaRepository;
import konkuk.thip.post.adapter.out.jpa.PostJpaEntity;
import konkuk.thip.record.adapter.out.persistence.repository.RecordJpaRepository;
import konkuk.thip.roompost.adapter.out.persistence.repository.record.RecordJpaRepository;
import konkuk.thip.user.adapter.out.jpa.UserJpaEntity;
import konkuk.thip.user.adapter.out.persistence.repository.UserJpaRepository;
import konkuk.thip.vote.adapter.out.persistence.repository.VoteJpaRepository;
import konkuk.thip.roompost.adapter.out.persistence.repository.vote.VoteJpaRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package konkuk.thip.comment.application.port.in.dto;


import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;

public record CommentShowAllQuery(
Long postId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
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.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.application.service.handler.PostHandler;
import konkuk.thip.post.domain.PostType;
Comment on lines +9 to +11
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

PostType/CountUpdatable/PostHandler 패키지 이동 반영 OK. 타입 변환 방식 일관성 확인 권장

리팩터링된 패키지 경로로의 정리는 적절합니다. 한 가지 점검사항: 본 서비스는 PostType.from(String)을 사용합니다(라인 34). 본 PR에서 일부 컴포넌트가 room-post 전용 매핑 메서드(roomPostTypeFrom)를 사용하도록 변경되었다면, 여기서도 동일 규칙을 적용할지 확인해 주세요. 매핑 규칙이 분기되면 권한 검증/조회 핸들러에서 타입 해석 불일치가 발생할 수 있습니다.

아래 스크립트로 타입 매핑 사용 현황을 점검해 주세요.

참고: 프로젝트 학습 메모에 따르면 Record/Vote는 Room 소속, Feed는 비소속입니다. commentAuthorizationValidator가 타입별 룸 참가자 검증을 이 규칙에 맞춰 수행하는지 함께 확인하면 좋겠습니다.


🏁 Script executed:

#!/bin/bash
# PostType 매핑 메서드 사용 현황 파악
rg -nP 'PostType\.from\s*\(' -C2
rg -nP 'PostType\.roomPostTypeFrom\s*\(' -C2

# 혹시 남아 있을 수 있는 구 패키지 경로 사용 점검
rg -nP 'import\s+konkuk\.thip\.common\.post\.(PostType|CountUpdatable)' -n

Length of output: 2523


🏁 Script executed:

#!/bin/bash
# Locate PostType enum implementation
fd --max-depth 3 PostType.java

# Display content around 'from' and 'roomPostTypeFrom' methods
# Replace path with actual file if found
POST_TYPE_FILE=$(fd --max-depth 3 PostType.java | head -n1)
if [ -n "$POST_TYPE_FILE" ]; then
  echo "=== File: $POST_TYPE_FILE ==="
  sed -n '1,200p' "$POST_TYPE_FILE" | sed -n '/from/,/}/p'
  echo
  sed -n '1,200p' "$POST_TYPE_FILE" | sed -n '/roomPostTypeFrom/,/}/p'
else
  echo "PostType.java not found"
fi

Length of output: 169


🏁 Script executed:

#!/bin/bash
# PostType.java 전체 경로 검색
fd PostType.java

# 검색된 파일에서 매핑 메서드 내용 출력
POST_TYPE_FILE=$(fd PostType.java | head -n1)
if [ -n "$POST_TYPE_FILE" ]; then
  echo "=== $POST_TYPE_FILE ==="
  sed -n '1,200p' "$POST_TYPE_FILE" | sed -n '/from\s*(/,/)/p'
  echo
  sed -n '1,200p' "$POST_TYPE_FILE" | sed -n '/roomPostTypeFrom\s*(/,/)/p'
else
  echo "PostType.java 파일을 찾을 수 없습니다."
fi

Length of output: 777


PostType 매핑 방식 일관성 확인 필요

리팩터링된 패키지 경로 반영은 적절합니다. 다만, 방 게시글 전용 매핑을 위해 일부 컴포넌트(RoomPostIsLikeRequest)에서는 PostType.roomPostTypeFrom을 사용하는 반면,
CommentCreateService(src/main/java/konkuk/thip/comment/application/service/CommentCreateService.java:34)에서는 여전히 일반 매핑인 PostType.from을 사용하고 있습니다.
매핑 로직 분기 시 권한 검증·조회 핸들러에서 타입 해석이 불일치할 수 있으므로, 아래 사항을 검토해주세요:

  • CommentCreateService: PostType.from(command.postType())PostType.roomPostTypeFrom(command.postType()) 적용 여부
  • commentAuthorizationValidator: Record/Vote(룸 소속 게시글)와 Feed(비소속 게시글) 검증 로직이 프로젝트 규칙에 맞게 구현되었는지 확인
🤖 Prompt for AI Agents
In
src/main/java/konkuk/thip/comment/application/service/CommentCreateService.java
around lines 9 to 11 and 34, the service uses the general
PostType.from(command.postType()) while room-specific components use
PostType.roomPostTypeFrom; change the mapping to
PostType.roomPostTypeFrom(command.postType()) to maintain consistent room-post
type interpretation, and update any imports if necessary; after that, review
commentAuthorizationValidator implementation to ensure its Record/Vote
(room-scoped) vs Feed (non-room) validation logic aligns with the project rules
and adjust its type checks to use the same roomPostTypeFrom mapping so
authorization and type resolution are consistent across handlers.

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
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.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.application.service.handler.PostHandler;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.application.service.handler.PostHandler;
import lombok.RequiredArgsConstructor;
Comment on lines +11 to 13
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

패키지 경로 변경 반영 OK — Room 소속 리소스 접근 검증(Record/Vote) 동일 적용 여부 확인

CommentAuthorizationValidator.validateUserCanAccessPostForComment(...)가 댓글 생성과 동일하게 Record/Vote에 대해 "해당 Room 참가자 여부"를 검증하는지 확인 부탁드립니다(팀 공유 지식 기준).

아래 스크립트로 해당 메서드 구현과 룸 참가자 검증 로직(예: RoomParticipant/Room 권한 검사)이 포함되어 있는지 빠르게 점검할 수 있습니다.

동시에, 댓글 좋아요 중복 삽입 방지를 위해 (userId, commentId) 유니크 인덱스가 저장소 레벨에 구성되어 있는지도 확인해 주세요. 이는 동시성 하에서 중복 like를 방지하는 최후방어선입니다.


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 메서드 선언/구현 위치 및 주변 문맥 확인
rg -nP 'validateUserCanAccessPostForComment\s*\(' -C5

# Room 참가자 검증과 연관된 키워드가 같은 파일에 함께 있는지 힌트 검색
rg -nP 'RoomParticipant|RoomParticipants|isParticipant|validate.*Participant|validate.*Room' -n -C3

Length of output: 266650


#!/usr/bin/env bash
set -euo pipefail

# 1. CommentAccessPolicy 구현체 확인
echo "=== CommentAccessPolicy 구현체 ==="
rg -nP 'implements\s+CommentAccessPolicy' -C3 src/main/java

# 2. CommentLikeJpaEntity 위치 및 unique 제약 확인
echo
echo "=== CommentLikeJpaEntity 검색 ==="
entity_file=$(rg -lP 'class\s+CommentLikeJpaEntity' -g '*.java' src/main/java || true)
if [[ -n "$entity_file" ]]; then
  echo "Found: $entity_file"
  echo "--- @Table 어노테이션 포함 부분 ---"
  rg -nP '@Table' -C2 "$entity_file" || echo "(no @Table annotation)"
  echo "--- unique 또는 uniqueConstraints 키워드 ---"
  rg -nP 'unique|uniqueConstraints' -n "$entity_file" || echo "(no unique constraints)"
else
  echo "CommentLikeJpaEntity 클래스를 찾지 못했습니다."
fi

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== 1. CommentAccessPolicy 인터페이스 위치 ==="
rg -nP "interface\s+CommentAccessPolicy" -C3 src/main/java || echo "(인터페이스 없음)"

echo
echo "=== 2. CommentAccessPolicy 구현체 목록 ==="
rg -nP "implements\s+CommentAccessPolicy" -C3 src/main/java || echo "(구현체 없음)"

echo
echo "=== 3. CommentLikeJpaEntity 에서 (userId, commentId) 유니크 인덱스 확인 ==="
entity_file=$(rg -lP "class\s+CommentLikeJpaEntity" -g '*.java' src/main/java || true)
if [[ -n "$entity_file" ]]; then
  echo "Found: $entity_file"
  echo "--- @Table 어노테이션 ---"
  rg -nP "@Table" -C2 "$entity_file" || echo "(어노테이션 없음)"
  echo "--- uniqueConstraints 또는 unique 키워드 ---"
  rg -nP "uniqueConstraints|unique" -C2 "$entity_file" || echo "(유니크 제약 없음)"
else
  echo "CommentLikeJpaEntity 클래스를 찾지 못했습니다."
fi

Length of output: 3801


CommentAuthorizationValidator: Record/Vote Room 참가자 검증 정상 적용 확인, CommentLike DB 유니크 제약 추가 필요

  • CommentAuthorizationValidator.validateUserCanAccessPostForComment()
    – PostType.RECORD·VOTE → RoomPostCommentAccessPolicy.validateCommentAccess() 호출
    – 내부에서 RoomParticipantValidator.validateUserIsRoomMember(roomId, userId)로 “해당 방 참가자 여부” 검증이 정확히 적용됨 확인
  • CommentLikeJpaEntity.java (src/main/java/konkuk/thip/comment/adapter/out/jpa/CommentLikeJpaEntity.java)
    – 현재 @table(name="comment_likes")만 선언되어 있어 (user_id, comment_id) 조합에 대한 DB 유니크 제약이 없음
    – 동시성 하 중복 좋아요를 막기 위해 아래와 같이 uniqueConstraints 추가 필요
    @Entity
    @Table(
      name = "comment_likes",
      uniqueConstraints = @UniqueConstraint(
        name = "uk_comment_like_user_comment",
        columnNames = {"user_id", "comment_id"}
      )
    )
    
🤖 Prompt for AI Agents
In src/main/java/konkuk/thip/comment/adapter/out/jpa/CommentLikeJpaEntity.java
around the class/@Table declaration, add a unique constraint for the (user_id,
comment_id) pair by updating the @Table annotation to include uniqueConstraints
= @UniqueConstraint(name = "uk_comment_like_user_comment", columnNames =
{"user_id", "comment_id"}); ensure javax.persistence.UniqueConstraint is
imported and the column names match the entity/JPA column mappings, then
regenerate/apply the DB migration or schema update so the unique constraint is
created.

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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.CountUpdatable;
import konkuk.thip.post.domain.CountUpdatable;

public interface CommentAccessPolicy {
void validateCommentAccess(CountUpdatable post, Long 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.CountUpdatable;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.feed.domain.Feed;
import org.springframework.stereotype.Component;

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

import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.room.application.service.validator.RoomParticipantValidator;
import konkuk.thip.room.domain.RoomPost;
import konkuk.thip.roompost.domain.RoomPost;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import konkuk.thip.comment.application.service.policy.CommentAccessPolicy;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.domain.PostType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/konkuk/thip/comment/domain/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import konkuk.thip.common.entity.BaseDomainEntity;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;
import lombok.Builder;
import lombok.Getter;
import lombok.experimental.SuperBuilder;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/konkuk/thip/common/annotation/DomainService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package konkuk.thip.common.annotation;

import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Component
public @interface DomainService {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오 좋네여 굿굿


@AliasFor(annotation = Component.class)
String value() default "";
}
6 changes: 3 additions & 3 deletions src/main/java/konkuk/thip/config/PostAccessPolicyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import konkuk.thip.comment.application.service.policy.CommentAccessPolicy;
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.domain.PostType;
import konkuk.thip.feed.application.service.policy.FeedLikeAccessPolicy;
import konkuk.thip.post.application.service.policy.PostLikeAccessPolicy;
import konkuk.thip.post.application.service.policy.RoomPostLikeAccessPolicy;
import konkuk.thip.roompost.application.service.policy.RoomPostLikeAccessPolicy;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import jakarta.validation.constraints.NotNull;
import konkuk.thip.post.application.port.in.dto.PostIsLikeCommand;

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

@Schema(description = "피드 좋아요 상태 변경 요청 DTO")
public record FeedIsLikeRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package konkuk.thip.post.application.service.policy;
package konkuk.thip.feed.application.service.policy;

import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.post.application.service.policy.PostLikeAccessPolicy;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.feed.domain.Feed;
import org.springframework.stereotype.Component;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/konkuk/thip/feed/domain/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import konkuk.thip.common.entity.BaseDomainEntity;
import konkuk.thip.common.exception.BusinessException;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.domain.service.PostCountService;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import jakarta.persistence.*;
import konkuk.thip.comment.adapter.out.jpa.CommentJpaEntity;
import konkuk.thip.common.entity.BaseJpaEntity;
import konkuk.thip.common.entity.StatusType;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.user.adapter.out.jpa.UserJpaEntity;
import lombok.AccessLevel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package konkuk.thip.post.adapter.out.persistence;

import konkuk.thip.common.exception.EntityNotFoundException;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;
import konkuk.thip.feed.adapter.out.persistence.repository.FeedJpaRepository;
import konkuk.thip.post.adapter.out.jpa.PostJpaEntity;
import konkuk.thip.post.adapter.out.mapper.PostLikeMapper;
import konkuk.thip.post.application.port.out.PostLikeCommandPort;
import konkuk.thip.record.adapter.out.persistence.repository.RecordJpaRepository;
import konkuk.thip.roompost.adapter.out.persistence.repository.record.RecordJpaRepository;
import konkuk.thip.user.adapter.out.jpa.UserJpaEntity;
import konkuk.thip.user.adapter.out.persistence.repository.UserJpaRepository;
import konkuk.thip.vote.adapter.out.persistence.repository.VoteJpaRepository;
import konkuk.thip.roompost.adapter.out.persistence.repository.vote.VoteJpaRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package konkuk.thip.post.application.port.in.dto;

import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;

public record PostIsLikeCommand(

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package konkuk.thip.post.application.port.out;

import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.PostType;

public interface PostLikeCommandPort {
void save(Long userId, Long postId, PostType postType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package konkuk.thip.post.application.service;

import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.service.PostHandler;
import konkuk.thip.post.application.service.handler.PostHandler;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.application.port.in.dto.PostIsLikeCommand;
import konkuk.thip.post.application.port.in.dto.PostIsLikeResult;
import konkuk.thip.post.application.port.in.PostLikeUseCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package konkuk.thip.common.post.service;
package konkuk.thip.post.application.service.handler;

import konkuk.thip.common.annotation.HelperService;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.domain.PostType;
import konkuk.thip.feed.application.port.out.FeedCommandPort;
import konkuk.thip.feed.domain.Feed;
import konkuk.thip.record.application.port.out.RecordCommandPort;
import konkuk.thip.record.domain.Record;
import konkuk.thip.vote.application.port.out.VoteCommandPort;
import konkuk.thip.vote.domain.Vote;
import konkuk.thip.roompost.application.port.out.RecordCommandPort;
import konkuk.thip.roompost.domain.Record;
import konkuk.thip.roompost.application.port.out.VoteCommandPort;
import konkuk.thip.roompost.domain.Vote;
import lombok.RequiredArgsConstructor;

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

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

public interface PostLikeAccessPolicy {
void validatePostLikeAccess(CountUpdatable post, Long userId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package konkuk.thip.post.application.service.validator;

import konkuk.thip.common.annotation.HelperService;
import konkuk.thip.common.exception.InvalidStateException;
import konkuk.thip.common.post.CountUpdatable;
import konkuk.thip.common.post.PostType;
import konkuk.thip.post.application.service.policy.PostLikeAccessPolicy;
import konkuk.thip.post.domain.CountUpdatable;
import konkuk.thip.post.domain.PostType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

import static konkuk.thip.common.exception.code.ErrorCode.*;

@Component
@HelperService
@RequiredArgsConstructor
public class PostLikeAuthorizationValidator {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package konkuk.thip.common.post;
package konkuk.thip.post.domain;

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오 밑에 TODO 패키지 구조 변경 주석 지워주시면 감사하겠습니다!!

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.

넵 제가 지우겠습니다

public interface CountUpdatable { //TODO 패키지 구조 충돌안나게 한번에 옮기기
public interface CountUpdatable {
void increaseCommentCount();
void decreaseCommentCount();
void updateLikeCount(PostCountService postCountService, boolean isLike);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package konkuk.thip.common.post;
package konkuk.thip.post.domain;

import konkuk.thip.common.exception.InvalidStateException;
import lombok.Getter;
Expand All @@ -7,6 +7,7 @@
import java.util.Arrays;

import static konkuk.thip.common.exception.code.ErrorCode.POST_TYPE_NOT_MATCH;
import static konkuk.thip.common.exception.code.ErrorCode.ROOM_POST_TYPE_NOT_MATCH;

@Getter
@RequiredArgsConstructor
Expand All @@ -26,4 +27,13 @@ public static PostType from(String type) {
new InvalidStateException(POST_TYPE_NOT_MATCH)
);
}

public static PostType roomPostTypeFrom(String type) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오 roomPostType 따로 정의한게 아니라 PostType안에서 roomPostType확인하는거 좋네여 FEED일 경우 예외처리도 넘넘좋습니다!!

return Arrays.stream(PostType.values())
.filter(p -> !p.equals(FEED) && p.getType().equalsIgnoreCase(type))
.findFirst()
.orElseThrow(() ->
new InvalidStateException(ROOM_POST_TYPE_NOT_MATCH)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package konkuk.thip.post.domain.service;

import konkuk.thip.common.annotation.DomainService;
import konkuk.thip.common.exception.InvalidStateException;
import org.springframework.stereotype.Service;

import static konkuk.thip.common.exception.code.ErrorCode.POST_LIKE_COUNT_UNDERFLOW;

@Service
@DomainService
public class PostCountService {

public int updatePostLikeCount(boolean isLike, int likeCount) {
Expand Down
Loading