-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GETP-168 feat: 피플 조회 기능의 피플 좋아요 수 조회 구현 (#111)
* GETP-168 refactor: 좋아요 / 좋아요 취소 서비스를 추상화 * GETP-168 remove: 현재 의미 없는 응용 레이어 테스트 삭제 * GETP-168 rename: 피플 좋아요 애그리거트를 like 패키지로 이동 * GETP-168 feat: 피플 조회 기능의 피플 좋아요 수 조회 구현 * GETP-168 refactor: 프로젝트 좋아요 / 좋아요 취소 서비스를 추상화에 대한 구현체로 변경
- Loading branch information
Showing
61 changed files
with
774 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/es/princip/getp/domain/client/exception/NotFoundClientException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package es.princip.getp.domain.client.exception; | ||
|
||
import es.princip.getp.infra.exception.ErrorDescription; | ||
import es.princip.getp.infra.exception.NotFoundException; | ||
|
||
public class NotFoundClientException extends NotFoundException { | ||
|
||
private static final String code = "NOT_FOUND_CLIENT"; | ||
private static final String message = "존재하지 않는 의뢰자입니다."; | ||
|
||
public NotFoundClientException() { | ||
super(ErrorDescription.of(code, message)); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/es/princip/getp/domain/common/domain/Identifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package es.princip.getp.domain.common.domain; | ||
|
||
public interface Identifiable { | ||
|
||
Long getId(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/es/princip/getp/domain/like/command/domain/Like.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
import es.princip.getp.domain.common.domain.BaseTimeEntity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.MappedSuperclass; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@MappedSuperclass | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public abstract class Like extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long likerId; | ||
|
||
private Long likedId; | ||
|
||
protected Like(final Long likerId, final Long likedId) { | ||
this.likerId = likerId; | ||
this.likedId = likedId; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/es/princip/getp/domain/like/command/domain/LikeReceivable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
import es.princip.getp.domain.common.domain.Identifiable; | ||
|
||
public interface LikeReceivable extends Identifiable { | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/es/princip/getp/domain/like/command/domain/LikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
public interface LikeRepository { | ||
|
||
boolean existsByLikerIdAndLikedId(Long likerId, Long likedId); | ||
|
||
void deleteByLikerIdAndLikedId(Long likerId, Long likedId); | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/es/princip/getp/domain/like/command/domain/Likeable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
import es.princip.getp.domain.common.domain.Identifiable; | ||
|
||
public interface Likeable extends Identifiable { | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/es/princip/getp/domain/like/command/domain/Liker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
import es.princip.getp.domain.like.exception.AlreadyLikedException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public abstract class Liker<T extends Like> { | ||
|
||
private final LikeRepository likeRepository; | ||
|
||
protected void checkAlreadyLiked(final Long likerId, final Long likedId) { | ||
if (likeRepository.existsByLikerIdAndLikedId(likerId, likedId)) { | ||
throw new AlreadyLikedException(); | ||
} | ||
} | ||
|
||
public abstract T like(final Likeable likeable, final LikeReceivable likeReceivable); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/es/princip/getp/domain/like/command/domain/Unliker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package es.princip.getp.domain.like.command.domain; | ||
|
||
import es.princip.getp.domain.like.exception.NeverLikedException; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public abstract class Unliker { | ||
|
||
private final LikeRepository likeRepository; | ||
|
||
protected void checkNeverLiked(final Long likerId, final Long likedId) { | ||
if (!likeRepository.existsByLikerIdAndLikedId(likerId, likedId)) { | ||
throw new NeverLikedException(); | ||
} | ||
} | ||
|
||
public void unlike(final Likeable likeable, final LikeReceivable likeReceivable) { | ||
checkNeverLiked(likeable.getId(), likeReceivable.getId()); | ||
likeRepository.deleteByLikerIdAndLikedId(likeable.getId(), likeReceivable.getId()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/es/princip/getp/domain/like/command/domain/people/PeopleLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package es.princip.getp.domain.like.command.domain.people; | ||
|
||
import es.princip.getp.domain.like.command.domain.Like; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@DiscriminatorColumn | ||
@Table(name = "people_like") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) | ||
@AttributeOverrides( | ||
{ | ||
@AttributeOverride(name = "id", column = @Column(name = "people_like_id")), | ||
@AttributeOverride(name = "likerId", column = @Column(name = "client_id")), | ||
@AttributeOverride(name = "likedId", column = @Column(name = "people_id")) | ||
} | ||
) | ||
public class PeopleLike extends Like { | ||
|
||
private PeopleLike(final Long clientId, final Long peopleId) { | ||
super(clientId, peopleId); | ||
} | ||
|
||
public static PeopleLike of(final Long clientId, final Long peopleId) { | ||
return new PeopleLike(clientId, peopleId); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/es/princip/getp/domain/like/command/domain/people/PeopleLikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package es.princip.getp.domain.like.command.domain.people; | ||
|
||
import es.princip.getp.domain.like.command.domain.LikeRepository; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface PeopleLikeRepository extends JpaRepository<PeopleLike, Long>, LikeRepository { | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/es/princip/getp/domain/like/command/domain/people/PeopleLiker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package es.princip.getp.domain.like.command.domain.people; | ||
|
||
import es.princip.getp.domain.like.command.domain.LikeReceivable; | ||
import es.princip.getp.domain.like.command.domain.Likeable; | ||
import es.princip.getp.domain.like.command.domain.Liker; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class PeopleLiker extends Liker<PeopleLike> { | ||
|
||
private final PeopleLikeRepository peopleLikeRepository; | ||
|
||
@Autowired | ||
public PeopleLiker(final PeopleLikeRepository peopleLikeRepository) { | ||
super(peopleLikeRepository); | ||
this.peopleLikeRepository = peopleLikeRepository; | ||
} | ||
|
||
@Override | ||
public PeopleLike like(final Likeable liker, final LikeReceivable liked) { | ||
checkAlreadyLiked(liker.getId(), liked.getId()); | ||
final PeopleLike like = PeopleLike.of(liker.getId(), liked.getId()); | ||
peopleLikeRepository.save(like); | ||
return like; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/es/princip/getp/domain/like/command/domain/people/PeopleUnliker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package es.princip.getp.domain.like.command.domain.people; | ||
|
||
import es.princip.getp.domain.like.command.domain.Unliker; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class PeopleUnliker extends Unliker { | ||
|
||
@Autowired | ||
public PeopleUnliker(final PeopleLikeRepository peopleLikeRepository) { | ||
super(peopleLikeRepository); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/es/princip/getp/domain/like/command/domain/project/ProjectLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package es.princip.getp.domain.like.command.domain.project; | ||
|
||
import es.princip.getp.domain.like.command.domain.Like; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Entity | ||
@DiscriminatorColumn | ||
@Table(name = "project_like") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) | ||
@AttributeOverrides( | ||
{ | ||
@AttributeOverride(name = "id", column = @Column(name = "project_like_id")), | ||
@AttributeOverride(name = "likerId", column = @Column(name = "people_id")), | ||
@AttributeOverride(name = "likedId", column = @Column(name = "project_id")) | ||
} | ||
) | ||
public class ProjectLike extends Like { | ||
|
||
private ProjectLike(final Long peopleId, final Long projectId) { | ||
super(peopleId, projectId); | ||
} | ||
|
||
public static ProjectLike of(final Long peopleId, final Long projectId) { | ||
return new ProjectLike(peopleId, projectId); | ||
} | ||
} |
Oops, something went wrong.