-
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.
[FEATURE] 자신이 답변한 일일 질문과 답변 관련 API 작성 (#94)
* feat : User 관련 기능 API 작성 #83 * spotlessApply #83 * feat : User 차단 관련 검색, 조회 API 로직 변경 #83 * feat : User 신고 정보 조회 API 작성 #83 * spotless Apply #83 * edit : @transactional 추가 #83 * feat : 유저 검색 시 친구 여부 보여지도록 수정, 검색 로직 수정, 신고 api에서 request body 삭제 #83 * spotless Apply #83 * feat : 유저 검색 시 친구, 차단 여부 표시 #83 * edit : 유저 차단 시 로직 변경 #83 * edit : 친구 조회 시 페이지네이션 삭제, 쿼리 로직 변경 #83 * edit : 친구 정보 조회 시 양방향 로직 추가 #83 * feat : 자신이 작성한 데일리 답변의 갯수와 리스트 조회 API 작성 #92
- Loading branch information
1 parent
e84c81e
commit 6b4f1e9
Showing
8 changed files
with
166 additions
and
0 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
38 changes: 38 additions & 0 deletions
38
Api/src/main/java/tify/server/api/user/model/dto/vo/MyDailyQuestionAnswerVo.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,38 @@ | ||
package tify.server.api.user.model.dto.vo; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.sql.Timestamp; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import tify.server.domain.domains.question.dto.model.DailyQuestionAnswerVo; | ||
|
||
@Getter | ||
@Builder | ||
public class MyDailyQuestionAnswerVo { | ||
|
||
@Schema(description = "답변한 날짜입니다.", example = "20000101") | ||
private final Timestamp answerTime; | ||
|
||
@Schema(description = "질문의 id(pk)값입니다.", example = "1") | ||
private final Long questionId; | ||
|
||
@Schema(description = "질문의 내용입니다.", example = "친구가 요리를 해줬는데 맛이 없다. 표정을 숨기지 못한다. vs 맛있다고 한다.") | ||
private final String question; | ||
|
||
@Schema(description = "답변의 id(pk)값입니다.", example = "1") | ||
private final Long answerId; | ||
|
||
@Schema(description = "답변의 내용입니다.", example = "맛있다고 한다.") | ||
private final String answer; | ||
|
||
public static MyDailyQuestionAnswerVo from(DailyQuestionAnswerVo dailyQuestionAnswerVo) { | ||
return MyDailyQuestionAnswerVo.builder() | ||
.answerTime(dailyQuestionAnswerVo.getDailyQuestion().getCreatedAt()) | ||
.questionId(dailyQuestionAnswerVo.getDailyQuestion().getId()) | ||
.question(dailyQuestionAnswerVo.getDailyQuestion().getContent()) | ||
.answerId(dailyQuestionAnswerVo.getAnswer().getId()) | ||
.answer(dailyQuestionAnswerVo.getAnswer().getContent()) | ||
.build(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Api/src/main/java/tify/server/api/user/service/RetrieveMyDailyAnswerUseCase.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 tify.server.api.user.service; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import tify.server.api.config.security.SecurityUtils; | ||
import tify.server.api.user.model.dto.vo.MyDailyQuestionAnswerVo; | ||
import tify.server.core.annotation.UseCase; | ||
import tify.server.domain.domains.question.adaptor.AnswerAdaptor; | ||
import tify.server.domain.domains.question.domain.DailyQuestionCategory; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class RetrieveMyDailyAnswerUseCase { | ||
|
||
private final AnswerAdaptor answerAdaptor; | ||
|
||
public Slice<MyDailyQuestionAnswerVo> execute(Pageable pageable) { | ||
Long currentUserId = SecurityUtils.getCurrentUserId(); | ||
return answerAdaptor | ||
.searchMyAnswer(currentUserId, pageable) | ||
.map(MyDailyQuestionAnswerVo::from); | ||
} | ||
|
||
public Long executeCount(DailyQuestionCategory dailyQuestionCategory) { | ||
Long currentUserId = SecurityUtils.getCurrentUserId(); | ||
return answerAdaptor.queryMyAnswerCountByDailyQuestionCategory( | ||
currentUserId, dailyQuestionCategory); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...in/src/main/java/tify/server/domain/domains/question/dto/model/DailyQuestionAnswerVo.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,16 @@ | ||
package tify.server.domain.domains.question.dto.model; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import tify.server.domain.domains.question.domain.Answer; | ||
import tify.server.domain.domains.question.domain.DailyQuestion; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class DailyQuestionAnswerVo { | ||
|
||
private DailyQuestion dailyQuestion; | ||
|
||
private Answer answer; | ||
} |
7 changes: 7 additions & 0 deletions
7
.../src/main/java/tify/server/domain/domains/question/repository/AnswerCustomRepository.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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package tify.server.domain.domains.question.repository; | ||
|
||
|
||
import java.util.List; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import tify.server.domain.domains.question.dto.condition.AnswerCondition; | ||
import tify.server.domain.domains.question.dto.model.AnswerVo; | ||
import tify.server.domain.domains.question.dto.model.DailyQuestionAnswerVo; | ||
|
||
public interface AnswerCustomRepository { | ||
|
||
Slice<AnswerVo> searchToPage(Long userId, AnswerCondition answerCondition); | ||
|
||
Long countAnswer(Long questionId); | ||
|
||
Long countMyAnswerByDailyQuestionCategory(Long userId, List<Long> dailyQuestionIdList); | ||
|
||
Slice<DailyQuestionAnswerVo> searchMyAnswerToPage(Long userId, Pageable pageable); | ||
} |
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