Skip to content

Commit

Permalink
Merge branch 'dev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
BYEONGRYEOL committed Aug 5, 2024
2 parents f5eaced + c846760 commit fcd6974
Show file tree
Hide file tree
Showing 73 changed files with 1,920 additions and 539 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ logs/

docker/docker-compose.yml
/docker/.env

firebase-genti.json
88 changes: 88 additions & 0 deletions genti-api/src/main/java/com/gt/genti/auth/api/AuthApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.gt.genti.auth.api;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.gt.genti.auth.dto.request.AppleLoginRequestDto;
import com.gt.genti.auth.dto.request.SocialAppLoginRequest;
import com.gt.genti.auth.dto.request.TokenRefreshRequestDto;
import com.gt.genti.auth.dto.response.OauthJwtResponse;
import com.gt.genti.auth.dto.response.SocialLoginResponse;
import com.gt.genti.error.ResponseCode;
import com.gt.genti.jwt.TokenResponse;
import com.gt.genti.response.GentiResponse.ApiResult;
import com.gt.genti.swagger.EnumResponse;
import com.gt.genti.swagger.EnumResponses;
import com.gt.genti.user.model.OauthPlatform;
import com.gt.genti.user.model.UserRole;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;

;

@Tag(name = "[AuthController] 인증 컨트롤러", description = "로그인을 처리한 후 토큰을 전달합니다.")
public interface AuthApi {
@Operation(summary = "oauth 로그인 페이지 호출", description = "구글, 카카오 oauth로그인페이지 로 Redirect 됩니다. url은 HttpHeader에 포함되어있습니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "303", description = "리디렉션을 위한 응답 헤더를 포함합니다.", headers = {
@Header(name = "Location", description = "리디렉션 URL", schema = @Schema(type = "string"))
}, content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Object> login(
@Parameter(description = "호출할 Oauth platform 종류", example = "KAKAO", schema = @Schema(allowableValues = {
"KAKAO"}))
@RequestParam(name = "oauthPlatform") OauthPlatform oauthPlatform);

@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.AppleOauthClaimInvalid),
@EnumResponse(ResponseCode.AppleOauthIdTokenExpired),
@EnumResponse(ResponseCode.AppleOauthIdTokenIncorrect),
@EnumResponse(ResponseCode.AppleOauthIdTokenInvalid),
@EnumResponse(ResponseCode.AppleOauthJwtValueInvalid),
@EnumResponse(ResponseCode.AppleOauthPublicKeyInvalid),
})
ResponseEntity<ApiResult<SocialLoginResponse>> loginApple(
@RequestBody @Valid AppleLoginRequestDto request);

ResponseEntity<ApiResult<SocialLoginResponse>> kakaoLogin(
@RequestParam(name = "code") String code);

@Deprecated
ResponseEntity<ApiResult<SocialLoginResponse>> googleLogin(
@RequestParam(name = "code") String code);

@Operation(summary = "테스트용 jwt 토큰 발급", description = "")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
ResponseEntity<ApiResult<TokenResponse>> getTestJwt(
@NotNull @RequestParam(name = "role", value = "role") UserRole role);

@Operation(summary = "oauth platform에서 로그인 후 받은 토큰을 전달하여 가입/로그인", description = "현재 애플, 카카오 지원합니다")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.AppleOauthClaimInvalid),
@EnumResponse(ResponseCode.AppleOauthIdTokenExpired),
@EnumResponse(ResponseCode.AppleOauthIdTokenIncorrect),
@EnumResponse(ResponseCode.AppleOauthIdTokenInvalid),
@EnumResponse(ResponseCode.AppleOauthJwtValueInvalid),
@EnumResponse(ResponseCode.AppleOauthPublicKeyInvalid),
})
ResponseEntity<ApiResult<OauthJwtResponse>> loginOrSignUpWithOAuthToken(
@RequestBody @Valid SocialAppLoginRequest socialAppLoginRequest);

ResponseEntity<ApiResult<TokenResponse>> reissue(
@RequestBody @Valid TokenRefreshRequestDto tokenRefreshRequestDto
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.gt.genti.auth.api.AuthApi;
import com.gt.genti.auth.dto.request.AppleLoginRequest;
import com.gt.genti.auth.dto.request.AppleLoginRequestDto;
import com.gt.genti.auth.dto.request.SocialAppLoginRequest;
Expand All @@ -22,27 +23,18 @@
import com.gt.genti.auth.dto.response.OauthJwtResponse;
import com.gt.genti.auth.dto.response.SocialLoginResponse;
import com.gt.genti.auth.service.AuthService;
import com.gt.genti.error.ResponseCode;
import com.gt.genti.jwt.JwtTokenProvider;
import com.gt.genti.jwt.TokenGenerateCommand;
import com.gt.genti.jwt.TokenResponse;
import com.gt.genti.model.LogAction;
import com.gt.genti.model.LogItem;
import com.gt.genti.model.LogRequester;
import com.gt.genti.model.Logging;
import com.gt.genti.swagger.EnumResponse;
import com.gt.genti.swagger.EnumResponses;
import com.gt.genti.user.model.AuthUser;
import com.gt.genti.user.model.OauthPlatform;
import com.gt.genti.user.model.UserRole;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.headers.Header;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
Expand All @@ -52,17 +44,11 @@
@Controller
@RequiredArgsConstructor
@RequestMapping("/auth/v1")
public class AuthController {
public class AuthController implements AuthApi {

private final JwtTokenProvider jwtTokenProvider;
private final AuthService authService;

@Operation(summary = "oauth 로그인 페이지 호출", description = "구글, 카카오 oauth로그인페이지 로 Redirect 됩니다. url은 HttpHeader에 포함되어있습니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "303", description = "리디렉션을 위한 응답 헤더를 포함합니다.", headers = {
@Header(name = "Location", description = "리디렉션 URL", schema = @Schema(type = "string"))
}, content = @Content(schema = @Schema(hidden = true)))
})
@GetMapping("/login/oauth2")
@Logging(item = LogItem.OAUTH_WEB, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
public ResponseEntity<Object> login(
Expand All @@ -73,25 +59,13 @@ public ResponseEntity<Object> login(
return new ResponseEntity<>(httpHeaders, HttpStatus.SEE_OTHER);
}

@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.AppleOauthClaimInvalid),
@EnumResponse(ResponseCode.AppleOauthIdTokenExpired),
@EnumResponse(ResponseCode.AppleOauthIdTokenIncorrect),
@EnumResponse(ResponseCode.AppleOauthIdTokenInvalid),
@EnumResponse(ResponseCode.AppleOauthJwtValueInvalid),
@EnumResponse(ResponseCode.AppleOauthPublicKeyInvalid),
})
@PostMapping("/login/oauth2/code/apple")
@Logging(item = LogItem.OAUTH_APPLE, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
public ResponseEntity<ApiResult<SocialLoginResponse>> loginApple(
@RequestBody @Valid AppleLoginRequestDto request) {
return success(authService.webLogin(AppleLoginRequest.of(OauthPlatform.APPLE, request.getToken())));
}

@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
})
@GetMapping("/login/oauth2/code/kakao")
@Logging(item = LogItem.OAUTH_KAKAO, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
public ResponseEntity<ApiResult<SocialLoginResponse>> kakaoLogin(
Expand All @@ -100,24 +74,18 @@ public ResponseEntity<ApiResult<SocialLoginResponse>> kakaoLogin(
}

@Deprecated
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
})
@GetMapping("/login/oauth2/code/google")
@Logging(item = LogItem.OAUTH_GOOGLE, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
public ResponseEntity<ApiResult<SocialLoginResponse>> googleLogin(
@RequestParam(name = "code") final String code) {
return success(authService.webLogin(SocialLoginRequestImpl.of(OauthPlatform.GOOGLE, code)));
}

@Operation(summary = "테스트용 jwt 토큰 발급", description = "")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
@GetMapping("/login/testjwt")
public ResponseEntity<ApiResult<TokenResponse>> getTestJwt(
@NotNull @RequestParam(name = "role", value = "role") UserRole role) {
Map<UserRole, String> userIdMapper = Map.of(UserRole.USER, "2", UserRole.ADMIN, "1", UserRole.CREATOR, "4", UserRole.OAUTH_FIRST_JOIN, String.valueOf(Long.MAX_VALUE));
Map<UserRole, String> userIdMapper = Map.of(UserRole.USER, "2", UserRole.ADMIN, "1", UserRole.CREATOR, "4",
UserRole.OAUTH_FIRST_JOIN, String.valueOf(Long.MAX_VALUE));
String userId = userIdMapper.get(role);
TokenGenerateCommand command = TokenGenerateCommand.builder()
.userId(userId)
Expand All @@ -129,16 +97,6 @@ public ResponseEntity<ApiResult<TokenResponse>> getTestJwt(
TokenResponse.of(accessToken, refreshToken));
}

@Operation(summary = "oauth platform에서 로그인 후 받은 토큰을 전달하여 가입/로그인", description = "현재 애플, 카카오 지원합니다")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.AppleOauthClaimInvalid),
@EnumResponse(ResponseCode.AppleOauthIdTokenExpired),
@EnumResponse(ResponseCode.AppleOauthIdTokenIncorrect),
@EnumResponse(ResponseCode.AppleOauthIdTokenInvalid),
@EnumResponse(ResponseCode.AppleOauthJwtValueInvalid),
@EnumResponse(ResponseCode.AppleOauthPublicKeyInvalid),
})
@PostMapping("/login/oauth2/token")
@Logging(item = LogItem.OAUTH_APP, action = LogAction.LOGIN, requester = LogRequester.ANONYMOUS)
public ResponseEntity<ApiResult<OauthJwtResponse>> loginOrSignUpWithOAuthToken(
Expand All @@ -149,7 +107,7 @@ public ResponseEntity<ApiResult<OauthJwtResponse>> loginOrSignUpWithOAuthToken(
@PostMapping("/reissue")
public ResponseEntity<ApiResult<TokenResponse>> reissue(
@RequestBody @Valid TokenRefreshRequestDto tokenRefreshRequestDto
){
) {
return success(authService.reissue(tokenRefreshRequestDto));
}

Expand Down
50 changes: 50 additions & 0 deletions genti-api/src/main/java/com/gt/genti/creator/api/CreatorApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.gt.genti.creator.api;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

import com.gt.genti.creator.dto.request.AccountUpdateRequestDto;
import com.gt.genti.creator.dto.request.CreatorStatusUpdateRequestDto;
import com.gt.genti.creator.dto.response.CreatorFindResponseDto;
import com.gt.genti.creator.dto.response.CreatorStatusUpdateResponseDto;
import com.gt.genti.error.ResponseCode;
import com.gt.genti.response.GentiResponse.ApiResult;
import com.gt.genti.swagger.AuthorizedCreator;
import com.gt.genti.swagger.EnumResponse;
import com.gt.genti.swagger.EnumResponses;
import com.gt.genti.user.model.AuthUser;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;

@Tag(name = "[CreatorController] 공급자 정보 컨트롤러", description = "공급자의 정보를 조회,수정합니다.")
@AuthorizedCreator
public interface CreatorApi {

@Operation(summary = "공급자 내정보 보기", description = "공급자의 내정보 보기")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
ResponseEntity<ApiResult<CreatorFindResponseDto>> getCreatorInfo(
@AuthUser Long userId);

@Operation(summary = "공급자 계좌정보 수정", description = "공급자의 내 계좌정보 수정")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
ResponseEntity<ApiResult<Boolean>> updateAccountInfo(
@AuthUser Long userId,
@RequestBody @Valid AccountUpdateRequestDto accountUpdateRequestDto);

@Operation(summary = "공급자 작업가능상태 수정", description = "공급자의 내 작업가능상태 수정")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
ResponseEntity<ApiResult<CreatorStatusUpdateResponseDto>> updateCreatorStatus(
@AuthUser Long userId,
@RequestBody @Valid CreatorStatusUpdateRequestDto creatorStatusUpdateRequestDto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,45 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gt.genti.creator.api.CreatorApi;
import com.gt.genti.creator.dto.request.AccountUpdateRequestDto;
import com.gt.genti.creator.dto.request.CreatorStatusUpdateRequestDto;
import com.gt.genti.creator.dto.response.CreatorFindResponseDto;
import com.gt.genti.creator.dto.response.CreatorStatusUpdateResponseDto;
import com.gt.genti.creator.service.CreatorService;
import com.gt.genti.error.ResponseCode;
import com.gt.genti.model.LogAction;
import com.gt.genti.model.LogItem;
import com.gt.genti.model.LogRequester;
import com.gt.genti.model.Logging;
import com.gt.genti.response.GentiResponse;
import com.gt.genti.response.GentiResponse.ApiResult;
import com.gt.genti.swagger.EnumResponse;
import com.gt.genti.swagger.EnumResponses;
import com.gt.genti.user.model.AuthUser;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@Tag(name = "[CreatorController] 공급자 정보 컨트롤러", description = "공급자의 정보를 조회,수정합니다.")
@RestController
@RequestMapping("/api/v1/creators")
@RequiredArgsConstructor
public class CreatorController {
public class CreatorController implements CreatorApi {
private final CreatorService creatorService;

@Operation(summary = "공급자 내정보 보기", description = "공급자의 내정보 보기")
@Logging(item = LogItem.CREATOR_MY, action = LogAction.VIEW, requester = LogRequester.CREATOR)
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
@GetMapping
public ResponseEntity<ApiResult<CreatorFindResponseDto>> getCreatorInfo(
@AuthUser Long userId) {
return GentiResponse.success(creatorService.getCreatorInfo(userId));
}

@Operation(summary = "공급자 계좌정보 수정", description = "공급자의 내 계좌정보 수정")
@Logging(item = LogItem.CREATOR_ACCOUNT, action = LogAction.UPDATE, requester = LogRequester.CREATOR)
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
@PostMapping("/account")
public ResponseEntity<ApiResult<Boolean>> updateAccountInfo(
@AuthUser Long userId,
@RequestBody @Valid AccountUpdateRequestDto accountUpdateRequestDto) {
return GentiResponse.success(creatorService.updateAccountInfo(userId, accountUpdateRequestDto));
}

@Operation(summary = "공급자 작업가능상태 수정", description = "공급자의 내 작업가능상태 수정")
@Logging(item = LogItem.CREATOR_STATUS, action = LogAction.UPDATE, requester = LogRequester.CREATOR)
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK),
@EnumResponse(ResponseCode.CreatorNotFound)
})
@PostMapping("/status")
public ResponseEntity<ApiResult<CreatorStatusUpdateResponseDto>> updateCreatorStatus(
@AuthUser Long userId,
Expand Down
37 changes: 37 additions & 0 deletions genti-api/src/main/java/com/gt/genti/picture/api/PictureApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.gt.genti.picture.api;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

import com.gt.genti.aws.dto.PreSignedUrlRequestDto;
import com.gt.genti.aws.dto.PreSignedUrlResponseDto;
import com.gt.genti.error.ResponseCode;
import com.gt.genti.response.GentiResponse.ApiResult;
import com.gt.genti.swagger.Authorized;
import com.gt.genti.swagger.EnumResponse;
import com.gt.genti.swagger.EnumResponses;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;

@Authorized
@Tag(name = "[PictureController] 공통 사진 컨트롤러", description = "사진 업로드 url을 요청합니다.")
public interface PictureApi {

@Operation(summary = "사진 업로드 url 1개 요청", description = "사진 1개의 업로드 url 요청")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
ResponseEntity<ApiResult<PreSignedUrlResponseDto>> getUploadUrl(
@RequestBody @Valid PreSignedUrlRequestDto preSignedUrlRequestDto);

@Operation(summary = "사진 업로드 url 리스트 요청", description = "사진 여러개의 업로드 url 요청")
@EnumResponses(value = {
@EnumResponse(ResponseCode.OK)
})
ResponseEntity<ApiResult<List<PreSignedUrlResponseDto>>> getUploadUrls(
@RequestBody @Valid List<PreSignedUrlRequestDto> requestDtoList);
}
Loading

0 comments on commit fcd6974

Please sign in to comment.