-
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.
Merge branch 'develop' of https://github.com/Team-baebae/baebae-BE in…
…to feature/answer/#39
- Loading branch information
Showing
41 changed files
with
519 additions
and
59 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -36,4 +36,4 @@ jobs: | |
run: | | ||
cd baebae-BE | ||
chmod +x ./gradlew | ||
./gradlew build -x test | ||
./gradlew build |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
38 changes: 38 additions & 0 deletions
38
...va/com/web/baebaeBE/domain/categorized/answer/controller/CategorizedAnswerController.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,38 @@ | ||
package com.web.baebaeBE.domain.categorized.answer.controller; | ||
|
||
import com.web.baebaeBE.domain.categorized.answer.controller.api.CategorizedAnswerApi; | ||
import com.web.baebaeBE.domain.categorized.answer.dto.CategorizedAnswerRequest; | ||
import com.web.baebaeBE.domain.categorized.answer.dto.CategorizedAnswerResponse; | ||
import com.web.baebaeBE.domain.categorized.answer.service.CategorizedAnswerService; | ||
import com.web.baebaeBE.global.authorization.annotation.AuthorizationAnswer; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/categorizedAnswer") | ||
public class CategorizedAnswerController implements CategorizedAnswerApi { | ||
|
||
private final CategorizedAnswerService categorizedAnswerService; | ||
|
||
|
||
@GetMapping("{answerId}") | ||
@AuthorizationAnswer | ||
public ResponseEntity<List<CategorizedAnswerResponse.CategoryInformationResponse>> getCategoriesByAnswerId( | ||
@PathVariable Long answerId | ||
) { | ||
return ResponseEntity.ok(categorizedAnswerService.getCategoriesByAnswerId(answerId)); | ||
} | ||
|
||
@PutMapping("/{answerId}") | ||
@AuthorizationAnswer | ||
public ResponseEntity<Void> updateCategoriesByAnswerId(@PathVariable Long answerId, @RequestBody CategorizedAnswerRequest.CategoryList categoryIds) { | ||
categorizedAnswerService.updateCategoriesByAnswerId(answerId, categoryIds); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
|
||
} |
56 changes: 56 additions & 0 deletions
56
.../java/com/web/baebaeBE/domain/categorized/answer/controller/api/CategorizedAnswerApi.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,56 @@ | ||
package com.web.baebaeBE.domain.categorized.answer.controller.api; | ||
|
||
import com.web.baebaeBE.domain.categorized.answer.dto.CategorizedAnswerRequest; | ||
import com.web.baebaeBE.domain.categorized.answer.dto.CategorizedAnswerResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
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.PathVariable; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
import java.util.List; | ||
|
||
@Tag(name = "CategorizedAnswer", description = "카테고리 내부의 피드에 관련된 API") | ||
public interface CategorizedAnswerApi { | ||
|
||
@Operation(summary = "피드가 속한 카테고리 조회", | ||
description = "Answer ID를 받아 해당 Answer에 연결된 모든 카테고리를 조회합니다.", | ||
security = @SecurityRequirement(name = "bearerAuth") | ||
) | ||
@Parameter( | ||
in = ParameterIn.HEADER, | ||
name = "Authorization", required = true, | ||
schema = @Schema(type = "string"), | ||
description = "Bearer [Access 토큰]") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "조회 성공") | ||
}) | ||
@GetMapping("{answerId}") | ||
ResponseEntity<List<CategorizedAnswerResponse.CategoryInformationResponse>> getCategoriesByAnswerId( | ||
@Parameter(description = "Answer의 ID", required = true) @PathVariable Long answerId | ||
); | ||
|
||
|
||
@Operation(summary = "피드가 속한 카테고리 수정", | ||
description = "Answer ID와 Category ID 리스트를 받아 피드가 속할 카테고리 정보를 수정합니다.", | ||
security = @SecurityRequirement(name = "bearerAuth") | ||
) | ||
@Parameter( | ||
in = ParameterIn.HEADER, | ||
name = "Authorization", required = true, | ||
schema = @Schema(type = "string"), | ||
description = "Bearer [Access 토큰]") | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "수정 성공") | ||
}) | ||
@PutMapping("/{answerId}") | ||
public ResponseEntity<Void> updateCategoriesByAnswerId(@PathVariable Long answerId, @RequestBody CategorizedAnswerRequest.CategoryList categoryIds) ; | ||
} |
20 changes: 20 additions & 0 deletions
20
...rc/main/java/com/web/baebaeBE/domain/categorized/answer/dto/CategorizedAnswerRequest.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,20 @@ | ||
package com.web.baebaeBE.domain.categorized.answer.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.List; | ||
|
||
public class CategorizedAnswerRequest { | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class CategoryList{ | ||
private List<Long> categoryIds; | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...c/main/java/com/web/baebaeBE/domain/categorized/answer/dto/CategorizedAnswerResponse.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,31 @@ | ||
package com.web.baebaeBE.domain.categorized.answer.dto; | ||
|
||
import com.web.baebaeBE.domain.category.dto.CategoryResponse; | ||
import com.web.baebaeBE.domain.category.entity.Category; | ||
import lombok.*; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class CategorizedAnswerResponse { | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class CategoryInformationResponse { | ||
private Long categoryId; | ||
private String categoryName; | ||
private String categoryImage; | ||
|
||
public static CategorizedAnswerResponse.CategoryInformationResponse of(Category category) { | ||
return CategorizedAnswerResponse.CategoryInformationResponse.builder() | ||
.categoryId(category.getId()) | ||
.categoryName(category.getCategoryName()) | ||
.categoryImage(category.getCategoryImage()) | ||
.build(); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.