Skip to content
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

Fix: createQuestion 이미지 요청 타입 변경 #162

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
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 @@ -16,13 +16,14 @@ import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import io.swagger.v3.oas.annotations.tags.Tag
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
import java.util.UUID
Expand All @@ -39,11 +40,9 @@ class QuestionController(
@PostMapping("/question")
fun createQuestion(
@Parameter(hidden = true) @MemberId memberId: UUID,
@Valid @RequestPart request: CreateQuestionRequest,
@RequestPart image: MultipartFile?,
@Valid @RequestBody request: CreateQuestionRequest,
): BaseResponse<CreateQuestionResponse> {
val imageUrl = image?.let { s3Service.uploadImage(it) }
return BaseResponse(msg = "문제 생성 성공", data = questionService.createQuestion(memberId, request, imageUrl))
return BaseResponse(msg = "문제 생성 성공", data = questionService.createQuestion(memberId, request))
}

@Operation(summary = "readQuestionDetail", description = "문제 상세 정보 조회")
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/swm_standard/phote/dto/QuestionDtos.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DeleteQuestionResponse(
data class CreateQuestionRequest(
@field:NotBlank(message = "statement 미입력")
val statement: String,
val imageUrl: String? = null,
@field:NotNull(message = "category 미입력")
val category: Category,
val options: JsonNode? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class QuestionService(
@Transactional
fun createQuestion(
memberId: UUID,
request: CreateQuestionRequest,
imageUrl: String?,
request: CreateQuestionRequest
): CreateQuestionResponse {
// 문제 생성 유저 확인
val member = memberRepository.findById(memberId).orElseThrow { NotFoundException("존재하지 않는 member") }
Expand All @@ -59,7 +58,7 @@ class QuestionService(
Question(
member = member,
statement = request.statement,
image = imageUrl,
image = request.imageUrl,
category = request.category,
options = request.options,
answer = request.answer,
Expand Down
Loading