Skip to content

Commit

Permalink
Merge pull request #89 from Open-Eye-Im-Developer/develop
Browse files Browse the repository at this point in the history
main에 v1.5 반영
  • Loading branch information
tidavid1 authored Feb 19, 2024
2 parents c57b57b + c61c6a9 commit f19bb3a
Show file tree
Hide file tree
Showing 84 changed files with 2,012 additions and 66 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/cd_gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ jobs:
run: echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.yml
shell: bash

## create firebase_service_key.json
- name: make firebase_service_key.json
run: touch ./src/main/resources/firebase_service_key.json
shell: bash

- name: save firebase_service_key.json from secrets
run: echo "${{ secrets.FIREBASE_SERVICE }}" > ./src/main/resources/firebase_service_key.json
shell: bash

## grant permission for gradlew
- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/ci_gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ jobs:
- name: save test_application.yml for secrets
run: echo "${{ secrets.APPLICATION_TEST }}" > ./src/test/resources/application.yml
shell: bash


## create firebase_service_key.json
- name: make firebase_service_key.json
run: touch ./src/main/resources/firebase_service_key.json
shell: bash

- name: save firebase_service_key.json from secrets
run: echo "${{ secrets.FIREBASE_SERVICE }}" > ./src/main/resources/firebase_service_key.json
shell: bash

## create test_ddl.sql for test

## execute Gradle test
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ out/
.vscode/

### application.yml ###
application*.yml
application*.yml
firebase*.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.oeid.mogakgo.common.base;

import jakarta.validation.constraints.NotNull;
import java.util.Objects;
import lombok.Getter;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.lang.Nullable;

@Getter
public class CursorPaginationInfoReq {

@Nullable
private final Long cursorId;

@NotNull
private final int pageSize;

@Nullable
private final Sort.Direction sortOrder;

public CursorPaginationInfoReq(Long cursorId, int pageSize, Direction sortOrder) {
this.cursorId = cursorId;
this.pageSize = pageSize;
this.sortOrder = Objects.requireNonNullElse(sortOrder, Direction.ASC);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.oeid.mogakgo.common.base;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import lombok.Getter;

@Schema(description = "커서 기반 페이지네이션 결과에 대한 일괄 응답")
@Getter
public class CursorPaginationResult<T> {

@Schema(description = "데이터 목록")
private List<T> data;
@Schema(description = "다음 페이지가 있는지 여부")
private boolean hasNext;
@Schema(description = "현재 페이지의 데이터 수")
private Integer numberOfElements;
@Schema(description = "요청한 데이터 수")
private Integer size;

private CursorPaginationResult(List<T> data, Integer size) {
this.data = data;
this.size = size;
if (data.size() > size) {
this.hasNext = true;
this.data.remove(data.size() - 1);
} else {
this.hasNext = false;
}
this.numberOfElements = data.size();
}

private CursorPaginationResult(List<T> data, Integer size, boolean hasNext) {
this.data = data;
this.numberOfElements = data.size();
this.hasNext = hasNext;
this.size = size;
}

public static <T> CursorPaginationResult<T> fromDataWithExtraItemForNextCheck(
List<T> data, Integer size
) {
return new CursorPaginationResult<>(data, size);
}

public static <T> CursorPaginationResult<T> fromDataWithHasNext(
List<T> data, Integer size, boolean hasNext
) {
return new CursorPaginationResult<>(data, size, hasNext);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.oeid.mogakgo.common.swagger.template;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerAuthErrorExamples;
import io.oeid.mogakgo.domain.auth.presentation.dto.res.AuthAccessTokenResponse;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
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 org.springframework.http.ResponseEntity;

@Tag(name = "Auth", description = "인증 관련 API")
@SuppressWarnings("unused")
public interface AuthSwagger {

@Operation(summary = "토큰 재발급", description = "Access Token을 재발급 받을 때 사용하는 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "토큰 재발급 성공",
content = @Content(schema = @Schema(implementation = AuthAccessTokenResponse.class))),
@ApiResponse(responseCode = "401", description = "재발급 토큰 인증정보가 유효하지 않음",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E010201", value = SwaggerAuthErrorExamples.AUTH_MISSING_CREDENTIALS)))
})
ResponseEntity<AuthAccessTokenResponse> reissue(
@Parameter(in = ParameterIn.HEADER, hidden = true) String accessToken,
@Parameter(in = ParameterIn.COOKIE) String refreshToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.oeid.mogakgo.common.swagger.template;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerCertErrorExamples;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerGeoErrorExamples;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples;
import io.oeid.mogakgo.domain.cert.presentation.dto.req.UserRegionCertAPIReq;
import io.oeid.mogakgo.domain.cert.presentation.dto.res.UserRegionCertAPIRes;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
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 org.springframework.http.ResponseEntity;

@Tag(name = "Cert", description = "동네 인증 관련 API")
@SuppressWarnings("unused")
public interface CertSwagger {

@Operation(summary = "동네 인증 완료 응답", description = "동네 인증 완료를 요청할 때 사용하는 API"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "동네 인증 요청 성공",
content = @Content(schema = @Schema(implementation = UserRegionCertAPIRes.class))),
@ApiResponse(responseCode = "400", description = "요청한 데이터가 유효하지 않음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E080101", value = SwaggerGeoErrorExamples.INVALID_SERVICE_REGION))),
@ApiResponse(responseCode = "403", description = "동네 인증 권한이 없음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E070201", value = SwaggerCertErrorExamples.INVALID_CERT_INFO))),
@ApiResponse(responseCode = "404", description = "요청한 유저가 존재하지 않음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND))),
})
ResponseEntity<UserRegionCertAPIRes> certificateNeighborhood(
@Parameter(hidden = true) Long userId,
UserRegionCertAPIReq request
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package io.oeid.mogakgo.common.swagger.template;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerGeoErrorExamples;
import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples;
import io.oeid.mogakgo.domain.geo.presentation.dto.res.UserRegionInfoAPIRes;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
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 org.springframework.http.ResponseEntity;

@Tag(name = "Geo", description = "지역 관련 API")
@SuppressWarnings("unused")
public interface GeoSwagger {

@Operation(summary = "GPS에 대한 법정구역코드 응답", description = "사용자의 GPS 좌표의 법정구역코드를 요청할 때 사용하는 API"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "법정구역코드 요청 성공",
content = @Content(schema = @Schema(implementation = UserRegionInfoAPIRes.class))),
@ApiResponse(responseCode = "400", description = "요청한 데이터가 유효하지 않음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E080101", value = SwaggerGeoErrorExamples.INVALID_SERVICE_REGION))),
@ApiResponse(responseCode = "404", description = "요청한 유저가 존재하지 않음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND))),
})
ResponseEntity<UserRegionInfoAPIRes> getUserRegionInfoByGPS(
@Parameter(hidden = true) Long userId,
@Parameter(description = "사용자의 GPS 경도", required = true) Double longitude,
@Parameter(description = "사용자의 GPS 위도", required = true) Double latitude
);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.oeid.mogakgo.common.swagger.template;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.core.properties.swagger.error.SwaggerUserErrorExamples;
import io.oeid.mogakgo.domain.notification.presentation.dto.req.FCMTokenApiRequest;
import io.oeid.mogakgo.exception.dto.ErrorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;

@Tag(name = "Notification", description = "알림 관련 API")
@SuppressWarnings("unused")
public interface NotificationSwagger {

@Operation(summary = "FCM 토큰 저장", description = "회원의 FCM 토큰을 저장할 때 사용하는 API")
@ApiResponse(responseCode = "200", description = "FCM 토큰 저장 성공")
@ApiResponse(responseCode = "404", description = "요청한 유저가 존재하지 않음", content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(name = "E020301", value = SwaggerUserErrorExamples.USER_NOT_FOUND)
})
)
ResponseEntity<Void> manageFCMToken(@Parameter(hidden = true) Long userId,
FCMTokenApiRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.oeid.mogakgo.common.swagger.template;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import io.oeid.mogakgo.domain.auth.presentation.dto.res.AuthAccessTokenResponse;
import io.oeid.mogakgo.domain.auth.presentation.dto.res.AuthLoginUrlResponse;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.Operation;
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.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.core.user.OAuth2User;

@Tag(name = "OAuth2", description = "OAuth2 관련 API")
@SuppressWarnings("unused")
public interface OAuth2Swagger {
@Operation(summary = "로그인 URL 반환", description = "로그인 URL을 반환하는 API")
@ApiResponse(responseCode = "200", description = "로그인 URL 반환 성공",
content = @Content(
mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = AuthLoginUrlResponse.class)))
ResponseEntity<AuthLoginUrlResponse> login();
@Hidden
ResponseEntity<AuthAccessTokenResponse> loginSuccess(
OAuth2User oAuth2User, HttpServletResponse response);
}
Loading

0 comments on commit f19bb3a

Please sign in to comment.