-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/Lets-JUPJUP/JUPJUP-Back …
…into develop
- Loading branch information
Showing
28 changed files
with
524 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/efub/back/jupjup/domain/heart/exception/DuplicateHeartException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package efub.back.jupjup.domain.heart.exception; | ||
|
||
import efub.back.jupjup.global.exception.custom.ApplicationException; | ||
import org.springframework.http.HttpStatus; | ||
|
||
public class DuplicateHeartException extends ApplicationException { | ||
public DuplicateHeartException() { | ||
super(HttpStatus.BAD_REQUEST); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/efub/back/jupjup/domain/member/dto/response/ProfileStatResDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package efub.back.jupjup.domain.member.dto.response; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ProfileStatResDto { | ||
private int userHeartsCount; | ||
private BigDecimal averageScore; // 평균 평점 | ||
private int postCount; | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/java/efub/back/jupjup/domain/member/service/MemberProfileFacade.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package efub.back.jupjup.domain.member.service; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import efub.back.jupjup.domain.member.domain.Member; | ||
import efub.back.jupjup.domain.member.dto.response.ProfileStatResDto; | ||
import efub.back.jupjup.domain.member.exception.MemberNotFoundException; | ||
import efub.back.jupjup.domain.member.repository.MemberRepository; | ||
import efub.back.jupjup.domain.post.repository.PostRepository; | ||
import efub.back.jupjup.domain.postjoin.repository.PostjoinRepository; | ||
import efub.back.jupjup.domain.score.domain.AverageScore; | ||
import efub.back.jupjup.domain.score.repository.AverageScoreRepository; | ||
import efub.back.jupjup.domain.userHeart.repository.UserHeartRepository; | ||
import efub.back.jupjup.global.response.StatusEnum; | ||
import efub.back.jupjup.global.response.StatusResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class MemberProfileFacade { | ||
private final MemberRepository memberRepository; | ||
private final PostRepository postRepository; | ||
private final PostjoinRepository postjoinRepository; | ||
private final UserHeartRepository userHeartRepository; | ||
private final AverageScoreRepository averageScoreRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public ResponseEntity<StatusResponse> getUserProfileStats(Long memberId) { | ||
Member member = memberRepository.findById(memberId).orElseThrow(MemberNotFoundException::new); | ||
// 주최한 플로깅 개수 | ||
int hostCount = (int)postRepository.countByAuthor(member); | ||
int joinCount = (int)postjoinRepository.countByMember(member); | ||
int postCount = hostCount + joinCount; | ||
int userHeartCount = userHeartRepository.countUserHeartsByMemberId(memberId).intValue(); | ||
BigDecimal averageScore = averageScoreRepository.findById(memberId) | ||
.map(AverageScore::getAverageScore) | ||
.orElse(BigDecimal.ZERO); | ||
|
||
ProfileStatResDto profileStatResDto = ProfileStatResDto.builder() | ||
.averageScore(averageScore) | ||
.postCount(postCount) | ||
.userHeartsCount(userHeartCount) | ||
.build(); | ||
|
||
return ResponseEntity.ok() | ||
.body(StatusResponse.builder() | ||
.status(StatusEnum.OK.getStatusCode()) | ||
.message(StatusEnum.OK.getCode()) | ||
.data(profileStatResDto) | ||
.build()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 47 additions & 5 deletions
52
src/main/java/efub/back/jupjup/domain/post/domain/District.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,54 @@ | ||
package efub.back.jupjup.domain.post.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum District { | ||
강남구, 강동구, 강북구, 강서구, 관악구, 광진구, 구로구, 금천구, 노원구, 도봉구, | ||
동대문구, 동작구, 마포구, 서대문구, 서초구, 성동구, 성북구, 송파구, 양천구, 영등포구, | ||
용산구, 은평구, 종로구, 중구, 중랑구 | ||
GANGNAM("강남구"), | ||
GANGDONG("강동구"), | ||
GANGBUK("강북구"), | ||
GANGSEO("강서구"), | ||
GWANAK("관악구"), | ||
GWANGJIN("광진구"), | ||
GURO("구로구"), | ||
GEUMCHEON("금천구"), | ||
NOWON("노원구"), | ||
DOBONG("도봉구"), | ||
DONGDAEMUN("동대문구"), | ||
DONGJAK("동작구"), | ||
MAPO("마포구"), | ||
SEODAEMUN("서대문구"), | ||
SEOCHO("서초구"), | ||
SEONGDONG("성동구"), | ||
SEONGBUK("성북구"), | ||
SONGPA("송파구"), | ||
YANGCHEON("양천구"), | ||
YEONGDEUNGPO("영등포구"), | ||
YONGSAN("용산구"), | ||
EUNPYEONG("은평구"), | ||
JONGNO("종로구"), | ||
JUNG("중구"), | ||
JUNGNANG("중랑구"); | ||
|
||
private final String koreanName; | ||
|
||
District(String koreanName) { | ||
this.koreanName = koreanName; | ||
} | ||
|
||
@JsonCreator | ||
public static District from(String value) { | ||
for (District district : District.values()) { | ||
if (district.getKoreanName().equals(value) || district.name().equalsIgnoreCase(value)) { | ||
return district; | ||
} | ||
} | ||
throw new IllegalArgumentException("Invalid district: " + value); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.koreanName; | ||
} | ||
} |
Oops, something went wrong.