-
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.
- Loading branch information
Showing
27 changed files
with
674 additions
and
31 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
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
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
54 changes: 54 additions & 0 deletions
54
src/main/java/ddingdong/ddingdongBE/domain/question/api/AdminQuestionApi.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,54 @@ | ||
package ddingdong.ddingdongBE.domain.question.api; | ||
|
||
|
||
import ddingdong.ddingdongBE.auth.PrincipalDetails; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.request.GenerateQuestionRequest; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.request.ModifyQuestionRequest; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.response.AdminQuestionResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@Tag(name = "FAQ - Admin", description = "FAQ Admin API") | ||
@RequestMapping("/server/admin/questions") | ||
public interface AdminQuestionApi { | ||
|
||
@Operation(summary = "어드민 FAQ 업로드 API") | ||
@PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) | ||
@ResponseStatus(HttpStatus.CREATED) | ||
@SecurityRequirement(name = "AccessToken") | ||
void generateQuestion( | ||
@AuthenticationPrincipal PrincipalDetails principalDetails, | ||
@ModelAttribute GenerateQuestionRequest generateDocumentRequest); | ||
|
||
@Operation(summary = "어드민 FAQ 목록 조회 API") | ||
@GetMapping | ||
@ResponseStatus(HttpStatus.OK) | ||
@SecurityRequirement(name = "AccessToken") | ||
List<AdminQuestionResponse> getAllQuestions(); | ||
|
||
@Operation(summary = "어드민 FAQ 수정 API") | ||
@PatchMapping(value = "/{questionId}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@SecurityRequirement(name = "AccessToken") | ||
void modifyQuestion(@PathVariable Long questionId, | ||
@ModelAttribute ModifyQuestionRequest modifyQuestionRequest); | ||
|
||
@Operation(summary = "어드민 FAQ 삭제 API") | ||
@DeleteMapping("/{questionId}") | ||
@ResponseStatus(HttpStatus.NO_CONTENT) | ||
@SecurityRequirement(name = "AccessToken") | ||
void deleteQuestion(@PathVariable Long questionId); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/ddingdong/ddingdongBE/domain/question/api/QuestionApi.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,22 @@ | ||
package ddingdong.ddingdongBE.domain.question.api; | ||
|
||
|
||
import ddingdong.ddingdongBE.domain.question.controller.dto.response.QuestionResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import java.util.List; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@Tag(name = "FAQ", description = "FAQ API") | ||
@RequestMapping("/server/questions") | ||
public interface QuestionApi { | ||
|
||
@Operation(summary = "FAQ 목록 조회 API") | ||
@GetMapping | ||
@ResponseStatus(HttpStatus.OK) | ||
List<QuestionResponse> getAllQuestions(); | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/ddingdong/ddingdongBE/domain/question/controller/AdminQuestionController.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,42 @@ | ||
package ddingdong.ddingdongBE.domain.question.controller; | ||
|
||
import ddingdong.ddingdongBE.auth.PrincipalDetails; | ||
import ddingdong.ddingdongBE.domain.question.api.AdminQuestionApi; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.request.GenerateQuestionRequest; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.request.ModifyQuestionRequest; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.response.AdminQuestionResponse; | ||
import ddingdong.ddingdongBE.domain.question.service.QuestionService; | ||
import ddingdong.ddingdongBE.domain.user.entity.User; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class AdminQuestionController implements AdminQuestionApi { | ||
|
||
private final QuestionService questionService; | ||
|
||
@Override | ||
public void generateQuestion(PrincipalDetails principalDetails, GenerateQuestionRequest generateDocumentRequest) { | ||
User admin = principalDetails.getUser(); | ||
questionService.create(generateDocumentRequest.toEntity(admin)); | ||
} | ||
|
||
@Override | ||
public List<AdminQuestionResponse> getAllQuestions() { | ||
return questionService.getAll().stream() | ||
.map(AdminQuestionResponse::from) | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public void modifyQuestion(Long questionId, ModifyQuestionRequest modifyQuestionRequest) { | ||
questionService.update(questionId, modifyQuestionRequest.toEntity()); | ||
} | ||
|
||
@Override | ||
public void deleteQuestion(Long questionId) { | ||
questionService.delete(questionId); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/ddingdong/ddingdongBE/domain/question/controller/QuestionController.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,22 @@ | ||
package ddingdong.ddingdongBE.domain.question.controller; | ||
|
||
import ddingdong.ddingdongBE.domain.question.api.QuestionApi; | ||
import ddingdong.ddingdongBE.domain.question.controller.dto.response.QuestionResponse; | ||
import ddingdong.ddingdongBE.domain.question.service.QuestionService; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class QuestionController implements QuestionApi { | ||
|
||
private final QuestionService questionService; | ||
|
||
@Override | ||
public List<QuestionResponse> getAllQuestions() { | ||
return questionService.getAll().stream() | ||
.map(QuestionResponse::from) | ||
.toList(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ddingdong/ddingdongBE/domain/question/controller/dto/request/GenerateQuestionRequest.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,26 @@ | ||
package ddingdong.ddingdongBE.domain.question.controller.dto.request; | ||
|
||
import ddingdong.ddingdongBE.domain.question.entity.Question; | ||
import ddingdong.ddingdongBE.domain.user.entity.User; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Schema( | ||
name = "GenerateQuestionRequest", | ||
description = "FAQ 질문 생성 요청" | ||
) | ||
@Builder | ||
public record GenerateQuestionRequest( | ||
@Schema(description = "FAQ 질문", example = "질문") | ||
String question, | ||
@Schema(description = "FAQ 답변", example = "답변") | ||
String reply | ||
) { | ||
|
||
public Question toEntity(User user) { | ||
return Question.builder() | ||
.user(user) | ||
.question(this.question) | ||
.reply(this.reply).build(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...a/ddingdong/ddingdongBE/domain/question/controller/dto/request/ModifyQuestionRequest.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,25 @@ | ||
package ddingdong.ddingdongBE.domain.question.controller.dto.request; | ||
|
||
import ddingdong.ddingdongBE.domain.question.entity.Question; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Schema( | ||
name = "ModifyQuestionRequest", | ||
description = "FAQ 질문 수정 요청" | ||
) | ||
@Builder | ||
public record ModifyQuestionRequest( | ||
@Schema(description = "자료 제목", example = "제목") | ||
String question, | ||
@Schema(description = "자료 내용", example = "내용") | ||
String reply | ||
) { | ||
|
||
public Question toEntity() { | ||
return Question.builder() | ||
.question(this.question) | ||
.reply(this.reply) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.