Skip to content

Commit

Permalink
(24/05/11 - 3) 클로즈 베타 테스트 버전 배포합니다.
Browse files Browse the repository at this point in the history
(24/05/11 - 3) 클로즈 베타 테스트 버전 배포합니다.
  • Loading branch information
fakerdeft authored May 11, 2024
2 parents fbb3750 + 1f27aef commit 3f6616e
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public FindCompanyAdminCountResponse find(final FindCompanyAdminRequest request)
@Override
@Transactional
public void save(final SaveCompanyRequest request) {
String modifiedName = "";
String modifiedName = request.name();
if (request.name().contains("㈜")) {
modifiedName = request.name().replace("㈜", "(주)");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/coverflow/company/domain/Company.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Company extends BaseTimeEntity {
private CompanyStatus companyStatus; // 기업 상태 (검토/등록/삭제)

@Builder.Default
@OneToMany(mappedBy = "company", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "company")
@JsonManagedReference
private List<Question> questions = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ private SocialType getSocialType(final String registrationId) {

/**
* SocialType과 attributes에 들어있는 소셜 로그인의 식별값 id를 통해 DB에서 회원을 찾아 리턴하는 메소드
* RESPITE 상태인 회원은 예외 발생시킨다.
* 데이터 없으면 saveMember()를 호출하여 회원을 저장하고 리턴한다.
* WAIT/REGISTRATION 상태인 회원이 존재하면 그대로 리턴하고
* 없으면 saveMember()를 호출하여 회원을 저장하고 리턴한다.
* LEAVE 상태인 회원은 예외 발생시킨다.
*/
private Member getMember(
final OAuthAttributes attributes,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/coverflow/inquiry/domain/Inquiry.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Inquiry extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private InquiryStatus inquiryStatus; // 상태 (답변대기/답변완료/삭제)

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member; // 작성자 정보

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public void save(
.orElseThrow(() -> new MemberNotFoundException(memberId));

member.updateMember(request);
member.updateAuthorization(Role.MEMBER);
}

@Override
Expand Down Expand Up @@ -219,10 +218,10 @@ public void leave() {
* [탈퇴에 따른 데이터 삭제 메서드]
*/
private void deleteData(final UUID memberId) {
reportRepository.deleteByMemberId(memberId);
answerRepository.deleteByMemberId(memberId);
questionRepository.deleteByMemberId(memberId);
inquiryRepository.deleteByMemberId(memberId);
reportRepository.deleteByMemberId(memberId);

emitterRepository.deleteAllStartWithId(String.valueOf(memberId));
emitterRepository.deleteAllEventCacheStartWithId(String.valueOf(memberId));
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/coverflow/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,26 @@ public class Member extends BaseTimeEntity {
private RefreshTokenStatus refreshTokenStatus; // 리프레쉬 토큰 상태 (로그인/로그아웃)

@Builder.Default
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "member")
@JsonManagedReference
private List<Question> questions = new ArrayList<>(); // 회원의 질문 리스트

@Builder.Default
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "member")
@JsonManagedReference
private List<Answer> answers = new ArrayList<>(); // 회원의 답변 리스트

@Builder.Default
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "member")
@JsonManagedReference
private List<Notification> notifications = new ArrayList<>(); // 회원의 알림 리스트

@Builder.Default
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "member")
private List<Inquiry> inquiries = new ArrayList<>(); // 회원의 문의 리스트

@Builder.Default
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "member")
@JsonManagedReference
private List<Report> reports = new ArrayList<>(); // 회원의 신고 리스트

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/coverflow/notice/domain/Notice.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Notice extends BaseTimeEntity {
@Column
private boolean noticeStatus; // 상태(T: 등록/F: 삭제)

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@JsonBackReference
private Member member; // 작성자 정보
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Notification extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private NotificationType type; // 알림 종류 (DAILY, QUESTION, ANSWER)

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@JsonBackReference
private Member member; // 회원 정보
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.coverflow.question.application;

import com.coverflow.company.infrastructure.CompanyRepository;
import com.coverflow.member.application.MemberServiceImpl;
import com.coverflow.question.domain.Question;
import com.coverflow.question.dto.AnswerListDTO;
Expand Down Expand Up @@ -36,7 +35,6 @@ public class QuestionServiceImpl implements QuestionService {

private final MemberServiceImpl memberService;
private final AnswerServiceImpl answerService;
private final CompanyRepository companyRepository;
private final QuestionRepository questionRepository;

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/coverflow/question/domain/Answer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ public class Answer extends BaseTimeEntity {
@Column
private boolean answerStatus; // 답변 상태 (T: 등록/F: 삭제)

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id")
@JsonBackReference
private Question question; // 질문 정보

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@JsonBackReference
private Member member; // 답변 작성자 정보

@Builder.Default
@OneToMany(mappedBy = "answer", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "answer")
@JsonManagedReference
private List<Report> reports = new ArrayList<>(); // 답변에 대한 신고 리스트

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/coverflow/question/domain/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ public class Question extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private QuestionTag questionTag; // 질문 태그 (문화/급여/업무/커리어/워라밸)

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "company_id")
@JsonBackReference
private Company company; // 회사 정보

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@JsonBackReference
private Member member; // 질문 작성자 정보

@Builder.Default
@OneToMany(mappedBy = "question", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "question")
@JsonManagedReference
private List<Answer> answers = new ArrayList<>(); // 질문에 대한 답변 리스트

@Builder.Default
@OneToMany(mappedBy = "question", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "question")
@JsonManagedReference
private List<Report> reports = new ArrayList<>(); // 질문에 대한 신고 리스트

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

import static com.coverflow.question.domain.QQuestion.question;

Expand Down Expand Up @@ -58,91 +56,40 @@ public Optional<Page<Question>> findRegisteredQuestionsById(
final long companyId,
final String questionTag
) {
List<Question> questions;
long total;

CompletableFuture<List<Question>> questionsFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.selectFrom(question)
.leftJoin(question.answers).fetchJoin()
.where(
question.company.id.eq(companyId),
question.questionStatus.eq(true),
toContainsQuestionTag(questionTag)
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(question, pageable))
.distinct()
.fetch()
);

CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.select(question.count())
.from(question)
.where(
question.company.id.eq(companyId),
question.questionStatus.eq(true),
toContainsQuestionTag(questionTag)
)
.fetchOne()
);

CompletableFuture.allOf(questionsFuture, countFuture).join();

try {
questions = questionsFuture.get();
total = countFuture.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

return Optional.of(new PageImpl<>(questions, pageable, total));
List<Question> questions = jpaQueryFactory
.selectFrom(question)
.leftJoin(question.answers).fetchJoin()
.where(
question.company.id.eq(companyId),
question.questionStatus.eq(true),
toContainsQuestionTag(questionTag)
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(question, pageable))
.distinct()
.fetch();

return Optional.of(new PageImpl<>(questions, pageable, questions.size()));
}

@Override
public Optional<Page<Question>> findWithFilters(
final Pageable pageable,
final FindQuestionAdminRequest request
) {
List<Question> questions;
long total;

CompletableFuture<List<Question>> questionsFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.selectFrom(question)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(question, pageable))
.fetch()
);

CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() ->
jpaQueryFactory
.select(question.count())
.from(question)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.fetchOne()
);

CompletableFuture.allOf(questionsFuture, countFuture).join();

try {
questions = questionsFuture.get();
total = countFuture.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

return Optional.of(new PageImpl<>(questions, pageable, total));
List<Question> questions = jpaQueryFactory
.selectFrom(question)
.where(
toCreatedDateBetween(request.createdStartDate(), request.createdEndDate()),
eqStatus(request.status())
)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.orderBy(makeOrderSpecifiers(question, pageable))
.fetch();

return Optional.of(new PageImpl<>(questions, pageable, questions.size()));
}

private BooleanExpression toContainsQuestionTag(final String questionTag) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/coverflow/report/domain/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ public class Report extends BaseTimeEntity {
@Enumerated(EnumType.STRING)
private ReportType type; // 신고 종류

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
@JsonBackReference
private Member member; // 작성자 정보

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "question_id")
@JsonBackReference
private Question question; // 질문 정보

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "answer_id")
@JsonBackReference
private Answer answer; // 답변 정보
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

@Log4j2
@RequiredArgsConstructor
@Service
public class VisitorServiceImpl implements VisitorService {
private final String NOW = String.valueOf(LocalDateTime.now()).substring(0, 10);
private final String NOW = String.valueOf(LocalDate.now());
private final VisitorRepository visitorRepository;

@Override
Expand Down

0 comments on commit 3f6616e

Please sign in to comment.