Skip to content

Commit

Permalink
Merge pull request #80 from study-hub-inu/refactor/SH-298-apply
Browse files Browse the repository at this point in the history
Refactor/sh 298 apply
  • Loading branch information
elyudwo authored Jan 26, 2024
2 parents 7a69d24 + abbb83f commit f144cac
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
package kr.co.studyhubinu.studyhubserver.apply.dto.data;

import kr.co.studyhubinu.studyhubserver.apply.enums.Inspection;
import kr.co.studyhubinu.studyhubserver.user.enums.MajorType;
import lombok.Builder;
import lombok.Getter;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Getter
public class ApplyUserData {

private Long id;
private String nickname;
private MajorType major;
private String imageUrl;
private String introduce;
private LocalDateTime createdDate;
private final Long id;
private final String nickname;
private final MajorType major;
private final String imageUrl;
private final String introduce;
private final LocalDateTime createdDate;
private final Inspection inspection;

@Builder
public ApplyUserData(Long id, String nickname, MajorType major, String imageUrl, String introduce, LocalDateTime createdDate) {
public ApplyUserData(Long id, String nickname, MajorType major, String imageUrl, String introduce, LocalDateTime createdDate, Inspection inspection) {
this.id = id;
this.nickname = nickname;
this.major = major;
this.imageUrl = imageUrl;
this.introduce = introduce;
this.createdDate = createdDate;
this.inspection = inspection;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
@Getter
public class ParticipateApplyData {

private String major;
private String title;
private String content;
private String chatUrl;
private String inspection;
private Long postId;
private final String major;
private final String title;
private final String content;
private final String chatUrl;
private final String inspection;
private final Long postId;

public ParticipateApplyData(MajorType major, String title, String content, String chatUrl, Inspection inspection, Long postId) {
this.major = major.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public List<ApplyUserData> findByStudy(Long studyId, final Pageable pageable) {
return jpaQueryFactory
.select(Projections.constructor(ApplyUserData.class,
userEntity.id, userEntity.nickname, userEntity.major, userEntity.imageUrl,
applyEntity.introduce, applyEntity.createdDate))
applyEntity.introduce, applyEntity.createdDate, applyEntity.inspection))
.from(applyEntity)
.innerJoin(userEntity).on(applyEntity.userId.eq(userEntity.id))
.where(applyEntity.studyId.eq(studyId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Optional;

import static kr.co.studyhubinu.studyhubserver.apply.enums.Inspection.ACCEPT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -55,7 +56,7 @@ class ApplyRepositoryTest {
ApplyEntity apply = ApplyEntity.builder()
.userId(user.getId())
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.inspection(ACCEPT)
.build();
ApplyEntity result = applyRepository.save(apply);

Expand All @@ -81,7 +82,7 @@ class ApplyRepositoryTest {
ApplyEntity applyEntity = ApplyEntity.builder()
.userId(user.getId())
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.inspection(ACCEPT)
.build();
applyRepository.save(applyEntity);
applyRepository.flush();
Expand All @@ -103,7 +104,7 @@ class ApplyRepositoryTest {
ApplyEntity apply = ApplyEntity.builder()
.userId(user.getId())
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.inspection(ACCEPT)
.build();
applyRepository.save(apply);
applyRepository.flush();
Expand Down Expand Up @@ -134,26 +135,26 @@ class ApplyRepositoryTest {
ApplyEntity apply1 = ApplyEntity.builder()
.userId(user.getId())
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.inspection(ACCEPT)
.introduce("벌금내러 왔습니다.")
.build();

ApplyEntity apply2 = ApplyEntity.builder()
.userId(user2.getId())
.studyId(study.getId())
.inspection(Inspection.ACCEPT)
.inspection(ACCEPT)
.introduce("목숨을 걸겠습니다.")
.build();

ApplyEntity result1 = applyRepository.save(apply1);
ApplyEntity result2 = applyRepository.save(apply2);
List<ApplyEntity> list = applyRepository.findAll();
applyRepository.save(apply1);
applyRepository.save(apply2);

// when
List<ApplyUserData> result = applyRepository.findByStudy(study.getId(), pageable);

// then
assertThat(result.size()).isEqualTo(2);
assertThat(result.get(0).getInspection()).isEqualTo(ACCEPT);
}

@Test
Expand Down

0 comments on commit f144cac

Please sign in to comment.