Skip to content

Commit 165f54e

Browse files
authored
Merge pull request #90 from chhs2131/develop
master v0.5.4
2 parents a62ffa9 + d27d1c8 commit 165f54e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+828
-778
lines changed

.github/workflows/codeball.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Codeball
2+
on:
3+
pull_request: {}
4+
pull_request_review_comment:
5+
types: [created, edited]
6+
7+
jobs:
8+
codeball_job:
9+
runs-on: ubuntu-latest
10+
name: Codeball
11+
steps:
12+
- name: Codeball
13+
uses: sturdy-dev/codeball-action@v2
14+
with:
15+
# For all configuration options see https://github.com/sturdy-dev/codeball-action/blob/v2/action.yml
16+
approvePullRequests: "true"
17+
labelPullRequestsWhenApproved: "true"
18+
labelPullRequestsWhenReviewNeeded: "false"
19+
failJobsWhenReviewNeeded: "false"

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ plugins {
1818
}
1919

2020
group = 'com.dbsgAPI'
21-
version = '0.4.1-SNAPSHOT'
21+
version = '0.5.4-SNAPSHOT'
2222
sourceCompatibility = '1.8'
2323

2424
configurations {
@@ -34,6 +34,7 @@ repositories {
3434
dependencies {
3535
//
3636
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.2'
37+
implementation 'org.springframework.boot:spring-boot-starter-webflux'
3738

3839
//데이터베이스
3940
implementation 'org.springframework.boot:spring-boot-starter-jdbc:2.6.2'

readme.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# 공모주토피아 백엔드 서버 개발
2+
![image](https://user-images.githubusercontent.com/10378777/223959940-c82dd679-d5fe-422f-be4f-6349c60f2f5a.png)
3+
24

35
## 📙 프로젝트 개요
46
### 프로젝트 설명
7+
- 주식 시장 신규상장(IPO) 정보를 알려주는 서비스
8+
- 공모주 관련 플랫폼을 구축하는 것이 목표인 백엔드 프로젝트
9+
- 크롤링된 공모주 정보를 Client에게 Restful API로 전달 및 관리
10+
- 전자공시시스템(DART) 데이터를 직접 크롤링/가공 하여 사용
11+
- SpringBoot, MySQL, Mybatis, OAuth2.0(카카오), REST 규격을 이용한 백엔드 담당
12+
- 안드로이드로 서비스 중 : [PlayStore](https://play.google.com/store/apps/details?id=com.psw9999.gongmozootopia.prod.release)
13+
14+
**배경**
515
- 공모주(IPO) 관련 법이 개정되면서 일반 개인들에게도 매력적인 투자수단이 되었습니다.
616
- 하지만 이를 안내해주는 마땅한 서비스가 없어 해당 서비스를 개발하게되었습니다.
7-
- 크롤링된 공모주 정보를 Client에게 Restful API로 전달 및 관리
8-
- 공모주 관련 플랫폼을 구축하는 것이 목표인 백엔드 프로젝트
917

1018
<br/>
1119

@@ -15,10 +23,11 @@
1523

1624
- 담당 인원 : 1인
1725
- Spring API
18-
- Spring: `SpringBoot2.6.4`, `Gradle`, `IntelliJ`, `Java8`, `lombok`
26+
- Spring: `SpringBoot2.6.4`, `Gradle`, `Java8`, `lombok`
27+
- Security: `security`, `jjwt`
1928
- DB: `Mybatis`, `Hikari`
20-
- API Document: `Swagger 2.9.2`
21-
- etc: `AOP (Transaction, LoggerAspect)`, `WebClient (HttpConnection)`
29+
- API Document: `springdoc-openapi-ui(Swagger)`
30+
- etc: `AOP (Transaction, LoggerAspect)`, `WebClient(webFlux)`
2231
- Database: `MariaDB`
2332
- ServerComputer: `Google Compute Engine`, `CentOS Linux release 8.4.2105`
2433
- dev Tool: `HeidiSQL DataGrip`, `putty winscp`, `Postman Swagger-UI`
@@ -27,7 +36,8 @@
2736
**공모주 데이터 크롤링**
2837

2938
- 담당 인원 : 3인
30-
- 크롤러: `Python3.9`, `BS4`, `PyMysql`
39+
- 크롤러: `Python3.7`, `BS4`, `PyMysql`
40+
- `Linux`, `Debian`, `crontab`
3141

3242
<br/>
3343

@@ -46,9 +56,10 @@
4656
- Underwriter: 청약을 진행하는 주간사 정보와 최대 청약 개수를 확인할 수 있습니다.
4757
- Schedule: 지정된 기간에 청약 일정이 있었는지 확인할 수 있습니다. (예. 오늘, 이번주, 지난달 등)
4858
- Comment: 각 종목에 정보가 변화된 기록을 확인할 수 있습니다.
59+
- AUTH: 카카오 OAuth2.0로 로그인 및 신규가입합니다.
60+
- 추후 개인별 즐겨찾기, 보유 증권사 목록 등의 정보를 서버에서 관리하여 플랫폼간 연결성을 높일 예정입니다.
4961
- SwaggerLink : http://server.dbsg.co.kr:8080/swagger-ui/index.html
50-
![image](https://user-images.githubusercontent.com/10378777/199421203-2ff4fbfa-ab3e-41ad-af3f-ce7c2ab07b83.png)
51-
62+
![image](https://user-images.githubusercontent.com/10378777/223958261-832ce4fd-a0cb-4c4d-a88b-d1d50e4f14c7.png)
5263

5364
<br/>
5465

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.dbsgapi.dbsgapi.api.auth.controller;
2+
3+
import com.dbsgapi.dbsgapi.api.auth.exception.KakaoApiException;
4+
import com.dbsgapi.dbsgapi.api.auth.service.KakaoOauthService;
5+
import com.dbsgapi.dbsgapi.global.authentication.AuthResponse;
6+
import com.dbsgapi.dbsgapi.global.response.CustomException;
7+
import io.swagger.v3.oas.annotations.Hidden;
8+
import io.swagger.v3.oas.annotations.tags.Tag;
9+
import lombok.RequiredArgsConstructor;
10+
import org.springframework.http.HttpStatus;
11+
import org.springframework.http.ResponseEntity;
12+
import org.springframework.web.bind.annotation.PostMapping;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RequestParam;
15+
import org.springframework.web.bind.annotation.RestController;
16+
17+
@RestController
18+
@RequiredArgsConstructor
19+
@RequestMapping("/api/v1/auth")
20+
@Tag(name = "Auth", description = "로그인 및 계정 관리를 위한 API")
21+
public class AuthController {
22+
private final KakaoOauthService kakaoOauthService;
23+
24+
@PostMapping("/oauth/kakao")
25+
public ResponseEntity<AuthResponse> oauthLoginKakao(@RequestParam String kakaoAccessToken) {
26+
try {
27+
AuthResponse result = kakaoOauthService.login(kakaoAccessToken);
28+
System.out.println(result.toString());
29+
return new ResponseEntity<>(result, HttpStatus.OK);
30+
} catch (KakaoApiException e) {
31+
throw new CustomException(e.getKakaoApiErrorCode());
32+
}
33+
}
34+
35+
@Hidden
36+
@PostMapping("/oauth/google")
37+
public String oauthLoginGoogle() {
38+
return null;
39+
}
40+
41+
@Hidden
42+
@PostMapping("/login")
43+
public String loginDbsg() {
44+
return null;
45+
}
46+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.dbsgapi.dbsgapi.api.auth.dto;
2+
3+
import lombok.Data;
4+
import lombok.NoArgsConstructor;
5+
import lombok.ToString;
6+
7+
@ToString
8+
@Data
9+
@NoArgsConstructor
10+
public class KakaoErrorDto {
11+
private int code;
12+
private String msg;
13+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.dbsgapi.dbsgapi.api.auth.dto;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.NoArgsConstructor;
6+
import lombok.ToString;
7+
8+
@ToString
9+
@Data
10+
@NoArgsConstructor
11+
public class KakaoProfileDto {
12+
@JsonProperty("id")
13+
private Long id;
14+
@JsonProperty("connected_at")
15+
private String connectedAt;
16+
17+
// @JsonProperty("kakao_account")
18+
// private KakaoAccount kakaoAccount;
19+
// @JsonProperty("properties")
20+
// private Properties properties;
21+
22+
@Data
23+
@NoArgsConstructor
24+
public static class KakaoAccount {
25+
@JsonProperty("profile")
26+
private Profile profile;
27+
@JsonProperty("profile_image_needs_agreement")
28+
private boolean profileImageNeedsAgreement;
29+
@JsonProperty("profile_nickname_needs_agreement")
30+
private boolean profileNicknameNeedsAgreement;
31+
}
32+
33+
@Data
34+
@NoArgsConstructor
35+
public static class Profile {
36+
@JsonProperty("is_default_image")
37+
private boolean isDefaultImage;
38+
@JsonProperty("profile_image_url")
39+
private String profileImageUrl;
40+
@JsonProperty("thumbnail_image_url")
41+
private String thumbnailImageUrl;
42+
@JsonProperty("nickname")
43+
private String nickname;
44+
}
45+
46+
@Data
47+
@NoArgsConstructor
48+
public static class Properties {
49+
@JsonProperty("thumbnail_image")
50+
private String thumbnailImage;
51+
@JsonProperty("profile_image")
52+
private String profileImage;
53+
@JsonProperty("nickname")
54+
private String nickname;
55+
}
56+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.dbsgapi.dbsgapi.api.auth.dto;
2+
3+
import lombok.Data;
4+
import lombok.NoArgsConstructor;
5+
6+
@Data
7+
@NoArgsConstructor
8+
public class KakaoTokenInfoDto {
9+
private long expiresInMillis;
10+
private long id;
11+
private long appId;
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.dbsgapi.dbsgapi.api.auth.dto;
2+
3+
import com.dbsgapi.dbsgapi.global.authentication.OauthType;
4+
import lombok.*;
5+
6+
import java.time.LocalDateTime;
7+
8+
@Data
9+
@Builder
10+
@ToString
11+
@AllArgsConstructor
12+
@NoArgsConstructor
13+
public class MemberOauthAccountDto {
14+
private String oauthId;
15+
private OauthType oauthType;
16+
private String memberUuid;
17+
private LocalDateTime registDatetime;
18+
19+
public void setOauthType(String oauthType) {
20+
this.oauthType = OauthType.valueOf(oauthType);
21+
}
22+
23+
public int getOauthType() {
24+
return oauthType.getId();
25+
}
26+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.dbsgapi.dbsgapi.api.auth.exception;
2+
3+
import com.dbsgapi.dbsgapi.api.auth.dto.KakaoErrorDto;
4+
import com.dbsgapi.dbsgapi.global.response.ErrorCode;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
import lombok.ToString;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.http.HttpStatus;
10+
11+
import java.util.Arrays;
12+
13+
import static org.springframework.http.HttpStatus.*;
14+
15+
@Getter
16+
@ToString
17+
@AllArgsConstructor
18+
public enum KakaoApiErrorCode implements ErrorCode {
19+
// General
20+
INTERNAL_ERROR(BAD_REQUEST, "-1","재시도하세요."),
21+
PARAMETER_ERROR(BAD_REQUEST, "-2", "요청 파라미터를 확인하세요."),
22+
OPTION_UNABLE_ERROR(FORBIDDEN, "-3", "카카오 설정 - 내 애플리케이션 - 필요한기능 활성화가 필요합니다."),
23+
BLOCK_USER_ERROR(FORBIDDEN, "-4", "제재된 계정일 수 있습니다."),
24+
HAVE_NOT_PERMISSION_ERROR(FORBIDDEN, "-5", "해당 API의 이해하기 문서를 참고하여 검수 진행, 권한 획득 후 재호출하세요."),
25+
SERVICE_CHECK_ERROR(BAD_REQUEST, "-7", "서비스 점검 또는 내부 문제가 있으니 공지사항을 확인하세요."),
26+
ILLEGAL_HEADER_ERROR(BAD_REQUEST, "-8", "올바르지 않은 헤더입니다."),
27+
SERVICE_NOT_FOUND_ERROR(BAD_REQUEST, "-9", "서비스 종료된 API 입니다."),
28+
API_CALL_LIMIT_ERROR(BAD_REQUEST, "-10", "API 요청 가능 횟수를 초과하였습니다."),
29+
SERVICE_KEY_ERROR(UNAUTHORIZED, "-401", "앱키 확인 또는 토큰 갱신, 개발자 사이트에 등록된 앱 정보를 확인해주세요."),
30+
KAKAO_USER_ERROR(BAD_REQUEST, "-501", "카카오톡 미가입 또는 유예 사용자입니다."),
31+
IMAGE_SIZE_ERROR(BAD_REQUEST, "-602", "이미지 파일 크기가 업로드 가능한 최대 용량을 초과하였습니다."),
32+
TIMEOUT_ERROR(BAD_REQUEST, "-603", "요청 처리 중 타임아웃이 발생하였스빈다."),
33+
TOO_MANY_IMAGE_ERROR(BAD_REQUEST, "-606", "업로드 할 수 있는 최대 이미지 개수를 초과하였습니다."),
34+
UNREGISTERED_KEY_ERROR(BAD_REQUEST, "-903", "등록되지않은 앱키 또는 엑세스 토큰입니다."),
35+
IMAGE_FORMAT_ERROR(BAD_REQUEST, "-911", "지원하지 않는 이미지 파일 형식입니다."),
36+
SYSTEM_CHECK_ERROR(SERVICE_UNAVAILABLE, "-9798", "서비스 점검중"),
37+
38+
// Login
39+
LOGIN_UNREGISTERED_ERROR(BAD_REQUEST, "-101", "카카오계쩡 연결 후 재시도하세요."),
40+
LOGIN_ALREADY_LINKED_ERROR(BAD_REQUEST, "-102", "이미 앱과 연결되어있는 사용자의 토큰입니다."),
41+
LOGIN_DORMANT_USER_ERROR(BAD_REQUEST, "-103", "휴면 상태 또는 존재하지 않는 카카오 계정입니다."),
42+
LOGIN_WRONG_PROPERTY_ERROR(BAD_REQUEST, "-201", "요청할 수 없는 값입니다. (내 애플리케이션 - 카카오 로그인 - 사용자 프로퍼티 확인)"),
43+
LOGIN_NOT_AGREE_ERROR(FORBIDDEN, "-402", "사용자의 동의가 필요한 리소스입니다. (required_scopes 확인)"),
44+
LOGIN_NO_CHILD_ERROR(UNAUTHORIZED, "-401", "14세 미만 사용자는 호츨 할 수 없게 설정되어있습니다.")
45+
;
46+
47+
private final HttpStatus status;
48+
private final String code;
49+
private final String message;
50+
51+
public static KakaoApiErrorCode from(KakaoErrorDto kakaoErrorDto) {
52+
String code = String.valueOf(kakaoErrorDto.getCode());
53+
return from(code);
54+
}
55+
56+
public static KakaoApiErrorCode from(String code) {
57+
return Arrays.stream(KakaoApiErrorCode.values())
58+
.filter(kakaoApiErrorCode -> kakaoApiErrorCode.getCode().equals(code))
59+
.findAny()
60+
.orElseThrow(() -> new IllegalStateException("지원x"));
61+
}
62+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.dbsgapi.dbsgapi.api.auth.exception;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Getter;
5+
6+
@Getter
7+
@AllArgsConstructor
8+
public class KakaoApiException extends RuntimeException {
9+
private final KakaoApiErrorCode kakaoApiErrorCode;
10+
}

0 commit comments

Comments
 (0)