Skip to content

Commit

Permalink
refactor: ApiResponse 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
annahxxl committed Mar 4, 2024
1 parent f24a570 commit f905841
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 85 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kw.api.domain.auth.controller

import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.domain.auth.dto.request.RefreshTokenRequest
import com.kw.api.domain.auth.dto.response.TokenResponse
import com.kw.api.domain.auth.service.AuthService
Expand All @@ -17,23 +16,22 @@ import org.springframework.web.bind.annotation.*
class AuthController(val authService: AuthService) {

@Operation(summary = "로그아웃을 합니다.")
@ResponseStatus(HttpStatus.NO_CONTENT)
@GetMapping("/logout")
fun logout(@RequestBody refreshTokenRequest: RefreshTokenRequest) {
authService.logout(refreshTokenRequest)
}

@Operation(summary = "리프레시 토큰으로 어세스 토큰을 재발급합니다.")
@GetMapping("/refresh-access-token")
fun refreshAccessToken(@RequestBody refreshTokenRequest: RefreshTokenRequest) : ApiResponse<TokenResponse> {
val response = authService.refreshAccessToken(refreshTokenRequest)
return ApiResponse.ok(response)
fun refreshAccessToken(@RequestBody refreshTokenRequest: RefreshTokenRequest): TokenResponse {
return authService.refreshAccessToken(refreshTokenRequest)
}

@Operation(summary = "회원탈퇴합니다.")
@ResponseStatus(HttpStatus.NO_CONTENT)
@DeleteMapping("/withdraw")
fun withdrawMember(@AuthToMember member: Member): ApiResponse<Nothing> {
fun withdrawMember(@AuthToMember member: Member) {
authService.withdrawMember(member)
return ApiResponse.noContent()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.kw.api.domain.bundle.controller

import com.kw.api.common.dto.request.PageCondition
import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.common.dto.response.PageResponse
import com.kw.api.domain.bundle.dto.request.*
import com.kw.api.domain.bundle.dto.response.BundleDetailResponse
Expand Down Expand Up @@ -30,8 +29,8 @@ class BundleController(
fun createBundle(
@RequestBody @Valid request: BundleCreateRequest,
@AuthToMember member: Member
): ApiResponse<BundleDetailResponse> {
return ApiResponse.created(bundleService.createBundle(request, member))
): BundleDetailResponse {
return bundleService.createBundle(request, member)
}

//TODO: ES
Expand All @@ -40,17 +39,17 @@ class BundleController(
fun searchBundles(
@ModelAttribute @Valid searchCondition: BundleSearchCondition,
@ModelAttribute @Valid pageCondition: PageCondition
): ApiResponse<PageResponse<BundleResponse>> {
return ApiResponse.ok(bundleService.searchBundles(searchCondition, pageCondition))
): PageResponse<BundleResponse> {
return bundleService.searchBundles(searchCondition, pageCondition)
}

@Operation(summary = "내 꾸러미 목록 조회")
@GetMapping("/bundles/my")
fun getMyBundles(
@ModelAttribute @Valid getCondition: BundleGetCondition,
@AuthToMember member: Member
): ApiResponse<List<BundleResponse>> {
return ApiResponse.ok(bundleService.getMyBundles(getCondition, member))
): List<BundleResponse> {
return bundleService.getMyBundles(getCondition, member)
}

@Operation(summary = "꾸러미 상세 조회")
Expand All @@ -59,8 +58,8 @@ class BundleController(
@PathVariable id: Long,
@RequestParam("showOnlyMyQuestions", required = false, defaultValue = "false") showOnlyMyQuestions: Boolean,
@AuthToMember member: Member
): ApiResponse<BundleDetailResponse> {
return ApiResponse.ok(bundleService.getBundle(id, showOnlyMyQuestions, member))
): BundleDetailResponse {
return bundleService.getBundle(id, showOnlyMyQuestions, member)
}

@Operation(summary = "꾸러미 수정")
Expand All @@ -69,8 +68,8 @@ class BundleController(
@PathVariable id: Long,
@RequestBody @Valid request: BundleUpdateRequest,
@AuthToMember member: Member
): ApiResponse<BundleResponse> {
return ApiResponse.ok(bundleService.updateBundle(id, request, member))
): BundleResponse {
return bundleService.updateBundle(id, request, member)
}

@Operation(summary = "꾸러미 삭제")
Expand All @@ -79,43 +78,40 @@ class BundleController(
fun deleteBundle(
@PathVariable id: Long,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
bundleService.deleteBundle(id, member)
return ApiResponse.noContent()
}

@Operation(summary = "꾸러미 스크랩")
@ResponseStatus(HttpStatus.CREATED)
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/bundles/{id}/scrape")
fun scrapeBundle(
@PathVariable id: Long,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
bundleService.scrapeBundle(id, member)
return ApiResponse.created(Unit)
}

@Operation(summary = "꾸러미 내 질문 순서 변경")
@ResponseStatus(HttpStatus.NO_CONTENT)
@PatchMapping("/bundles/{id}/question-order")
fun updateQuestionOrder(
@PathVariable id: Long,
@RequestBody @Valid request: BundleQuestionOrderUpdateRequest,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
bundleService.updateQuestionOrder(id, request, member)
return ApiResponse.noContent()
}

@Operation(summary = "선택한 질문 꾸러미에 추가")
@ResponseStatus(HttpStatus.CREATED)
@ResponseStatus(HttpStatus.NO_CONTENT)
@PostMapping("/bundles/{id}/questions")
fun addQuestion(
@PathVariable id: Long,
@RequestBody @Valid request: BundleQuestionAddRequest,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
bundleService.addQuestion(id, request, member)
return ApiResponse.created(Unit)
}

@Operation(summary = "선택한 질문 꾸러미에서 삭제")
Expand All @@ -125,8 +121,7 @@ class BundleController(
@PathVariable id: Long,
@RequestBody @Valid request: BundleQuestionRemoveRequest,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
bundleService.removeQuestion(id, request, member)
return ApiResponse.noContent()
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package com.kw.api.domain.claim.controller

import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.domain.claim.dto.request.CreateClaimRequest
import com.kw.api.domain.claim.dto.response.ClaimResponse
import com.kw.api.domain.claim.service.ClaimService
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
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.RestController
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.*

@Tag(name = "건의")
@RestController
@RequestMapping("/api/v1")
class ClaimController(val claimService: ClaimService) {

@Operation(summary = "건의 생성")
@ResponseStatus(HttpStatus.CREATED)
@PostMapping("/claims")
fun createClaim(@RequestBody createClaimRequest: CreateClaimRequest): ApiResponse<ClaimResponse> {
val response = claimService.createClaim(createClaimRequest)
return ApiResponse.created(response)
fun createClaim(@RequestBody createClaimRequest: CreateClaimRequest): ClaimResponse {
return claimService.createClaim(createClaimRequest)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kw.api.domain.member.controller

import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.domain.member.dto.response.MemberInfoResponse
import com.kw.api.domain.member.service.MemberService
import com.kw.data.domain.member.Member
Expand All @@ -18,24 +17,25 @@ class MemberController(private val memberService: MemberService) {

@Operation(summary = "로그인된 사용자의 정보를 가져옵니다.")
@GetMapping("/me")
fun getUserInfo(@AuthToMember member: Member): ApiResponse<MemberInfoResponse> {
val response = memberService.getMemberInfo(member)
return ApiResponse.ok(response)
fun getUserInfo(@AuthToMember member: Member): MemberInfoResponse {
return memberService.getMemberInfo(member)
}

@Operation(summary = "사용자의 닉네임을 변경합니다.")
@PatchMapping("/me/nickname")
fun updateMemberNickname(@AuthToMember member: Member,
@RequestParam nickname: String): ApiResponse<MemberInfoResponse> {
val response = memberService.updateMemberNickname(member, nickname)
return ApiResponse.ok(response)
fun updateMemberNickname(
@AuthToMember member: Member,
@RequestParam nickname: String
): MemberInfoResponse {
return memberService.updateMemberNickname(member, nickname)
}

@Operation(summary = "회원 프로필 사진을 저장합니다.")
@PatchMapping(value = ["/me/profile-image"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
fun updateMemberProfileImage(@AuthToMember member: Member,
@RequestPart(value = "file", required = true) file: MultipartFile): ApiResponse<MemberInfoResponse> {
val response = memberService.updateMemberProfileImage(member, file)
return ApiResponse.ok(response)
fun updateMemberProfileImage(
@AuthToMember member: Member,
@RequestPart(value = "file", required = true) file: MultipartFile
): MemberInfoResponse {
return memberService.updateMemberProfileImage(member, file)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kw.api.domain.question.controller

import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.domain.question.dto.request.QuestionCreateRequest
import com.kw.api.domain.question.dto.request.QuestionSearchRequest
import com.kw.api.domain.question.dto.request.QuestionUpdateRequest
Expand All @@ -27,9 +26,8 @@ class QuestionController(val questionService: QuestionService) {
fun createQuestion(
@RequestBody @Valid request: QuestionCreateRequest,
@AuthToMember member: Member
): ApiResponse<QuestionResponse> {
val response = questionService.createQuestion(request, member)
return ApiResponse.created(response)
): QuestionResponse {
return questionService.createQuestion(request, member)
}

@Operation(summary = "질문 수정")
Expand All @@ -38,9 +36,8 @@ class QuestionController(val questionService: QuestionService) {
@PathVariable id: Long,
@RequestBody @Valid request: QuestionUpdateRequest,
@AuthToMember member: Member
): ApiResponse<QuestionResponse> {
val response = questionService.updateQuestion(id, request, member)
return ApiResponse.ok(response)
): QuestionResponse {
return questionService.updateQuestion(id, request, member)
}

@Operation(summary = "질문 삭제")
Expand All @@ -49,9 +46,8 @@ class QuestionController(val questionService: QuestionService) {
fun deleteQuestion(
@PathVariable id: Long,
@AuthToMember member: Member
): ApiResponse<Unit> {
) {
questionService.deleteQuestion(id, member)
return ApiResponse.noContent()
}

@Operation(summary = "질문 신고")
Expand All @@ -60,15 +56,13 @@ class QuestionController(val questionService: QuestionService) {
fun reportQuestion(
@RequestParam reason: String,
@PathVariable id: Long
): ApiResponse<QuestionReportResponse> {
val response = questionService.reportQuestion(reason, id)
return ApiResponse.created(response)
): QuestionReportResponse {
return questionService.reportQuestion(reason, id)
}

@Operation(summary = "질문 검색")
@GetMapping("/questions/search")
fun searchQuestion(@ModelAttribute questionSearchRequest: QuestionSearchRequest): ApiResponse<QuestionListResponse> {
val responses = questionService.searchQuestion(questionSearchRequest)
return ApiResponse.ok(responses)
fun searchQuestion(@ModelAttribute questionSearchRequest: QuestionSearchRequest): QuestionListResponse {
return questionService.searchQuestion(questionSearchRequest)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kw.api.domain.tag.controller

import com.kw.api.common.dto.response.ApiResponse
import com.kw.api.domain.tag.dto.response.TagResponse
import com.kw.api.domain.tag.service.TagService
import io.swagger.v3.oas.annotations.Operation
Expand All @@ -16,8 +15,7 @@ class TagController(val tagService: TagService) {

@Operation(summary = "태그 목록 조회")
@GetMapping("/tags")
fun getTags(): ApiResponse<List<TagResponse>> {
val responses = tagService.getTags()
return ApiResponse.ok(responses)
fun getTags(): List<TagResponse> {
return tagService.getTags()
}
}

0 comments on commit f905841

Please sign in to comment.