Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.edison.project.domain.artletter.entity.ArtletterCategory;
import com.edison.project.domain.artletter.service.ArtletterService;
import com.edison.project.global.security.CustomUserPrincipal;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -20,6 +22,10 @@

import java.util.List;

@Tag(
name = "Artletter",
description = "μ•„νŠΈλ ˆν„° κ΄€λ ¨ API - μ•„νŠΈλ ˆν„° 생성, 쑰회, 검색, μ’‹μ•„μš”, 슀크랩, μΆ”μ²œλ°” λ“±"
)
@RestController
@RequestMapping("/artletters")
@RequiredArgsConstructor
Expand All @@ -31,6 +37,9 @@ public class ArtletterController {
// μ•„νŠΈλ ˆν„° 등둝
@PostMapping
@PreAuthorize("isAuthenticated()")
@Operation(
summary = "μ•„νŠΈλ ˆν„° 등둝"
)
public ResponseEntity<ApiResponse> createArtletter(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@Valid @RequestBody ArtletterDTO.CreateRequestDto requestDto) {
Expand All @@ -41,6 +50,9 @@ public ResponseEntity<ApiResponse> createArtletter(

// 전체 μ•„νŠΈλ ˆν„° 쑰회
@GetMapping
@Operation(
summary = "전체 μ•„νŠΈλ ˆν„° 쑰회"
)
public ResponseEntity<ApiResponse> getAllArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@RequestParam(defaultValue = "0") int page,
Expand All @@ -61,6 +73,10 @@ public ResponseEntity<ApiResponse> getAllArtletters(

// μ•„νŠΈλ ˆν„° 검색
@GetMapping("/search")
@Operation(
summary = "μ•„νŠΈλ ˆν„° 검색",
description = "μž…λ ₯ν•œ ν‚€μ›Œλ“œλ₯Ό κΈ°μ€€μœΌλ‘œ μ•„νŠΈλ ˆν„°λ₯Ό κ²€μƒ‰ν•©λ‹ˆλ‹€. νƒœκ·Έ, 제λͺ©, λ‚΄μš©μ— λŒ€ν•œ full text searchλ₯Ό ν•˜κ³ , κ²€μƒ‰μ–΄μ™€μ˜ 관련도λ₯Ό κΈ°μ€€μœΌλ‘œ κ²°κ³Όλ₯Ό μ •λ ¬ν•©λ‹ˆλ‹€."
)
public ResponseEntity<ApiResponse> searchArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@RequestParam(value = "keyword", required = false) String keyword,
Expand All @@ -85,6 +101,9 @@ public ResponseEntity<ApiResponse> searchArtletters(


@GetMapping("/editor-pick")
@Operation(
summary = "에디터 ν”½ μ•„νŠΈλ ˆν„° 쑰회"
)
public ResponseEntity<ApiResponse> getEditorArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal) {
List<ArtletterDTO.ListResponseDto> response = artletterService.getEditorArtletters(userPrincipal);
Expand All @@ -95,6 +114,9 @@ public ResponseEntity<ApiResponse> getEditorArtletters(
// μ’‹μ•„μš” κΈ°λŠ₯
@PostMapping("/{letterId}/like")
@PreAuthorize("isAuthenticated()")
@Operation(
summary = "μ•„νŠΈλ ˆν„° μ’‹μ•„μš” ν† κΈ€"
)
public ResponseEntity<ApiResponse> likeArtletter(@PathVariable Long letterId, @AuthenticationPrincipal CustomUserPrincipal userPrincipal) {
ArtletterDTO.LikeResponseDto response = artletterService.likeToggleArtletter(userPrincipal, letterId);

Expand All @@ -104,13 +126,19 @@ public ResponseEntity<ApiResponse> likeArtletter(@PathVariable Long letterId, @A
// 슀크랩 κΈ°λŠ₯
@PostMapping("/{letterId}/scrap")
@PreAuthorize("isAuthenticated()")
@Operation(
summary = "μ•„νŠΈλ ˆν„° 슀크랩 ν† κΈ€"
)
public ResponseEntity<ApiResponse> scrapArtletter(@PathVariable Long letterId, @AuthenticationPrincipal CustomUserPrincipal userPrincipal) {
ArtletterDTO.ScrapResponseDto response = artletterService.scrapToggleArtletter(userPrincipal, letterId);
return ApiResponse.onSuccess(SuccessStatus._OK, response);
}

// μ•„νŠΈλ ˆν„° 상세 쑰회
@GetMapping("/{letterId}")
@Operation(
summary = "μ•„νŠΈλ ˆν„° μƒμ„Έλ‚΄μš© 쑰회"
)
public ResponseEntity<ApiResponse> getArtletterInfo(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@PathVariable("letterId") Long letterId) {
Expand All @@ -119,19 +147,31 @@ public ResponseEntity<ApiResponse> getArtletterInfo(
}

@GetMapping("/recommend-bar/category")
@Operation(
summary = "μΆ”μ²œλ°” μΉ΄ν…Œκ³ λ¦¬ 쑰회",
description = "μ•„νŠΈλ ˆν„° μΆ”μ²œλ°”μ— λ“€μ–΄κ°ˆ 3개의 μΉ΄ν…Œκ³ λ¦¬κ°’μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€."
)
public ResponseEntity<ApiResponse> getRecommendCategory() {
List<String> categories = artletterService.getRecommendCategory();
return ApiResponse.onSuccess(SuccessStatus._OK, new ArtletterDTO.RecommendCategoryResponse(categories));
}

@GetMapping("/recommend-bar/keyword")
@Operation(
summary = "μΆ”μ²œλ°” ν‚€μ›Œλ“œ 쑰회",
description = "μ•„νŠΈλ ˆν„° μΆ”μ²œλ°”μ— λ“€μ–΄κ°ˆ 3개의 ν‚€μ›Œλ“œκ°’μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€."
)
public ResponseEntity<ApiResponse> getRecommendKeywords(
@RequestParam List<Long> artletterIds) {
List<ArtletterDTO.recommendKeywordDto> response = artletterService.getRecommendKeyword(artletterIds);
return ApiResponse.onSuccess(SuccessStatus._OK, response);
}

@GetMapping("/more/{currentId}")
@Operation(
summary = "λ‹€λ₯Έ μ•„νŠΈλ ˆν„° 랜덀 쑰회",
description = "μ‚¬μš©μžκ°€ ν˜„μž¬ 보고 μžˆλŠ” μ•„νŠΈλ ˆν„°λ₯Ό μ œμ™Έν•œ λ‹€λ₯Έ μ•„νŠΈλ ˆν„° 3개λ₯Ό 랜덀으둜 μ‘°νšŒν•©λ‹ˆλ‹€."
)
public ResponseEntity<ApiResponse> getRandomArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@PathVariable("currentId") Long currentId) {
Expand All @@ -142,6 +182,9 @@ public ResponseEntity<ApiResponse> getRandomArtletters(

@GetMapping("/scrap")
@PreAuthorize("isAuthenticated()")
@Operation(
summary = "μŠ€ν¬λž©ν•œ μ•„νŠΈλ ˆν„° 쑰회"
)
public ResponseEntity<ApiResponse> getScrapArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@RequestParam(defaultValue = "0") int page,
Expand All @@ -152,6 +195,9 @@ public ResponseEntity<ApiResponse> getScrapArtletters(

@GetMapping("/scrap/{category}")
@PreAuthorize("isAuthenticated()")
@Operation(
summary = "μŠ€ν¬λž©ν•œ μ•„νŠΈλ ˆν„° μΉ΄ν…Œκ³ λ¦¬λ³„ 쑰회"
)
public ResponseEntity<ApiResponse> getScrapCategoryArtletters(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@PathVariable ArtletterCategory category,
Expand All @@ -163,13 +209,19 @@ public ResponseEntity<ApiResponse> getScrapCategoryArtletters(

// 졜근 검색어 쑰회
@GetMapping("/search-memory")
@Operation(
summary = "졜근 검색어 쑰회"
)
public ResponseEntity<ApiResponse> getMemoryMemory(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal) {
return artletterService.getMemoryKeyword(userPrincipal);
}

// 졜근 검색어 μ‚­μ œ
@DeleteMapping("/search-memory")
@Operation(
summary = "졜근 검색어 μ‚­μ œ"
)
public ResponseEntity<ApiResponse> deleteMemoryKeyword(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@RequestParam(value = "keyword", required = false) String keyword) {
Expand All @@ -178,6 +230,9 @@ public ResponseEntity<ApiResponse> deleteMemoryKeyword(

// μΉ΄ν…Œκ³ λ¦¬λ³„ μ•„νŠΈλ ˆν„° 쑰회
@GetMapping("/category")
@Operation(
summary = "μ•„νŠΈλ ˆν„° μΉ΄ν…Œκ³ λ¦¬λ³„ 쑰회"
)
public ResponseEntity<ApiResponse> getArtlettersByCategory(
@AuthenticationPrincipal CustomUserPrincipal userPrincipal,
@RequestParam("category") ArtletterCategory category,
Expand Down