-
Notifications
You must be signed in to change notification settings - Fork 0
[FEATURE #26]: 가맹점 및 카테고리 구현 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8b7a7a4
refactor: 명시적으로 초기화
seoyeon2001 0c0fd6b
fix: 게시글/댓글 삭제 및 수정 코드 정리
seoyeon2001 7622e84
feature: 관리자 더미 유저 생성
seoyeon2001 3a15cb5
feature: 가맹점 등록, 수정, 조회
seoyeon2001 712e8e3
feature: 카테고리 등록, 수정, 조회
seoyeon2001 6f4c572
refactor: 카테고리 수정, 조회
seoyeon2001 8a33165
conflict 해결
seoyeon2001 9a86a35
docs: 스웨거 적용
seoyeon2001 64b36cd
refactor: gemini 리뷰 반영
seoyeon2001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/payper/server/merchant/controller/CategoryApi.java
This file contains hidden or 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,35 @@ | ||
| package com.payper.server.merchant.controller; | ||
|
|
||
| import com.payper.server.global.response.ApiResponse; | ||
| import com.payper.server.merchant.dto.CategoryRequest; | ||
| import com.payper.server.merchant.dto.CategoryResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Tag(name = "카테고리", description = "카테고리 등록/수정/조회 API") | ||
| public interface CategoryApi { | ||
|
|
||
| @Operation(summary = "카테고리 등록", description = "관리자만 등록 가능. depth는 최대 2.") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| ResponseEntity<ApiResponse<Long>> registerCategory( | ||
| @RequestBody CategoryRequest.RegisterCategory request | ||
| ); | ||
|
|
||
| @Operation(summary = "카테고리 수정", description = "관리자만 수정 가능. 부모 카테고리는 이름만, 자식 카테고리는 이름과 부모 변경 가능.") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| ResponseEntity<ApiResponse<Void>> updateCategory( | ||
| @Parameter(description = "카테고리 ID", required = true, example = "1") Long categoryId, | ||
| @RequestBody CategoryRequest.UpdateCategory request | ||
| ); | ||
|
|
||
| @Operation(summary = "카테고리 조회", description = "부모 카테고리 ID로 필터링 가능. 파라미터 미지정 시 부모 카테고리만 조회. 카테고리명 오름차순 정렬.", security = {}) | ||
| ResponseEntity<ApiResponse<List<CategoryResponse.CategoryItem>>> getCategories( | ||
| @Parameter(description = "부모 카테고리 ID 필터", required = false) Long parentCategoryId | ||
| ); | ||
| } |
69 changes: 69 additions & 0 deletions
69
src/main/java/com/payper/server/merchant/controller/CategoryController.java
This file contains hidden or 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,69 @@ | ||
| package com.payper.server.merchant.controller; | ||
|
|
||
| import com.payper.server.global.response.ApiResponse; | ||
| import com.payper.server.merchant.dto.CategoryRequest; | ||
| import com.payper.server.merchant.dto.CategoryResponse; | ||
| import com.payper.server.merchant.service.CategoryService; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.access.prepost.PreAuthorize; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @RestController | ||
| @RequestMapping("/api/v1/categories") | ||
| @RequiredArgsConstructor | ||
| public class CategoryController implements CategoryApi { | ||
| private final CategoryService categoryService; | ||
|
|
||
| /** | ||
| * 카테고리 등록 | ||
| * 관리자만 등록 가능 | ||
| * depth는 최대 2 | ||
| */ | ||
| @PreAuthorize("hasRole('ADMIN')") | ||
| @PostMapping() | ||
| public ResponseEntity<ApiResponse<Long>> registerCategory( | ||
| @RequestBody @Valid CategoryRequest.RegisterCategory request | ||
| ) { | ||
| Long categoryId = categoryService.registerCategory(request); | ||
| return ResponseEntity.status(HttpStatus.CREATED).body(ApiResponse.created(categoryId)); | ||
| } | ||
|
|
||
| /** | ||
| * 카테고리 수정 (depth는 수정할 수 없음) | ||
| * 관리자만 수정 가능 | ||
| * 부모 카테고리 -> 이름만 변경 가능 | ||
| * 자식 카테고리 -> 이름, 부모 변경 가능 | ||
| */ | ||
| @PreAuthorize("hasRole('ADMIN')") | ||
| @PutMapping("/{categoryId}") | ||
| public ResponseEntity<ApiResponse<Void>> updateCategory( | ||
| @PathVariable Long categoryId, | ||
| @RequestBody @Valid CategoryRequest.UpdateCategory request | ||
| ) { | ||
| categoryService.updateCategory(categoryId, request); | ||
| return ResponseEntity.ok(ApiResponse.ok()); | ||
| } | ||
|
|
||
| /** | ||
| * 카테고리 조회 | ||
| * | ||
| * 필터링 조건 | ||
| * 부모 카테고리 | ||
| * 파라미터 안 넣으면 부모 카테고리만 보임 | ||
| * | ||
| * 정렬 조건 | ||
| * 카테고리명, 오름차순 | ||
| */ | ||
| @GetMapping() | ||
| public ResponseEntity<ApiResponse<List<CategoryResponse.CategoryItem>>> getCategories( | ||
| @RequestParam(required = false) Long parentCategoryId | ||
| ) { | ||
| List<CategoryResponse.CategoryItem> response = categoryService.getCategories(parentCategoryId); | ||
| return ResponseEntity.ok(ApiResponse.ok(response)); | ||
| } | ||
| } | ||
29 changes: 26 additions & 3 deletions
29
src/main/java/com/payper/server/merchant/controller/MerchantApi.java
This file contains hidden or 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,22 +1,45 @@ | ||
| package com.payper.server.merchant.controller; | ||
|
|
||
| import com.payper.server.global.response.ApiResponse; | ||
| import com.payper.server.merchant.dto.MerchantRequest; | ||
| import com.payper.server.merchant.dto.MerchantResponse; | ||
| import com.payper.server.post.dto.PostRequest; | ||
| import com.payper.server.security.CustomUserDetails; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.parameters.RequestBody; | ||
| import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| @Tag(name = "가맹점", description = "가맹점 관련 API") | ||
| import java.util.List; | ||
|
|
||
| @Tag(name = "가맹점", description = "가맹점 등록/수정/조회 및 게시글 작성 API") | ||
| public interface MerchantApi { | ||
|
|
||
| @Operation(summary = "가맹점 등록", description = "관리자만 등록 가능. 카테고리를 선택하여 가맹점을 등록합니다.") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| ResponseEntity<ApiResponse<Long>> registerMerchant( | ||
| @RequestBody MerchantRequest.RegisterMerchant request | ||
| ); | ||
|
|
||
| @Operation(summary = "가맹점 수정", description = "관리자만 수정 가능") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| ResponseEntity<ApiResponse<Void>> updateMerchant( | ||
| @Parameter(description = "가맹점 ID", required = true, example = "1") Long merchantId, | ||
| @RequestBody MerchantRequest.UpdateMerchant request | ||
| ); | ||
|
|
||
| @Operation(summary = "가맹점 조회", description = "카테고리 ID로 필터링 가능. 가맹점명 오름차순 정렬.", security = {}) | ||
| ResponseEntity<ApiResponse<List<MerchantResponse.MerchantItem>>> getMerchants( | ||
| @Parameter(description = "카테고리 ID 필터", required = false) Long categoryId | ||
| ); | ||
|
|
||
| @Operation(summary = "게시글 작성", description = "가맹점에 대한 게시글을 작성합니다.") | ||
| @SecurityRequirement(name = "bearerAuth") | ||
| ResponseEntity<ApiResponse<Long>> createPost( | ||
| CustomUserDetails user, | ||
| @Parameter(description = "가맹점 ID", example = "1") Long merchantId, | ||
| PostRequest.CreatePost request | ||
| @Parameter(description = "가맹점 ID", example = "1", required = true) Long merchantId, | ||
| @RequestBody PostRequest.CreatePost request | ||
| ); | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.