-
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.
[BSVR-167] 레벨 도메인 분리 및 레벨별 칭호, 마스코트 이미지 추가 (#96)
* feat: Level 도메인 분리 * feat: 레벨 레포지토리 추가 및 레벨 수정 유스케이스 수정 * feat: level 유스케이스 생성 * feat: member 생성 로직 변경 * fix: level 관련 API res 수정 * feat: 불필요한 Level enum 삭제 * fix: member-level 사이의 cascade all 옵션 삭제 * feat: Level 도메인에 createdAt, updatedAt, deletedAt 추가 * fix: jpa save 이용하도록 Update 수정 * fix: 후기 작성 후, 레벨 업데이트 된 유저 정보 반환하도록 수정 * feat: data.sql에 levels 추가 * feat: data.sql의 헥사코드 수정
- Loading branch information
Showing
22 changed files
with
347 additions
and
215 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
41 changes: 41 additions & 0 deletions
41
domain/src/main/java/org/depromeet/spot/domain/member/Level.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,41 @@ | ||
package org.depromeet.spot.domain.member; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class Level { | ||
|
||
private final Long id; | ||
private final int value; | ||
private final String title; | ||
private final String mascotImageUrl; | ||
private final LocalDateTime createdAt; | ||
private final LocalDateTime updatedAt; | ||
private final LocalDateTime deletedAt; | ||
|
||
public static int calculateLevel(final long reviewCnt) { | ||
if (reviewCnt == 0) { | ||
return 0; | ||
} | ||
if (reviewCnt <= 2) { | ||
return 1; | ||
} | ||
if (2 < reviewCnt && reviewCnt <= 4) { | ||
return 2; | ||
} | ||
if (4 < reviewCnt && reviewCnt <= 7) { | ||
return 3; | ||
} | ||
if (7 < reviewCnt && reviewCnt <= 13) { | ||
return 4; | ||
} | ||
if (13 < reviewCnt && reviewCnt <= 20) { | ||
return 5; | ||
} | ||
return 6; | ||
} | ||
} |
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
37 changes: 0 additions & 37 deletions
37
domain/src/main/java/org/depromeet/spot/domain/member/enums/Level.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
infrastructure/jpa/src/main/java/org/depromeet/spot/jpa/member/entity/LevelEntity.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,49 @@ | ||
package org.depromeet.spot.jpa.member.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
|
||
import org.depromeet.spot.domain.member.Level; | ||
import org.depromeet.spot.jpa.common.entity.BaseEntity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Table(name = "levels") | ||
public class LevelEntity extends BaseEntity { | ||
|
||
@Column(name = "value", nullable = false, unique = true) | ||
private int value; | ||
|
||
@Column(name = "title", nullable = false, unique = true) | ||
private String title; | ||
|
||
@Column(name = "mascot_image_url") | ||
private String mascotImageUrl; | ||
|
||
public LevelEntity(Level level) { | ||
super(level.getId(), level.getCreatedAt(), level.getUpdatedAt(), level.getDeletedAt()); | ||
value = level.getValue(); | ||
title = level.getTitle(); | ||
mascotImageUrl = level.getMascotImageUrl(); | ||
} | ||
|
||
public static LevelEntity from(Level level) { | ||
return new LevelEntity(level.getValue(), level.getTitle(), level.getMascotImageUrl()); | ||
} | ||
|
||
public Level toDomain() { | ||
return new Level( | ||
this.getId(), | ||
value, | ||
title, | ||
mascotImageUrl, | ||
this.getCreatedAt(), | ||
this.getUpdatedAt(), | ||
this.getDeletedAt()); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
...ucture/jpa/src/main/java/org/depromeet/spot/jpa/member/repository/LevelJpaRepository.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,9 @@ | ||
package org.depromeet.spot.jpa.member.repository; | ||
|
||
import org.depromeet.spot.jpa.member.entity.LevelEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface LevelJpaRepository extends JpaRepository<LevelEntity, Long> { | ||
|
||
LevelEntity findByValue(int value); | ||
} |
19 changes: 19 additions & 0 deletions
19
...cture/jpa/src/main/java/org/depromeet/spot/jpa/member/repository/LevelRepositoryImpl.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,19 @@ | ||
package org.depromeet.spot.jpa.member.repository; | ||
|
||
import org.depromeet.spot.domain.member.Level; | ||
import org.depromeet.spot.usecase.port.out.member.LevelRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class LevelRepositoryImpl implements LevelRepository { | ||
|
||
private final LevelJpaRepository levelJpaRepository; | ||
|
||
@Override | ||
public Level findByValue(final int value) { | ||
return levelJpaRepository.findByValue(value).toDomain(); | ||
} | ||
} |
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
Oops, something went wrong.