diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d4568b2..1b1e346 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,3 +1,12 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[FIX]" +labels: '' +assignees: EunbeenDev + +--- + ## ๐Ÿ€ Summary > ์–ด๋–ค ๋ฌธ์ œ์ธ๊ฐ€์š”? - @@ -6,4 +15,4 @@ - ## โ˜๏ธ Reference -- +- diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..514a3a3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,17 @@ +--- +name: Task request +about: Suggest an idea for this project +title: "" +labels: +assignees: EunbeenDev + +--- +## ๐Ÿ€ Summary +> ์–ด๋–ค ๊ธฐ๋Šฅ์ธ๊ฐ€์š”? +- +## โœ”๏ธ Task & Description +> ์ƒ์„ธ ์ž‘์—… ๋‚ด์šฉ์„ ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”. +- + +## โ˜๏ธ Reference +- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 219bba8..d4e63c1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,3 +1,12 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEAT]" +labels: feature โœจ +assignees: EunbeenDev + +--- + ## ๐Ÿ€ Summary > ์–ด๋–ค ๊ธฐ๋Šฅ์ธ๊ฐ€์š”? - @@ -7,3 +16,7 @@ ## โ˜๏ธ Reference - + + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/src/main/java/com/movelog/domain/record/dto/response/Recent5RecordImagesRes.java b/src/main/java/com/movelog/domain/record/dto/response/Recent5RecordImagesRes.java new file mode 100644 index 0000000..02baa68 --- /dev/null +++ b/src/main/java/com/movelog/domain/record/dto/response/Recent5RecordImagesRes.java @@ -0,0 +1,17 @@ +package com.movelog.domain.record.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class Recent5RecordImagesRes { + + @Schema( type = "String", example ="https://movelog.com/record/1/image/1", description="์ตœ๊ทผ 5๊ฐœ์˜ ๊ธฐ๋ก ์ด๋ฏธ์ง€ URL") + private String imageUrl; +} diff --git a/src/main/java/com/movelog/domain/record/presentation/RecordController.java b/src/main/java/com/movelog/domain/record/presentation/RecordController.java index 53668f3..279909a 100644 --- a/src/main/java/com/movelog/domain/record/presentation/RecordController.java +++ b/src/main/java/com/movelog/domain/record/presentation/RecordController.java @@ -3,10 +3,7 @@ import com.movelog.domain.news.dto.response.NewsCalendarRes; import com.movelog.domain.record.dto.request.CreateRecordReq; import com.movelog.domain.record.dto.request.SearchKeywordReq; -import com.movelog.domain.record.dto.response.RecentRecordImagesRes; -import com.movelog.domain.record.dto.response.RecordCalendarRes; -import com.movelog.domain.record.dto.response.SearchKeywordRes; -import com.movelog.domain.record.dto.response.TodayRecordStatus; +import com.movelog.domain.record.dto.response.*; import com.movelog.domain.record.service.RecordService; import com.movelog.global.config.security.token.UserPrincipal; import com.movelog.global.payload.Message; @@ -97,9 +94,9 @@ public ResponseEntity retrieveRecentRecordImages( @GetMapping("/search") public ResponseEntity searchKeyword( @Parameter(description = "User์˜ ํ† ํฐ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.", required = true) @AuthenticationPrincipal UserPrincipal userPrincipal, - @Parameter(description = "๊ฒ€์ƒ‰ํ•  ๋ช…์‚ฌ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.", required = true) @RequestBody SearchKeywordReq searchKeywordReq + @Parameter(description = "๊ฒ€์ƒ‰ํ•  ๋ช…์‚ฌ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.", required = true) @RequestParam String keyword ) { - List result = recordService.searchKeyword(userPrincipal, searchKeywordReq); + List result = recordService.searchKeyword(userPrincipal, keyword); return ResponseEntity.ok(ApiResponseUtil.success(result)); } @@ -125,4 +122,22 @@ public ResponseEntity getRecordByDate( } + @Operation(summary = "์‚ฌ์šฉ์ž ๊ธฐ๋ก ์ด๋ฏธ์ง€ ์ค‘ ์ตœ์‹  5๊ฐœ ๋ชฉ๋ก ์กฐํšŒ API", description = "์‚ฌ์šฉ์ž๊ฐ€ ์ƒ์„ฑํ•œ ๊ธฐ๋ก ์ด๋ฏธ์ง€ ์ค‘ ์ตœ์‹  5๊ฐœ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "์ตœ์‹  5๊ฐœ ๊ธฐ๋ก ์ด๋ฏธ์ง€ ๋ชฉ๋ก ์กฐํšŒ ์„ฑ๊ณต", + content = @Content(mediaType = "application/json", + schema = @Schema(type = "array", implementation = Recent5RecordImagesRes.class))), + @ApiResponse(responseCode = "400", description = "์ตœ์‹  5๊ฐœ ๊ธฐ๋ก ์ด๋ฏธ์ง€ ๋ชฉ๋ก ์กฐํšŒ ์‹คํŒจ", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class))) + }) + @GetMapping("/current") + public ResponseEntity retrieveCurrentRecordImages( + @Parameter(description = "User์˜ ํ† ํฐ์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.", required = true) @AuthenticationPrincipal UserPrincipal userPrincipal + ) { + List result = recordService.retrieveCurrentRecordImages(userPrincipal); + return ResponseEntity.ok(ApiResponseUtil.success(result)); + } + + + } diff --git a/src/main/java/com/movelog/domain/record/repository/RecordRepository.java b/src/main/java/com/movelog/domain/record/repository/RecordRepository.java index c440f0a..01f978b 100644 --- a/src/main/java/com/movelog/domain/record/repository/RecordRepository.java +++ b/src/main/java/com/movelog/domain/record/repository/RecordRepository.java @@ -25,4 +25,10 @@ public interface RecordRepository extends JpaRepository { "AND r.actionTime BETWEEN :start AND :end " + "ORDER BY r.actionTime ASC") Page findRecordByUserAndCreatedAtBetween(User user, LocalDateTime start, LocalDateTime end, Pageable pageable); + + + // ์‚ฌ์šฉ์ž๊ฐ€ ๋“ฑ๋กํ•œ ๊ธฐ๋ก ์ค‘ ๊ฐ€์žฅ ์ตœ๊ทผ 5๊ฐœ์˜ ๊ธฐ๋ก์„ ์กฐํšŒ, ์ด๋ฏธ์ง€๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ๋งŒ ์กฐํšŒ + // 5๊ฐœ์˜ ๊ธฐ๋ก๋งŒ ์กฐํšŒ + List findTop5ByKeywordUserAndRecordImageNotNullOrderByActionTimeDesc(User user); + } diff --git a/src/main/java/com/movelog/domain/record/service/RecordService.java b/src/main/java/com/movelog/domain/record/service/RecordService.java index ca2572d..6a40c74 100644 --- a/src/main/java/com/movelog/domain/record/service/RecordService.java +++ b/src/main/java/com/movelog/domain/record/service/RecordService.java @@ -7,10 +7,7 @@ import com.movelog.domain.record.domain.VerbType; import com.movelog.domain.record.dto.request.CreateRecordReq; import com.movelog.domain.record.dto.request.SearchKeywordReq; -import com.movelog.domain.record.dto.response.RecentRecordImagesRes; -import com.movelog.domain.record.dto.response.RecordCalendarRes; -import com.movelog.domain.record.dto.response.SearchKeywordRes; -import com.movelog.domain.record.dto.response.TodayRecordStatus; +import com.movelog.domain.record.dto.response.*; import com.movelog.domain.record.repository.KeywordRepository; import com.movelog.domain.record.repository.RecordRepository; import com.movelog.domain.user.application.UserService; @@ -145,10 +142,9 @@ public List retrieveRecentRecordImages(UserPrincipal user } - public List searchKeyword(UserPrincipal userPrincipal, SearchKeywordReq searchKeywordReq) { + public List searchKeyword(UserPrincipal userPrincipal, String keyword) { User user = validUserById(userPrincipal); // User user = validUserById(5L); - String keyword = searchKeywordReq.getSearchKeyword(); List keywords = keywordRepository.findAllByUserAndKeywordContaining(user, keyword); keywords.forEach(k -> log.info("Keyword in DB: {}", k.getKeyword())); @@ -190,6 +186,19 @@ public Page getRecordByDate(UserPrincipal userPrincipal, Stri } + public List retrieveCurrentRecordImages(UserPrincipal userPrincipal) { + User user = validUserById(userPrincipal); + // User user = userRepository.findById(5L).orElseThrow(UserNotFoundException::new); + + List records = recordRepository.findTop5ByKeywordUserAndRecordImageNotNullOrderByActionTimeDesc(user); + + return records.stream() + .map(record -> Recent5RecordImagesRes.builder() + .imageUrl((record.getRecordImage())) + .build()) + .toList(); + } + private User validUserById(UserPrincipal userPrincipal) { Optional userOptional = userService.findById(userPrincipal.getId());