-
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.
* [feat] : 크레딧 증감 로직 추가 * [feat] : 답변 에러코드 추가 * [feat] : 질문글 에러코드 추가 * [refactor] : 질문자 여부 확인 함수 엔티티로 이동 * [feat] : 답변 채택에 따른 상태변경 메서드 엔티티에 추가 * [feat] : 답변 채택 비즈니스 로직 작성 * [test] : Member 파라미터 있는 질문글 fixture 추가 * [test] : 답변 채택 비즈니스 로직 테스트 * [test] : assertAll 검증함수들 통합 * [feat] : 답변 채택 API 함수 작성 * [test] : 답변 채택 API 통합 테스트 * [chore] : swagger 명세 * [style] : 코드 리포멧팅 * [style] : 메서드 네이밍 변경 * [feat] : 엔티티명 및 detail 타입 변경 * [feat] : CreditType enum에 detail 필드 추가 * [remove] : creditDetail enum 삭 * [feat] : 크레딧 에러 코드 member 영역으로 이동 * [feat] : 답변 채택 시 필드 변경 메서드 책임분리 * [feat] : 크레딧 내역 repository 추가 * [feat] : 크레딧 내역 Mapper 추가 * [feat] : 크레딧 내역 저장하는 비즈니스 로직 추가 * [feat] : errorCode 클래스 이동 반영 * [feat] : 크레딧 증감 로직 서비스로 이동 및 크레딧 저장 로직 호출 * [test] : 크레딧 저장 로직 호출 반영 * [test] : 에러 코드 변경 반영 * [test] : 외래키 제약 조건에 따라 creditRepository 먼저 초기화 * [feat] : 필요한 파라미터만 넘기도록 mapper 수정 * [test] : 크레딧 내역 저장 단위 테스트 작성 * [refactor] : DTO 내 팩토리 메서드 삭제 * [fix] : valid 어노테이션 위치 수정 * [style] : 코드 리포멧팅 * [fix] : request에 대한 spring bean validation 반영
- Loading branch information
Showing
23 changed files
with
392 additions
and
71 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
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/dnd/gongmuin/answer/exception/AnswerErrorCode.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,17 @@ | ||
package com.dnd.gongmuin.answer.exception; | ||
|
||
import com.dnd.gongmuin.common.exception.ErrorCode; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum AnswerErrorCode implements ErrorCode { | ||
|
||
NOT_FOUND_ANSWER("해당 아이디의 답변이 존재하지 않습니다.", "ANS_001"), | ||
ALREADY_CHOSEN_ANSWER_EXISTS("채택한 답변이 존재합니다.", "ANS_02"); | ||
|
||
private final String message; | ||
private final String code; | ||
} |
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 was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/dnd/gongmuin/credit_history/dto/CreditHistoryMapper.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,15 @@ | ||
package com.dnd.gongmuin.credit_history.dto; | ||
|
||
import com.dnd.gongmuin.credit_history.CreditHistory; | ||
import com.dnd.gongmuin.credit_history.CreditType; | ||
import com.dnd.gongmuin.member.domain.Member; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class CreditHistoryMapper { | ||
public static CreditHistory toCreditHistory(CreditType creditType, int reward, Member member) { | ||
return CreditHistory.of(creditType, creditType.getDetail(), reward, member); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/dnd/gongmuin/credit_history/repository/CreditHistoryRepository.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 com.dnd.gongmuin.credit_history.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.dnd.gongmuin.credit_history.CreditHistory; | ||
|
||
public interface CreditHistoryRepository extends JpaRepository<CreditHistory, Long> { | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/dnd/gongmuin/credit_history/service/CreditHistoryService.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,29 @@ | ||
package com.dnd.gongmuin.credit_history.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.dnd.gongmuin.answer.domain.Answer; | ||
import com.dnd.gongmuin.credit_history.CreditType; | ||
import com.dnd.gongmuin.credit_history.dto.CreditHistoryMapper; | ||
import com.dnd.gongmuin.credit_history.repository.CreditHistoryRepository; | ||
import com.dnd.gongmuin.question_post.domain.QuestionPost; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CreditHistoryService { | ||
|
||
private final CreditHistoryRepository creditHistoryRepository; | ||
|
||
@Transactional | ||
public void saveChosenCreditHistory(QuestionPost questionPost, Answer answer) { | ||
creditHistoryRepository.saveAll(List.of( | ||
CreditHistoryMapper.toCreditHistory(CreditType.CHOSEN, questionPost.getReward(), answer.getMember()), | ||
CreditHistoryMapper.toCreditHistory(CreditType.CHOOSE, questionPost.getReward(), questionPost.getMember()) | ||
)); | ||
} | ||
} |
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
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
Oops, something went wrong.