Skip to content

Commit

Permalink
Merging branch 'develop' into 'refact/#334-refact_event_architecture'
Browse files Browse the repository at this point in the history
  • Loading branch information
JIN-076 committed May 9, 2024
2 parents 18b50c3 + db71f1e commit 667303d
Show file tree
Hide file tree
Showing 53 changed files with 1,326 additions and 455 deletions.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<h3 align="center">
<a href="https://github.com/Open-Eye-Im-Developer">
<img src="https://github.com/Open-Eye-Im-Developer/MoGakGo-BE/assets/85854384/686e8843-1c54-4a50-906c-e720785d0367"/>
</a>
</h3>

## 📢 프로젝트 소개
<div align="center">
<img width="1600" alt="image" src="https://github.com/Open-Eye-Im-Developer/MoGakGo-BE/assets/85854384/87f2a91b-7ec7-44fe-ae03-69b74bee9dac">
</div>


## ⚙️ 아키텍처

<h3 align="center">
<img width="1600" alt="image" src="https://github.com/Open-Eye-Im-Developer/MoGakGo-BE/assets/85854384/cfdbc5f7-f0a8-453f-bcc2-f6ca94379c85">
</h3>

## 📁 DB ERD

<h3 align="center">
<img width="1600" alt="image" src="https://github.com/Open-Eye-Im-Developer/MoGakGo-BE/assets/85854384/f7815c1e-7cf9-46ac-a10f-35f9b6a06a48">
</h3>

## 📚 기술 스택

- <b>Core</b>

<img src="https://img.shields.io/badge/java 17-FF4800?style=for-the-badge&logo=openjdk&logoColor=white">
<img src="https://img.shields.io/badge/Spring Boot 3.2-6DB33F?style=for-the-badge&logo=spring&logoColor=white">
<img src="https://img.shields.io/badge/Spring Security 6.2-6DB33F?style=for-the-badge&logo=Spring Security&logoColor=white">
<img src="https://img.shields.io/badge/JWT 4.4-000000?style=for-the-badge&logo=JSON Web Tokens&logoColor=white">
<img src="https://img.shields.io/badge/QueryDsl 5.1-4169E1?style=for-the-badge&logo=QueryDsl&logoColor=white">
<img src="https://img.shields.io/badge/JPA-6DB33F?style=for-the-badge&logo=Spring JPA&logoColor=white">
<img src="https://img.shields.io/badge/mysql 8.0-4479A1?style=for-the-badge&logo=mysql&logoColor=white">
<img src="https://img.shields.io/badge/redis-DC382D?style=for-the-badge&logo=redis&logoColor=white">
<img src="https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white">
<img src="https://img.shields.io/badge/Flyway-CC0200?style=for-the-badge&logo=Flyway&logoColor=white">

- <b>DevOps</b>
<img src="https://img.shields.io/badge/docker-2496ED?style=for-the-badge&logo=docker&logoColor=white">
<img src="https://img.shields.io/badge/NGINX-009639?style=for-the-badge&logo=NGINX&logoColor=white">

- <b>Infrastructure</b>
<img src="https://img.shields.io/badge/Amazon AWS-232F3E?style=for-the-badge&logo=Amazon AWS&logoColor=white">
<img src="https://img.shields.io/badge/Amazon RDS-527FFF?style=for-the-badge&logo=Amazon RDS&logoColor=white">
<img src="https://img.shields.io/badge/Firebase-039BE5?style=for-the-badge&logo=Firebase&logoColor=white">
<img src="https://img.shields.io/badge/Mongo Atlas-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white">

- <b>CI / CD</b>
<img src="https://img.shields.io/badge/GitHub Actions-2088FF?style=for-the-badge&logo=GitHub Actions&logoColor=white">

- <b> API </b>
<img src="https://img.shields.io/badge/GitHub API-181717?style=for-the-badge&logo=GitHub&logoColor=white">
<img src="https://img.shields.io/badge/Kakao Developers-FFCD00?style=for-the-badge&logo=Kakao&logoColor=white">


<br>


## 🔍︎ 기술적 고민

- [GitHub OAuth2 + JWT 활용 인증 구현](https://velog.io/@tidavid1/MoGakGo-GitHub-OAuth2-JWT-%ED%99%9C%EC%9A%A9-%EC%9D%B8%EC%A6%9D-%EA%B5%AC%ED%98%84%ED%95%98%EA%B8%B0)[개선](https://velog.io/@tidavid1/MoGakGo-%EC%9D%B8%EC%A6%9D-%ED%94%84%EB%A1%9C%EC%84%B8%EC%8A%A4-%EA%B0%9C%EC%84%A0%ED%95%98%EA%B8%B0)
- [GitHub API 활용 사용자 개발 언어 정보 제공 기능 구현 및 비동기 활용 개선](https://velog.io/@tidavid1/MoGakGo-GitHub-API-%ED%99%9C%EC%9A%A9-%EC%82%AC%EC%9A%A9%EC%9E%90-%EA%B0%9C%EB%B0%9C-%EC%96%B8%EC%96%B4-%EC%A0%95%EB%B3%B4-%EC%A0%9C%EA%B3%B5-%EA%B8%B0%EB%8A%A5-%EA%B5%AC%ED%98%84-%EB%B0%8F-%EA%B0%9C%EC%84%A0)
- [채팅 데이터 MongoDB 컬랙션 분리를 통한 페이지네이션 성능 개선](https://velog.io/@tidavid1/MoGakGo-%EC%B1%84%ED%8C%85-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%BB%AC%EB%9E%99%EC%85%98-%EB%B6%84%EB%A6%AC%EB%A5%BC-%ED%86%B5%ED%95%9C-%ED%8E%98%EC%9D%B4%EC%A7%80%EB%84%A4%EC%9D%B4%EC%85%98-%EC%84%B1%EB%8A%A5-%EA%B0%9C%EC%84%A0%ED%95%98%EA%B8%B0)


## 👤 멤버 소개

<div align="center">

| <center>이경민</center> | <center>김주환</center> | <center>홍지인</center> |
| :---: | :---: | :---: |
| <div align="center"><a href="https://github.com/tidavid1"><img width="100px" src="https://github.com/tidavid1.png" /></a></div> | <div align="center"><a href="https://github.com/happyjamy"><img width="100px" src="https://github.com/happyjamy.png" /></a></div> | <div align="center"><a href="https://github.com/JIN-076"><img width="100px" src="https://github.com/JIN-076.png" /></a></div> |
| 팀장 <br> 인증 / 인가 <br> 사용자 도메인 <br> 알림 <br> 채팅 | 프로젝트 도메인 <br> 매칭 도메인 <br> 업적 | 프로필 카드 도메인 <br> 프로젝트 도메인 <br> 업적 <br> 동네 인증 |

</div>

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Deprecated(forRemoval = true)
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserId {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.oeid.mogakgo.common.base;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Min;
import java.util.Objects;
import lombok.Getter;
import org.springframework.data.domain.Sort.Direction;
Expand All @@ -9,16 +9,14 @@
@Getter
public class CursorPaginationInfoReq {

@Nullable
private final Long cursorId;

@NotNull
@Min(1)
private final int pageSize;

@Nullable
private final Direction sortOrder;

public CursorPaginationInfoReq(@Nullable Long cursorId, int pageSize, Direction sortOrder) {
public CursorPaginationInfoReq(@Nullable Long cursorId, int pageSize,
@Nullable Direction sortOrder) {
this.cursorId = cursorId;
this.pageSize = pageSize;
// 최근순 기본
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

@Deprecated(forRemoval = true)
public class UserIdAnnotationResolver implements HandlerMethodArgumentResolver {

@Override
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/oeid/mogakgo/core/configuration/MongoConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.oeid.mogakgo.core.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.EnableMongoAuditing;

@Configuration
@EnableMongoAuditing
public class MongoConfig {

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import static io.oeid.mogakgo.exception.code.ErrorCode403.ACHIEVEMENT_FORBIDDEN_OPERATION;
import static io.oeid.mogakgo.exception.code.ErrorCode404.ACHIEVEMENT_NOT_FOUND;

import io.oeid.mogakgo.domain.achievement.application.dto.res.UserAchievementInfoRes;
import io.oeid.mogakgo.domain.achievement.domain.entity.Achievement;
import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType;
import io.oeid.mogakgo.domain.achievement.domain.entity.enums.RequirementType;
import io.oeid.mogakgo.domain.achievement.exception.AchievementException;
import io.oeid.mogakgo.domain.achievement.infrastructure.AchievementJpaRepository;
import io.oeid.mogakgo.domain.achievement.infrastructure.UserAchievementJpaRepository;
import io.oeid.mogakgo.domain.achievement.presentation.dto.res.UserAchievementDetailInfoRes;
import io.oeid.mogakgo.domain.user.application.UserCommonService;
import io.oeid.mogakgo.domain.user.domain.User;
import java.util.Collections;
Expand Down Expand Up @@ -37,26 +37,26 @@ public Achievement getById(Long achievementId) {
.orElseThrow(() -> new AchievementException(ACHIEVEMENT_NOT_FOUND));
}

public List<UserAchievementInfoRes> getUserAchievementInfo(Long userId, Long id) {
public List<UserAchievementDetailInfoRes> getUserAchievementInfo(Long userId, Long id) {
User user = validateToken(userId);
validateUser(user, id);

// 사용자의 미달성, Accumulate 타입 업적에 대한 상세 조회
List<UserAchievementInfoRes> result = getNonAchievedAndAccumulateAchiementInfo(userId);
List<UserAchievementDetailInfoRes> result = getNonAchievedAndAccumulateAchiementInfo(userId);

// 사용자의 Sequence 타입 업적에 대한 상세 조회
List<UserAchievementInfoRes> seqResult = getSequenceAchievementInfoAboutUser(userId);
List<UserAchievementDetailInfoRes> seqResult = getSequenceAchievementInfoAboutUser(userId);

return Stream
.concat(result.stream(), seqResult.stream())
.sorted(Comparator.comparing(UserAchievementInfoRes::getAchievementId)).toList();
.sorted(Comparator.comparing(UserAchievementDetailInfoRes::getAchievementId)).toList();
}

private List<UserAchievementInfoRes> getNonAchievedAndAccumulateAchiementInfo(Long userId) {
private List<UserAchievementDetailInfoRes> getNonAchievedAndAccumulateAchiementInfo(Long userId) {
return userAchievementRepository.getAchievementInfoAboutUser(userId);
}

private List<UserAchievementInfoRes> getSequenceAchievementInfoAboutUser(Long userId) {
private List<UserAchievementDetailInfoRes> getSequenceAchievementInfoAboutUser(Long userId) {

// 사용자가 진행중이거나 달성중인, Sequence 타입 업적
List<ActivityType> sequenceList = achievementRepository
Expand All @@ -74,12 +74,13 @@ private List<UserAchievementInfoRes> getSequenceAchievementInfoAboutUser(Long us

return achievementIds.stream().map(achievementId -> {
Achievement achievement = achievementFacadeService.getById(achievementId);
return UserAchievementInfoRes.builder()
.userId(userId)
return UserAchievementDetailInfoRes.builder()
.achievementId(achievementId)
.userId(userId)
.title(achievement.getTitle())
.imgUrl(achievement.getImgUrl())
.description(achievement.getDescription())
.progressLevel(achievement.getProgressLevel())
.requirementType(achievement.getRequirementType())
.requirementValue(achievement.getRequirementValue())
.progressCount(map.get(achievement.getActivityType()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ public class UserAchievementInfoRes {
private final String title;
private final String imgUrl;
private final String description;
private final Integer progressLevel;
private final RequirementType requirementType;
private final Integer requirementValue;
private final Integer progressCount;
private final Boolean completed;

@Builder
private UserAchievementInfoRes(Long userId, Long achievementId, String title, String imgUrl,
String description, RequirementType requirementType, Integer requirementValue,
Integer progressCount, Boolean completed) {
String description, Integer progressLevel, RequirementType requirementType,
Integer requirementValue, Integer progressCount, Boolean completed) {
this.userId = userId;
this.achievementId = achievementId;
this.title = title;
this.imgUrl = imgUrl;
this.description = description;
this.progressLevel = progressLevel;
this.requirementType = requirementType;
this.requirementValue = requirementValue;
this.progressCount = progressCount;
Expand All @@ -40,6 +42,7 @@ public static UserAchievementInfoRes of(UserAchievement userAchievement, Integer
userAchievement.getAchievement().getTitle(),
userAchievement.getAchievement().getImgUrl(),
userAchievement.getAchievement().getDescription(),
userAchievement.getAchievement().getProgressLevel(),
userAchievement.getAchievement().getRequirementType(),
userAchievement.getAchievement().getRequirementValue(),
progressCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public interface AchievementJpaRepository extends JpaRepository<Achievement, Lon
@Query("select ac from Achievement ac where ac.id = :id")
Optional<Achievement> findById(Long id);

@Query("select ac from Achievement ac where ac.activityType = :activityType")
List<Achievement> findByActivityType(ActivityType activityType);

@Query("select max(ac.progressLevel) from Achievement ac where ac.activityType = :activityType group by ac.activityType")
Integer findMaxProgressLevelByActivityType(ActivityType activityType);

@Query("""
select ac.activityType from Achievement ac join UserAchievement ua
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.oeid.mogakgo.domain.achievement.infrastructure;

import io.oeid.mogakgo.domain.achievement.application.dto.res.UserAchievementInfoRes;
import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType;
import io.oeid.mogakgo.domain.achievement.presentation.dto.res.UserAchievementDetailInfoRes;
import java.util.List;

public interface UserAchievementRepositoryCustom {

List<UserAchievementInfoRes> getAchievementInfoAboutUser(Long userId);
List<UserAchievementDetailInfoRes> getAchievementInfoAboutUser(Long userId);
Long getAvailableAchievementWithNull(Long userId, ActivityType activityType);
Long findMinAchievementIdByActivityType(ActivityType activityType);
Long getAvailableAchievementWithoutNull(Long userId, ActivityType activityType);
Expand Down
Loading

0 comments on commit 667303d

Please sign in to comment.