-
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.
Merge pull request #85 from YAPP-Github/feature/favorite
Feature/favorite 찜하기 기능 구현
- Loading branch information
Showing
64 changed files
with
540 additions
and
214 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
src/main/java/com/pyonsnalcolor/auth/oauth/OAuthClient.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
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
2 changes: 1 addition & 1 deletion
2
.../com/pyonsnalcolor/auth/AuthMemberId.java → ...om/pyonsnalcolor/member/AuthMemberId.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
4 changes: 2 additions & 2 deletions
4
...snalcolor/auth/AuthParameterResolver.java → ...alcolor/member/AuthParameterResolver.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
2 changes: 1 addition & 1 deletion
2
...ava/com/pyonsnalcolor/auth/RedisUtil.java → ...a/com/pyonsnalcolor/member/RedisUtil.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
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
66 changes: 66 additions & 0 deletions
66
src/main/java/com/pyonsnalcolor/member/controller/FavoriteController.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,66 @@ | ||
package com.pyonsnalcolor.member.controller; | ||
|
||
import com.pyonsnalcolor.member.AuthMemberId; | ||
import com.pyonsnalcolor.member.dto.FavoriteRequestDto; | ||
import com.pyonsnalcolor.member.service.MemberService; | ||
import com.pyonsnalcolor.product.ProductFactory; | ||
import com.pyonsnalcolor.product.dto.ProductResponseDto; | ||
import com.pyonsnalcolor.product.enumtype.ProductType; | ||
import com.pyonsnalcolor.product.service.ProductService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@Slf4j | ||
@Tag(name = "찜하기 관련 api") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/favorites") | ||
public class FavoriteController { | ||
|
||
private final MemberService memberService; | ||
private final ProductFactory productFactory; | ||
|
||
@Operation(summary = "찜한 상품 조회", description = "찜한 PB 혹은 행사 상품을 조회합니다.") | ||
@GetMapping | ||
public ResponseEntity<Slice<ProductResponseDto>> getFavorites( | ||
@RequestParam int pageNumber, | ||
@RequestParam int pageSize, | ||
@RequestParam ProductType productType, | ||
@Parameter(hidden = true) @AuthMemberId Long memberId | ||
) { | ||
Pageable pageable = PageRequest.of(pageNumber, pageSize); | ||
Slice<String> productIds = memberService.getProductIdsOfFavorite(pageable, memberId, productType); | ||
ProductService productService = productFactory.getService(productType); | ||
Slice<ProductResponseDto> results = productService.getProductsOfFavoriteByIds(productIds); | ||
return new ResponseEntity(results, HttpStatus.OK); | ||
} | ||
|
||
@Operation(summary = "찜하기 등록", description = "상품을 찜하기에 등록합니다.") | ||
@PostMapping | ||
public ResponseEntity<Void> createFavorite( | ||
@Parameter(hidden = true) @AuthMemberId Long memberId, | ||
@RequestBody FavoriteRequestDto favoriteRequestDto | ||
) { | ||
memberService.createFavorite(memberId, favoriteRequestDto); | ||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
|
||
@Operation(summary = "찜하기 취소", description = "상품을 찜하기에서 취소합니다.") | ||
@DeleteMapping | ||
public ResponseEntity<Void> deleteFavorite( | ||
@Parameter(hidden = true) @AuthMemberId Long memberId, | ||
@RequestBody FavoriteRequestDto favoriteRequestDto | ||
) { | ||
memberService.deleteFavorite(memberId, favoriteRequestDto); | ||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/pyonsnalcolor/member/dto/FavoriteRequestDto.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,24 @@ | ||
package com.pyonsnalcolor.member.dto; | ||
|
||
import com.pyonsnalcolor.product.enumtype.ProductType; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Schema(description = "상품 찜하기 등록 DTO") | ||
@Getter | ||
@NoArgsConstructor | ||
@Builder | ||
@AllArgsConstructor | ||
public class FavoriteRequestDto { | ||
|
||
private String productId; | ||
|
||
private String productType; | ||
|
||
public ProductType getProductType() { | ||
return ProductType.valueOf(productType.toUpperCase()); | ||
} | ||
} |
Oops, something went wrong.