본문 바로가기

프로젝트/PongGame18

RelationController RelationController 사전에 정의한 API 명세에 따른 Controller를 구현한다. 1. RelationValidator Controller로 들어오는 accountId 간에 검증을 처리한다. Controller로 들어오는 accountId는 별개의 파라미터로 Spring에서 제공하는 Validator 기능을 사용할 수 없기에 따로 RelationValidator 클래스를 생성하고 Controller에서 해당 Validator를 적용한다. ■ RelationValidator Account간 Relation의 상태에 대해 검증을 시행한다. [RelationValidator] @Component @RequiredArgsConstructor public class RelationValidato.. 2022. 6. 3.
RelationService RelationService Relation에 대한 business Logic을 처리하는 RelationService를 생성하고 구현한다. 1. RelationService ■ RelationService [RelationService] @Service @Transactional(readOnly = true) @RequiredArgsConstructor public class RelationService { private final AccountRepository accountRepository; private final RelationRepository relationRepository; . . . } □ requestFriend fromAccountId -> toAccountId 방향의 "친구 요청".. 2022. 6. 3.
RelationRepository RelationRepository Relaiton 엔티티를 DB에서 가져오는 RelationRepository를 생성한다. 복잡한 Query문이 들어가거나 Paging을 해야 하는 경우에는 QueryDsl을 사용한다. 1. Spring Data JPA ■ RelationRepository [RelationRepository] public interface RelationRepository extends JpaRepository, RelationRepositoryCustom { @Query("select relations from Relation relations " + "join relations.fromAccount fromAccount " + "join fetch relations.toAccount .. 2022. 6. 1.
Relation API 명세 Relation API 명세 Account 간의 관계를 나타내는 Relation entity를 생성하고 Relation을 사용하는 API에 대한 명세를 작성한다. 1. Relation Account 간의 관계를 나타내는 entity. 관계는 세 가지로, [친구, 친구 요청, 차단] 상태가 존재한다. [Relation] @Entity @Where(clause = "deleted = false") @Getter @Builder @AllArgsConstructor @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Relation extends BaseTime { @Id @GeneratedValue @Column(name = "relation_id.. 2022. 5. 30.