-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/org/sopt/seminar/domain/member/api/MemberApiController.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 org.sopt.seminar.domain.member.api; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.seminar.domain.member.dto.request.MemberSaveRequest; | ||
import org.sopt.seminar.domain.member.dto.request.MemberUpdateRequest; | ||
import org.sopt.seminar.domain.member.dto.response.MemberGetResponse; | ||
import org.sopt.seminar.domain.member.dto.response.MemberSaveResponse; | ||
import org.sopt.seminar.domain.member.service.MemberService; | ||
import org.sopt.seminar.global.common.ApiResponse; | ||
import org.sopt.seminar.global.common.SuccessStatus; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/api/member") | ||
@Controller | ||
public class MemberApiController { | ||
private final MemberService memberService; | ||
|
||
@PostMapping | ||
public ResponseEntity<ApiResponse<?>> saveMember(@RequestBody final MemberSaveRequest memberSaveRequest) { | ||
final MemberSaveResponse savedMember = memberService.saveMember(memberSaveRequest); | ||
return ApiResponse.success(SuccessStatus.CREATED, savedMember); | ||
} | ||
|
||
@GetMapping("/{memberId}") | ||
public ResponseEntity<ApiResponse<?>> getMember(@PathVariable final Long memberId) { | ||
final MemberGetResponse findMember = memberService.getMember(memberId); | ||
return ApiResponse.success(SuccessStatus.OK, findMember); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<ApiResponse<?>> getMembers(final Pageable pageable) { | ||
final List<MemberGetResponse> findMembers = memberService.getMembers(pageable); | ||
return ApiResponse.success(SuccessStatus.OK, findMembers); | ||
} | ||
|
||
@PatchMapping("/{memberId}") | ||
public ResponseEntity<ApiResponse<?>> updateMember(@PathVariable final Long memberId, | ||
@RequestBody final MemberUpdateRequest memberUpdateRequest) { | ||
memberService.updateMember(memberId, memberUpdateRequest); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
|
||
@DeleteMapping("/{memberId}") | ||
public ResponseEntity<ApiResponse<?>> deleteMember(@PathVariable final Long memberId) { | ||
memberService.deleteMember(memberId); | ||
return ApiResponse.success(SuccessStatus.OK); | ||
} | ||
} |