Skip to content

Commit

Permalink
Merge pull request #297 from WE-ARE-RACCOONS/RAC-410
Browse files Browse the repository at this point in the history
RAC-410 fix : ์‘๋‹ต ๊ฐ์ฒด ๋ณ€๊ฒฝ
  • Loading branch information
ywj9811 authored Jul 9, 2024
2 parents 450b5ab + 26adcb7 commit cb7fd9e
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import static com.postgraduate.domain.auth.presentation.constant.AuthResponseCode.*;
import static com.postgraduate.domain.auth.presentation.constant.AuthResponseMessage.*;
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseCode.SENIOR_CREATE;
import static com.postgraduate.domain.senior.presentation.constant.SeniorResponseMessage.CREATE_SENIOR;
import static com.postgraduate.global.dto.ResponseDto.create;

@RestController
@RequiredArgsConstructor
Expand All @@ -36,93 +38,93 @@ public class AuthController {

@PostMapping("/login/{provider}")
@Operation(summary = "์†Œ์…œ ๋กœ๊ทธ์ธ", description = "ํšŒ์›์ธ ๊ฒฝ์šฐ JWT๋ฅผ, ํšŒ์›์ด ์•„๋‹Œ ๊ฒฝ์šฐ socialId๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค(ํšŒ์›๊ฐ€์ž…์€ ์ง„ํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค).")
public ResponseDto<AuthResponse> authLogin(@RequestBody @Valid CodeRequest request, @PathVariable Provider provider) {
public ResponseEntity<ResponseDto<AuthResponse>> authLogin(@RequestBody @Valid CodeRequest request, @PathVariable Provider provider) {
SignInUseCase signInUseCase = selectOauth.selectSignIn(provider);
AuthUserResponse authUser = signInUseCase.getUser(request);
if (authUser.user() == null)
return ResponseDto.create(AUTH_NONE.getCode(), NOT_REGISTERED_USER.getMessage(), authUser);
return ResponseEntity.ok(create(AUTH_NONE.getCode(), NOT_REGISTERED_USER.getMessage(), authUser));
JwtTokenResponse jwtToken = jwtUseCase.signIn(authUser.user());
return ResponseDto.create(AUTH_ALREADY.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_ALREADY.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/dev/login/{provider}")
@Operation(summary = "๊ฐœ๋ฐœ์šฉ ์†Œ์…œ ๋กœ๊ทธ์ธ", description = "ํšŒ์›์ธ ๊ฒฝ์šฐ JWT๋ฅผ, ํšŒ์›์ด ์•„๋‹Œ ๊ฒฝ์šฐ socialId๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค(ํšŒ์›๊ฐ€์ž…์€ ์ง„ํ–‰ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค).")
public ResponseDto<AuthResponse> authDevLogin(@RequestBody @Valid CodeRequest request, @PathVariable Provider provider) {
public ResponseEntity<ResponseDto<AuthResponse>> authDevLogin(@RequestBody @Valid CodeRequest request, @PathVariable Provider provider) {
SignInUseCase signInUseCase = selectOauth.selectSignIn(provider);
AuthUserResponse authUser = signInUseCase.getDevUser(request);
if (authUser.user() == null)
return ResponseDto.create(AUTH_NONE.getCode(), NOT_REGISTERED_USER.getMessage(), authUser);
return ResponseEntity.ok(create(AUTH_NONE.getCode(), NOT_REGISTERED_USER.getMessage(), authUser));
JwtTokenResponse jwtToken = jwtUseCase.signIn(authUser.user());
return ResponseDto.create(AUTH_ALREADY.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_ALREADY.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/logout")
@Operation(summary = "๋กœ๊ทธ์•„์›ƒ", description = "ํ† ํฐ ๊ฐ™์ด ๋ณด๋‚ด์ฃผ์„ธ์š”")
public ResponseDto<Void> logout(@AuthenticationPrincipal User user) {
public ResponseEntity<ResponseDto<Void>> logout(@AuthenticationPrincipal User user) {
jwtUseCase.logout(user);
return ResponseDto.create(AUTH_DELETE.getCode(), LOGOUT_USER.getMessage());
return ResponseEntity.ok(create(AUTH_DELETE.getCode(), LOGOUT_USER.getMessage()));
}

@PostMapping("/signout/{provider}/{userId}")
@Operation(summary = "ํšŒ์› ํƒˆํ‡ด | ๊ด€๋ฆฌ์ž ํ† ํฐ ํ•„์š”", description = "ํšŒ์› ํƒˆํ‡ด ์ง„ํ–‰")
public ResponseDto<Void> signOut(@PathVariable Provider provider, @PathVariable Long userId) {
public ResponseEntity<ResponseDto<Void>> signOut(@PathVariable Provider provider, @PathVariable Long userId) {
SignOutUseCase signOutUseCase = selectOauth.selectSignOut(provider);
signOutUseCase.signOut(userId);
return ResponseDto.create(AUTH_DELETE.getCode(), SIGNOUT_USER.getMessage());
return ResponseEntity.ok(create(AUTH_DELETE.getCode(), SIGNOUT_USER.getMessage()));
}

@PostMapping("/user/signup")
@Operation(summary = "๋Œ€ํ•™์ƒ ํšŒ์›๊ฐ€์ž…", description = "๋กœ๊ทธ์ธ API์—์„œ ๋ฐ˜ํ™˜ํ•œ socialId, ๋‹‰๋„ค์ž„, ๋ฒˆํ˜ธ, ๋งˆ์ผ€ํŒ… ์ˆ˜์‹ ์—ฌ๋ถ€, ํฌ๋ง ํ•™๊ณผ, ํฌ๋ง ๋ถ„์•ผ, ๋งค์นญ ํฌ๋ง ์—ฌ๋ถ€")
public ResponseDto<JwtTokenResponse> signUpUser(@RequestBody @Valid SignUpRequest request) {
public ResponseEntity<ResponseDto<JwtTokenResponse>> signUpUser(@RequestBody @Valid SignUpRequest request) {
User user = signUpUseCase.userSignUp(request);
JwtTokenResponse jwtToken = jwtUseCase.signIn(user);
return ResponseDto.create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/user/token")
@Operation(summary = "ํ›„๋ฐฐ๋กœ ๋ณ€๊ฒฝ | ํ† ํฐ ํ•„์š”", description = "ํ›„๋ฐฐ๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ ํ›„๋ฐฐ ํ† ํฐ ๋ฐœ๊ธ‰")
public ResponseDto<JwtTokenResponse> changeUserToken(@AuthenticationPrincipal User user) {
public ResponseEntity<ResponseDto<JwtTokenResponse>> changeUserToken(@AuthenticationPrincipal User user) {
JwtTokenResponse jwtToken = jwtUseCase.changeUser(user);
return ResponseDto.create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/user/change")
@Operation(summary = "ํ›„๋ฐฐ๋กœ ์ถ”๊ฐ€ ๊ฐ€์ž… | ํ† ํฐ ํ•„์š”", description = "๋Œ€ํ•™์›์ƒ ๋Œ€ํ•™์ƒ์œผ๋กœ ๋ณ€๊ฒฝ ์ถ”๊ฐ€ ๊ฐ€์ž…")
public ResponseDto<JwtTokenResponse> changeUser(@AuthenticationPrincipal User user,
public ResponseEntity<ResponseDto<JwtTokenResponse>> changeUser(@AuthenticationPrincipal User user,
@RequestBody @Valid UserChangeRequest changeRequest) {
signUpUseCase.changeUser(user, changeRequest);
JwtTokenResponse jwtToken = jwtUseCase.changeUser(user);
return ResponseDto.create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/senior/signup")
@Operation(summary = "๋Œ€ํ•™์›์ƒ ๊ฐ€์ž… - ํ•„์ˆ˜ ๊ณผ์ •๋งŒ", description = "๋Œ€ํ•™์›์ƒ ํšŒ์›๊ฐ€์ž… - ํ•„์ˆ˜ ๊ณผ์ •๋งŒ")
public ResponseDto<JwtTokenResponse> singUpSenior(@RequestBody @Valid SeniorSignUpRequest request) {
public ResponseEntity<ResponseDto<JwtTokenResponse>> singUpSenior(@RequestBody @Valid SeniorSignUpRequest request) {
User user = signUpUseCase.seniorSignUp(request);
JwtTokenResponse jwtToken = jwtUseCase.signIn(user);
return ResponseDto.create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken);
return ResponseEntity.ok(create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken));
}

@PostMapping("/senior/change")
@Operation(summary = "์„ ๋ฐฐ๋กœ ์ถ”๊ฐ€ ๊ฐ€์ž… | ํ† ํฐ ํ•„์š”", description = "๋Œ€ํ•™์ƒ ๋Œ€ํ•™์›์ƒ์œผ๋กœ ๋ณ€๊ฒฝ ์ถ”๊ฐ€ ๊ฐ€์ž…")
public ResponseDto<JwtTokenResponse> changeSenior(@AuthenticationPrincipal User user,
public ResponseEntity<ResponseDto<JwtTokenResponse>> changeSenior(@AuthenticationPrincipal User user,
@RequestBody @Valid SeniorChangeRequest changeRequest) {
User changeUser = signUpUseCase.changeSenior(user, changeRequest);
JwtTokenResponse jwtToken = jwtUseCase.changeSenior(changeUser);
return ResponseDto.create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken);
return ResponseEntity.ok(create(SENIOR_CREATE.getCode(), CREATE_SENIOR.getMessage(), jwtToken));
}

@PostMapping("/senior/token")
@Operation(summary = "์„ ๋ฐฐ๋กœ ๋ณ€๊ฒฝ | ํ† ํฐ ํ•„์š”", description = "์„ ๋ฐฐ๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ ์„ ๋ฐฐ ํ† ํฐ ๋ฐœ๊ธ‰")
public ResponseDto<JwtTokenResponse> changeSeniorToken(@AuthenticationPrincipal User user) {
public ResponseEntity<ResponseDto<JwtTokenResponse>> changeSeniorToken(@AuthenticationPrincipal User user) {
JwtTokenResponse jwtToken = jwtUseCase.changeSenior(user);
return ResponseDto.create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_CREATE.getCode(), SUCCESS_AUTH.getMessage(), jwtToken));
}

@PostMapping("/refresh")
@Operation(summary = "ํ† ํฐ ์žฌ๋ฐœ๊ธ‰ | ํ† ํฐ ํ•„์š”", description = "refreshToken ์œผ๋กœ ํ† ํฐ ์žฌ๋ฐœ๊ธ‰")
public ResponseDto<JwtTokenResponse> refresh(@AuthenticationPrincipal User user, HttpServletRequest request) {
public ResponseEntity<ResponseDto<JwtTokenResponse>> refresh(@AuthenticationPrincipal User user, HttpServletRequest request) {
JwtTokenResponse jwtToken = jwtUseCase.regenerateToken(user, request);
return ResponseDto.create(AUTH_UPDATE.getCode(), SUCCESS_REGENERATE_TOKEN.getMessage(), jwtToken);
return ResponseEntity.ok(create(AUTH_UPDATE.getCode(), SUCCESS_REGENERATE_TOKEN.getMessage(), jwtToken));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import static com.postgraduate.domain.image.presentation.constant.ImageResponseCode.IMAGE_CREATE;
import static com.postgraduate.domain.image.presentation.constant.ImageResponseMessage.ISSUE_URL;
import static com.postgraduate.domain.image.presentation.constant.ImageResponseMessage.UPLOAD_URL;
import static com.postgraduate.global.dto.ResponseDto.create;

@RestController
@RequiredArgsConstructor
Expand All @@ -28,29 +30,29 @@ public class ImageController {

@PostMapping("/url/profile")
@Operation(description = "USER Profile ๋“ฑ๋ก URL API - ์ด๋ฏธ์ง€ ํ’€๋„ค์ž„์œผ๋กœ ์ฃผ์„ธ์š” xxx.ํ™•์žฅ์ž, ์ด๋ฏธ์ง€ ์ด๋ฆ„์„ ์œ ๋‹ˆํฌํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š” UUID+ํŒŒ์ผ๋ช… ๋“ฑ๋“ฑ")
public ResponseDto<PreSignedUrlResponse> getProfilePreSignedUrl(@RequestBody PreSignedUrlRequest preSignedUrlRequest) {
public ResponseEntity<ResponseDto<PreSignedUrlResponse>> getProfilePreSignedUrl(@RequestBody PreSignedUrlRequest preSignedUrlRequest) {
PreSignedUrlResponse profileUrl = preSignedUseCase.getProfileUrl(preSignedUrlRequest);
return ResponseDto.create(IMAGE_CREATE.getCode(), ISSUE_URL.getMessage(), profileUrl);
return ResponseEntity.ok(create(IMAGE_CREATE.getCode(), ISSUE_URL.getMessage(), profileUrl));
}

@PostMapping("/url/certification")
@Operation(description = "Senior ํ•™์ƒ์ฆ ์ธ์ฆ ๋“ฑ๋ก URL API - ์ด๋ฏธ์ง€ ํ’€๋„ค์ž„์œผ๋กœ ์ฃผ์„ธ์š” xxx.ํ™•์žฅ์ž, ์ด๋ฏธ์ง€ ์ด๋ฆ„์„ ์œ ๋‹ˆํฌํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์ฃผ์„ธ์š” UUID+ํŒŒ์ผ๋ช… ๋“ฑ๋“ฑ")
public ResponseDto<PreSignedUrlResponse> getCertificationPreSignedUrl(@RequestBody PreSignedUrlRequest preSignedUrlRequest) {
public ResponseEntity<ResponseDto<PreSignedUrlResponse>> getCertificationPreSignedUrl(@RequestBody PreSignedUrlRequest preSignedUrlRequest) {
PreSignedUrlResponse certificationUrl = preSignedUseCase.getCertificationUrl(preSignedUrlRequest);
return ResponseDto.create(IMAGE_CREATE.getCode(), ISSUE_URL.getMessage(), certificationUrl);
return ResponseEntity.ok(create(IMAGE_CREATE.getCode(), ISSUE_URL.getMessage(), certificationUrl));
}

@PostMapping("/upload/profile")
@Operation(summary = "USER Profile ์—…๋กœ๋“œ ํ›„ ์—…๋กœ๋“œ URL return / ํ† ํฐ ํ•„์š”", description = "profileFile ์‚ฌ์ง„ Multipart File๋กœ ๋ณด๋‚ด์ฃผ์„ธ์š”")
public ResponseDto<ImageUrlResponse> getProfileUrl(@AuthenticationPrincipal User user, @RequestPart MultipartFile profileFile) {
public ResponseEntity<ResponseDto<ImageUrlResponse>> getProfileUrl(@AuthenticationPrincipal User user, @RequestPart MultipartFile profileFile) {
ImageUrlResponse imageUrlResponse = imageUploadUseCase.uploadProfile(user, profileFile);
return ResponseDto.create(IMAGE_CREATE.getCode(), UPLOAD_URL.getMessage(), imageUrlResponse);
return ResponseEntity.ok(create(IMAGE_CREATE.getCode(), UPLOAD_URL.getMessage(), imageUrlResponse));
}

@PostMapping("/upload/certification")
@Operation(summary = "SENIOR Certification ์—…๋กœ๋“œ ํ›„ ์—…๋กœ๋“œ URL return", description = "certificationFile ์‚ฌ์ง„ Multipart File๋กœ ๋ณด๋‚ด์ฃผ์„ธ์š”")
public ResponseDto<ImageUrlResponse> getCertificationUrl(@RequestPart MultipartFile certificationFile) {
public ResponseEntity<ResponseDto<ImageUrlResponse>> getCertificationUrl(@RequestPart MultipartFile certificationFile) {
ImageUrlResponse imageUrlResponse = imageUploadUseCase.uploadCertification(certificationFile);
return ResponseDto.create(IMAGE_CREATE.getCode(), UPLOAD_URL.getMessage(), imageUrlResponse);
return ResponseEntity.ok(create(IMAGE_CREATE.getCode(), UPLOAD_URL.getMessage(), imageUrlResponse));
}
}
Loading

0 comments on commit cb7fd9e

Please sign in to comment.