-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Chore : Redis Listener 제거 * Feat : Controller 계층 구현 * Feat : Implementation 계층 구현 * Feat : Service 계층 구현 * Feat : Repository 계층 구현
- Loading branch information
Showing
12 changed files
with
149 additions
and
90 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/main/java/com/donkeys_today/server/application/reply/ReplyRetriever.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,26 @@ | ||
package com.donkeys_today.server.application.reply; | ||
|
||
import com.donkeys_today.server.application.auth.JwtUtil; | ||
import com.donkeys_today.server.domain.reply.Reply; | ||
import com.donkeys_today.server.infrastructure.reply.ReplyRepository; | ||
import com.donkeys_today.server.support.dto.type.ErrorType; | ||
import com.donkeys_today.server.support.exception.NotFoundException; | ||
import java.time.LocalDate; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReplyRetriever { | ||
|
||
private final ReplyRepository replyRepository; | ||
|
||
public Reply findReplyByDate(String year, String month, String date) { | ||
LocalDate localDate = LocalDate.of(Integer.parseInt(year), Integer.parseInt(month), | ||
Integer.parseInt(date)); | ||
Long userId = JwtUtil.getLoginMemberId(); | ||
return replyRepository.findByUserIdAndDiaryCreatedDate(userId, localDate).orElseThrow( | ||
() -> new NotFoundException(ErrorType.REPLY_NOT_FOUND) | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/donkeys_today/server/application/reply/ReplyService.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,22 @@ | ||
package com.donkeys_today.server.application.reply; | ||
|
||
import com.donkeys_today.server.domain.reply.Reply; | ||
import com.donkeys_today.server.presentation.reply.dto.response.ReplyResponse; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReplyService { | ||
|
||
private final ReplyRetriever replyRetriever; | ||
private final ReplyUpdater replyUpdater; | ||
|
||
@Transactional | ||
public ReplyResponse readReply(String year, String month, String date) { | ||
Reply reply = replyRetriever.findReplyByDate(year, month, date); | ||
reply.readReply(); | ||
return ReplyResponse.of(reply.getContent()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/donkeys_today/server/application/reply/ReplyUpdater.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,18 @@ | ||
package com.donkeys_today.server.application.reply; | ||
|
||
import com.donkeys_today.server.domain.reply.Reply; | ||
import com.donkeys_today.server.infrastructure.reply.ReplyRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class ReplyUpdater { | ||
|
||
private final ReplyRepository replyRepository; | ||
|
||
public void readReply(Reply reply) { | ||
reply.readReply(); | ||
replyRepository.save(reply); | ||
} | ||
} |
55 changes: 0 additions & 55 deletions
55
...n/java/com/donkeys_today/server/application/reply/listener/RedisReplyMessageListener.java
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
...in/java/com/donkeys_today/server/application/reply/listener/dto/DiaryListenedMessage.java
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/donkeys_today/server/presentation/api/ReplyController.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,26 @@ | ||
package com.donkeys_today.server.presentation.api; | ||
|
||
import com.donkeys_today.server.common.constants.Constants; | ||
import com.donkeys_today.server.presentation.reply.dto.response.ReplyResponse; | ||
import com.donkeys_today.server.support.dto.ApiResponse; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@Tag(name = "답변 관련") | ||
@RequestMapping("/api/v1") | ||
@RestController | ||
public interface ReplyController { | ||
|
||
@GetMapping("/reply") | ||
ResponseEntity<ApiResponse<ReplyResponse>> getReply( | ||
@RequestHeader(Constants.AUTHORIZATION) final String accessToken, | ||
@RequestParam @Parameter(name = "연도", description = "조회할 연도", required = true) final String year, | ||
@RequestParam @Parameter(name = "달", description = "조회할 달", required = true) final String month, | ||
@RequestParam @Parameter(name = "일", description = "조회할 일", required = true) final String date); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/donkeys_today/server/presentation/reply/ReplyControllerImpl.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,34 @@ | ||
package com.donkeys_today.server.presentation.reply; | ||
|
||
import com.donkeys_today.server.application.reply.ReplyService; | ||
import com.donkeys_today.server.common.constants.Constants; | ||
import com.donkeys_today.server.presentation.api.ReplyController; | ||
import com.donkeys_today.server.presentation.reply.dto.response.ReplyResponse; | ||
import com.donkeys_today.server.support.dto.ApiResponse; | ||
import com.donkeys_today.server.support.dto.type.SuccessType; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/v1") | ||
@RequiredArgsConstructor | ||
public class ReplyControllerImpl implements ReplyController { | ||
|
||
private final ReplyService replyService; | ||
|
||
@GetMapping("/reply") | ||
public ResponseEntity<ApiResponse<ReplyResponse>> getReply( | ||
@RequestHeader(Constants.AUTHORIZATION) final String accessToken, | ||
@RequestParam final String year, | ||
@RequestParam final String month, | ||
@RequestParam final String date) { | ||
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.success( | ||
SuccessType.READ_SUCCESS, replyService.readReply(year, month, date))); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/donkeys_today/server/presentation/reply/dto/response/ReplyResponse.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,9 @@ | ||
package com.donkeys_today.server.presentation.reply.dto.response; | ||
|
||
public record ReplyResponse( | ||
String content | ||
) { | ||
public static ReplyResponse of(String content) { | ||
return new ReplyResponse(content); | ||
} | ||
} |
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