Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
jjddhh authored May 12, 2023
2 parents c59bcbd + def8346 commit c0772e8
Show file tree
Hide file tree
Showing 21 changed files with 152 additions and 96 deletions.
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,3 @@
- refact: 코드 리팩토링에 대한 커밋
- test : 테스트 코드 수정에 대한 커밋

## 서버 메트릭 모니터링 방법
![image (8)](https://user-images.githubusercontent.com/80163835/203802990-b9d896fb-f28d-47c1-8338-2bdcf36dcd23.png)
Prometheus를 사용하여 각종 모니터링 지표를 수집. 수집된 데이터들을 Grafana로 시각화하여 모니터링을 진행합니다.

## 개발부터 배포까지의 워크플로우
![workflow_e](https://user-images.githubusercontent.com/80163835/203800201-1a42ce89-666d-49ab-b6ec-dfde3f26f6aa.png)
<br>✓ 브랜치 머지부터 배포까지 걸리는 시간은 대략 **1분 30초**

## 데이터 로깅과 시각화 방법 - 지표 추적 방법
![merge_1-01](https://user-images.githubusercontent.com/80163835/203802625-c7b74f5e-6143-4270-82cd-c7f3c2159a0c.png)
| 진행 | 미래(추후 적용) |
|:----------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| : Spring AOP 이용<br>(데이터 로그를 출력 및 DB에 저장) | : Google Analytics 이용<br>(데이터 로깅에 따른 시각화 및 분석을 더욱 용이하게 할 수 있도록 할 예정) |
|저장된 데이터를 토대로 앞서 기재한 서비스 핵심 지표를 분석하는 방법 | - 구글에서 제공하는 웹 분석 서비스, API 와 프로젝트를 연결하여 상단에 기재된 지표 추적 가능<br>- 구글 클라우드 플랫폼에서 구글 애널리틱스에 접근하기 위한 계정을 생성 후 Google Analytics Reporting API 라이브러리를 연동<br>- 구글 태그 매니저(GTM)의 연동을 통해, 다양한 태그를 관리하여 이벤트 트래킹을 진행. GTM 은 개발자가 정의하지 않아도 기획자 마케터가 직접 정의하여 데이터 획득 |
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ public CommonResponse<?> naverAuth(@RequestBody ReqAuthDto reqAuthDto, HttpServl
*/
LoginInfo loginInfo = authService.commonAuth(reqAuthDto.getAccessToken(), request.getRequestURI());

if(loginInfo.getOnBoarding())
return new CommonResponse<>(ErrorCode.SUCCESS_BUT, loginInfo);
else
return new CommonResponse<>(loginInfo);
return new CommonResponse<>(loginInfo);
}

/**
Expand All @@ -94,10 +91,7 @@ public CommonResponse<?> kakaoAuth(@RequestBody ReqAuthDto reqAuthDto, HttpServl
*/
LoginInfo loginInfo = authService.commonAuth(reqAuthDto.getAccessToken(), request.getRequestURI());

if(loginInfo.getOnBoarding())
return new CommonResponse<>(ErrorCode.SUCCESS_BUT, loginInfo);
else
return new CommonResponse<>(loginInfo);
return new CommonResponse<>(loginInfo);
}

/**
Expand All @@ -112,10 +106,7 @@ public CommonResponse<?> googleAuth(@RequestBody ReqAuthDto reqAuthDto, HttpServ
*/
LoginInfo loginInfo = authService.commonAuth(reqAuthDto.getAccessToken(), request.getRequestURI());

if(loginInfo.getOnBoarding())
return new CommonResponse<>(ErrorCode.SUCCESS_BUT, loginInfo);
else
return new CommonResponse<>(loginInfo);
return new CommonResponse<>(loginInfo);
}

@PostMapping(value = "/auth/apple")
Expand All @@ -127,10 +118,7 @@ public CommonResponse<?> appleAuth(@RequestBody ReqAppleAuthDto reqAppleAuthDto,
*/
LoginInfo loginInfo = authService.appleAuth(reqAppleAuthDto.getIdentityToken(), request.getRequestURI());

if(loginInfo.getOnBoarding())
return new CommonResponse<>(ErrorCode.SUCCESS_BUT, loginInfo);
else
return new CommonResponse<>(loginInfo);
return new CommonResponse<>(loginInfo);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ public class LoginInfo {
@JsonInclude(JsonInclude.Include.NON_NULL)
private String refreshToken;

@JsonIgnore
private Boolean onBoarding;
private Boolean onBoardingCompleted;

public LoginInfo(String nickname, Token token) {
this.nickname = nickname;
this.token = token.getToken();
this.refreshToken = token.getRefreshToken();
}

public LoginInfo(String nickname, Token token, Boolean onBoarding) {
public LoginInfo(String nickname, Token token, Boolean onBoardingCompleted) {
this.nickname = nickname;
this.token = token.getToken();
this.refreshToken = token.getRefreshToken();
this.onBoarding = onBoarding;
this.onBoardingCompleted = onBoardingCompleted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public LoginInfo commonAuth(String accessToken, String providerInfo) {
// Redis에 Refresh Token 저장
tokenUtil.storeRefreshToken(authenticatedMember.getSocialId(), token);

return new LoginInfo(authenticatedMember.getNickname(), token, authenticatedMember.getRole().equals(Member.Role.ONBOARDER));
return new LoginInfo(authenticatedMember.getNickname(), token, authenticatedMember.getRole().equals(Member.Role.USER));
}

@Counted("auth.api.count")
Expand All @@ -122,7 +122,7 @@ public LoginInfo appleAuth(String identityToken, String providerInfo) {
// Redis에 Refresh Token 저장
tokenUtil.storeRefreshToken(authenticatedMember.getSocialId(), token);

return new LoginInfo(authenticatedMember.getNickname(), token, authenticatedMember.getRole().equals(Member.Role.ONBOARDER));
return new LoginInfo(authenticatedMember.getNickname(), token, authenticatedMember.getRole().equals(Member.Role.USER));
}

@Counted("auth.api.count")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Data
public class KeywordDto {
@NotNull(message = "keyword 는 비어있을 수 없습니다.")
@Size(min = 1, max = 5, message = "keyword 는 최소 1개, 최대 5개의 문자만 입력 가능합니다.")
@Size(min = 1, max = 7, message = "keyword 는 최소 1개, 최대 7개의 문자만 입력 가능합니다.")
private String keyword;

@Valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ReqDiaryDto {
private LocalDateTime date;

@NotBlank(message = "content 는 비어있을 수 없습니다.")
@Size(min = 1, max = 300, message="content 는 최대 300개의 문자만 입력 가능합니다.")
@Size(min = 1, max = 600, message="content 는 최대 600개의 문자만 입력 가능합니다.")
private String content;

@Valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Diary extends BaseTime {
@Column(name = "diary_id")
private Long diaryId;

@Column(length = 500, nullable = false)
@Column(length = 600, nullable = false)
private String content;

private LocalDateTime writeDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Keyword extends BaseTime {
@Column(name = "keyword_id")
private Long keywordId;

@Column(nullable = false, length = 5)
@Column(nullable = false, length = 7)
private String word;

@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RetrospectKeywordDto {
String classify;

@NotBlank(message = "keyword 는 비어있을 수 없습니다.")
@Size(min = 1, max = 5, message="keyword 는 최소 1개, 최대 5개의 문자만 입력 가능합니다.")
@Size(min = 1, max = 7, message="keyword 는 최소 1개, 최대 7개의 문자만 입력 가능합니다.")
String keyword;

public RetrospectKeywordDto(RetrospectKeyword retrospectKeyword) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ private List<RespGetClassifiedKeywordDto> getKeyword(Member member, LocalDateTim
}
private List<CountEmotion> getEmotionCount(List<Diary> diaries) {
List<Emotion> findEmotions = emotionRepository.findAll();
int totalCount = diaries.stream()
.flatMap(d -> d.getKeywords().stream())
.map(k -> k.getKeywordEmotions().size())
.reduce(0, Integer::sum);

return findEmotions.stream().map(e -> {
int count = diaries.stream()
Expand All @@ -331,13 +335,17 @@ private List<CountEmotion> getEmotionCount(List<Diary> diaries) {
.collect(Collectors.toList())
.size();

double ratio = totalCount == 0 ? 0 : ((double) count) / totalCount;
System.out.println(ratio);

int frequency = 0;
if (count >= 1 && count <= 5)
if (ratio <= 0.3 && ratio > 0) {
frequency = 1;
else if (count >= 6 && count <= 10)
} else if (ratio <= 0.7 && ratio > 0.3) {
frequency = 2;
else if (count > 10)
} else if (ratio > 0.7){
frequency = 3;
}

return CountEmotion.makeCountEmotion(e.getEmotion(), frequency);
}).collect(Collectors.toList());
Expand All @@ -364,4 +372,4 @@ private void delete(Member member, Retrospect retrospect) {
retrospectRepository.delete(retrospect);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
public class Token {
private String token;

@JsonInclude(JsonInclude.Include.NON_NULL)
private String refreshToken;

@JsonInclude(JsonInclude.Include.NON_NULL)
private Boolean onBoardingCompleted;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public Token generateToken(Member member) {
.setIssuedAt(now)
.setExpiration(new Date(now.getTime() + refreshPeriod))
.signWith(SignatureAlgorithm.HS256, secretKey)
.compact());
.compact(),
member.getRole().equals(Member.Role.USER));
}

public boolean verifyToken(String token) {
Expand Down Expand Up @@ -95,10 +96,12 @@ public Token tokenReissue(String token) {
Date expireDate = getExpiration(token);
Date currentDate = new Date();
// refreshToken 기간이 얼마남지 않았을 경우 (3일 미만)
log.info("remain time = {} < {}", expireDate.getTime() - currentDate.getTime(), reissuePeriod);
if (expireDate.getTime() - currentDate.getTime() < reissuePeriod) storeRefreshToken(socialId, newToken);
// refreshToken 의 유효기간이 3일 이상 남았을 경우 (refreshToken NULL 값으로 설정함으로써 전송하지 않음)
else newToken.setRefreshToken(null);
if (expireDate.getTime() - currentDate.getTime() < reissuePeriod) {
log.info("Refresh token reissue");
storeRefreshToken(socialId, newToken);
}
// refreshToken 의 유효기간이 3일 이상 남았을 경우 (refreshToken 그대로 넣어서 응답)
else newToken.setRefreshToken(token);

return newToken;
}
Expand Down
52 changes: 41 additions & 11 deletions src/main/resources/static/docs/Auth-API.html
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ <h4 id="Auth-Naver-소셜-로그인_http_response">HTTP response</h4>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 237
Content-Length: 272

{
"isSuccess" : true,
Expand All @@ -499,7 +499,8 @@ <h4 id="Auth-Naver-소셜-로그인_http_response">HTTP response</h4>
"result" : {
"nickname" : "유저 닉네임",
"token" : "SERVER_ACCESS_TOKEN",
"refreshToken" : "SERVER_REFRESH_TOKEN"
"refreshToken" : "SERVER_REFRESH_TOKEN",
"onBoardingCompleted" : true
}
}</code></pre>
</div>
Expand Down Expand Up @@ -551,6 +552,11 @@ <h4 id="Auth-Naver-소셜-로그인_response_fields">Response fields</h4>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">서버 접근용 Refresh Token</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>result.onBoardingCompleted</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">온보딩 여부 확인</p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -603,7 +609,7 @@ <h4 id="Auth-Kakao-소셜-로그인_http_response">HTTP response</h4>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 237
Content-Length: 272

{
"isSuccess" : true,
Expand All @@ -612,7 +618,8 @@ <h4 id="Auth-Kakao-소셜-로그인_http_response">HTTP response</h4>
"result" : {
"nickname" : "유저 닉네임",
"token" : "SERVER_ACCESS_TOKEN",
"refreshToken" : "SERVER_REFRESH_TOKEN"
"refreshToken" : "SERVER_REFRESH_TOKEN",
"onBoardingCompleted" : true
}
}</code></pre>
</div>
Expand Down Expand Up @@ -664,6 +671,11 @@ <h4 id="Auth-Kakao-소셜-로그인_response_fields">Response fields</h4>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">서버 접근용 Refresh Token</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>result.onBoardingCompleted</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">온보딩 여부 확인</p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -716,7 +728,7 @@ <h4 id="Auth-Google-소셜-로그인_http_response">HTTP response</h4>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 237
Content-Length: 272

{
"isSuccess" : true,
Expand All @@ -725,7 +737,8 @@ <h4 id="Auth-Google-소셜-로그인_http_response">HTTP response</h4>
"result" : {
"nickname" : "유저 닉네임",
"token" : "SERVER_ACCESS_TOKEN",
"refreshToken" : "SERVER_REFRESH_TOKEN"
"refreshToken" : "SERVER_REFRESH_TOKEN",
"onBoardingCompleted" : true
}
}</code></pre>
</div>
Expand Down Expand Up @@ -777,6 +790,11 @@ <h4 id="Auth-Google-소셜-로그인_response_fields">Response fields</h4>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">서버 접근용 Refresh Token</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>result.onBoardingCompleted</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">온보딩 여부 확인</p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -829,7 +847,7 @@ <h4 id="Auth-Apple-소셜-로그인_http_response">HTTP response</h4>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 237
Content-Length: 272

{
"isSuccess" : true,
Expand All @@ -838,7 +856,8 @@ <h4 id="Auth-Apple-소셜-로그인_http_response">HTTP response</h4>
"result" : {
"nickname" : "유저 닉네임",
"token" : "SERVER_ACCESS_TOKEN",
"refreshToken" : "SERVER_REFRESH_TOKEN"
"refreshToken" : "SERVER_REFRESH_TOKEN",
"onBoardingCompleted" : true
}
}</code></pre>
</div>
Expand Down Expand Up @@ -890,6 +909,11 @@ <h4 id="Auth-Apple-소셜-로그인_response_fields">Response fields</h4>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">서버 접근용 Refresh Token</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>result.onBoardingCompleted</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">온보딩 여부 확인</p></td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -934,15 +958,16 @@ <h4 id="Auth-토큰-재발급_http_response">HTTP response</h4>
<div class="content">
<pre class="highlight nowrap"><code class="language-http" data-lang="http">HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 199
Content-Length: 234

{
"isSuccess" : true,
"code" : 200,
"message" : "요청에 성공하였습니다.",
"result" : {
"token" : "SERVER_ACCESS_TOKEN",
"refreshToken" : "SERVER_REFRESH_TOKEN"
"refreshToken" : "SERVER_REFRESH_TOKEN",
"onBoardingCompleted" : true
}
}</code></pre>
</div>
Expand Down Expand Up @@ -989,6 +1014,11 @@ <h4 id="Auth-토큰-재발급_response_fields">Response fields</h4>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>String</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">서버 접근용 Refresh Token</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>result.onBoardingCompleted</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Boolean</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">온보딩 여부 확인</p></td>
</tr>
</tbody>
</table>
</div>
Expand All @@ -999,7 +1029,7 @@ <h4 id="Auth-토큰-재발급_response_fields">Response fields</h4>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-04-18 10:42:19 +0900
Last updated 2023-05-09 15:03:35 +0900
</div>
</div>
</body>
Expand Down
Loading

0 comments on commit c0772e8

Please sign in to comment.