Skip to content

Commit

Permalink
Merge pull request #164 from TRIP-Side-Project/dev
Browse files Browse the repository at this point in the history
swagger 문서 작성
  • Loading branch information
don9m1n authored Dec 28, 2023
2 parents 3ca6d02 + f2fe560 commit 1c09c85
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@
import com.api.trip.domain.member.service.MemberService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Tag(name = "members", description = "회원 API")
@RestController
Expand All @@ -33,19 +29,22 @@ public class MemberController {
private final MemberService memberService;
private final EmailService emailService;

@Operation(summary = "회원 가입", description = "이메일, 비밀번호, 닉네임, [프로필 이미지]를 입력해서 회원가입을 한다.")
@PostMapping(value = "/join")
public ResponseEntity<Void> join(@ModelAttribute @Valid JoinRequest joinRequest) throws IOException {

memberService.join(joinRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "로그인", description = "이메일, 비밀번호를 입력해서 로그인한다.")
@PostMapping("/login")
public ResponseEntity<LoginResponse> login(@RequestBody @Valid LoginRequest loginRequest) {
LoginResponse loginResponse = memberService.login(loginRequest);
return ResponseEntity.ok().body(loginResponse);
}

@Operation(summary = "마이페이지", description = "마이페이지 화면으로 이동한다.")
@GetMapping("/me")
public ResponseEntity<MyPageResponse> myPage() {
MyPageResponse myPageResponse = memberService.myPage();
Expand All @@ -54,12 +53,14 @@ public ResponseEntity<MyPageResponse> myPage() {


// 인증 메일 전송
@Operation(summary = "인증 메일 전송", description = "인증 링크를 포함한 메일을 발송한다.")
@PostMapping("/send-email/{email}")
public void sendAuthEmail(@PathVariable String email) {
emailService.send(email, emailService.createEmailAuth(email));
}

// 이메일 인증
@Operation(summary = "이메일 인증", description = "인증 메일이 유효한지 검사하고 인증을 처리한다.")
@GetMapping("/auth-email/{email}/{authToken}")
public ResponseEntity<EmailResponse> emailAndAuthToken(@PathVariable String email, @PathVariable String authToken) {
EmailResponse emailResponse = emailService.authEmail(email, authToken);
Expand All @@ -71,20 +72,23 @@ public ResponseEntity<EmailResponse> emailAndAuthToken(@PathVariable String emai
return ResponseEntity.ok().headers(headers).body(emailResponse);
}

@Operation(summary = "비밀번호 찾기", description = "임시 비밀번호를 발급한다.")
@PreAuthorize("isAnonymous()")
@PostMapping("/find/password")
public ResponseEntity<Void> sendNewPassword(@RequestBody FindPasswordRequest findPasswordRequest) {
emailService.sendNewPassword(findPasswordRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "프로필 수정", description = "프로필 이미지, 닉네임, 관심 태그를 수정한다.")
@PreAuthorize("isAuthenticated()")
@PatchMapping("/me")
public ResponseEntity<Void> updateProfile(@ModelAttribute UpdateProfileRequest updateProfileRequest) throws IOException {
memberService.updateProfile(updateProfileRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "비밀번호 변경", description = "현재 비밀번호를 변경한다.")
@PreAuthorize("isAuthenticated()")
@PatchMapping("/password")
public ResponseEntity<Void> updatePassword(@RequestBody UpdatePasswordRequest updatePasswordRequest) {
Expand All @@ -93,28 +97,31 @@ public ResponseEntity<Void> updatePassword(@RequestBody UpdatePasswordRequest up
}


@Operation(summary = "회원 탈퇴", description = "[일반 회원]의 탈퇴 처리를 진행한다.")
@PreAuthorize("isAuthenticated()")
@DeleteMapping("/me")
public ResponseEntity<Void> deleteMember(@RequestBody DeleteRequest deleteRequest) {
memberService.deleteMember(deleteRequest);
return ResponseEntity.ok().build();
}

@Operation(summary = "소셜 회원 탈퇴", description = "[소셜 회원]의 탈퇴 처리를 진행한다.")
@PreAuthorize("isAuthenticated()")
@DeleteMapping("/social/me")
public ResponseEntity<Void> deleteSocialMember() {
memberService.deleteSocialMember();
return ResponseEntity.ok().build();
}

@Operation(summary = "로그아웃", description = "현재 계정을 로그아웃 처리한다.")
@PreAuthorize("isAuthenticated()")
@Operation(summary = "로그아웃")
@PostMapping("/logout")
public ResponseEntity<String> logoutMember() {
String username = SecurityContextHolder.getContext().getAuthentication().getName();
return ResponseEntity.ok().body(memberService.logout(username));
}

@Operation(summary = "refreshToken 재발급", description = "만료된 refreshToken을 재발급한다.")
@GetMapping("/rotate")
public JwtToken rotateToken(HttpServletRequest request){
String refreshToken = JwtTokenUtils.extractBearerToken(request.getHeader("refreshToken"));
Expand Down

0 comments on commit 1c09c85

Please sign in to comment.