From 3a427bb2b99641ab3cf7a2a080257907b19b8fb8 Mon Sep 17 00:00:00 2001 From: happyjamy <78072370+happyjamy@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:10:49 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20=EC=97=85=EC=A0=81=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/{ => entity}/Achievement.java | 30 ++++++----- .../domain/entity/UserAchievement.java | 51 +++++++++++++++++++ .../domain/entity/UserActivity.java | 48 +++++++++++++++++ .../domain/entity/enums/ActivityType.java | 32 ++++++++++++ .../domain/entity/enums/RequirementType.java | 8 +++ .../domain/enums/AchievementType.java | 6 --- .../AchievementJpaRepository.java | 4 +- 7 files changed, 157 insertions(+), 22 deletions(-) rename src/main/java/io/oeid/mogakgo/domain/achievement/domain/{ => entity}/Achievement.java (59%) create mode 100644 src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserAchievement.java create mode 100644 src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserActivity.java create mode 100644 src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/ActivityType.java create mode 100644 src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/RequirementType.java delete mode 100644 src/main/java/io/oeid/mogakgo/domain/achievement/domain/enums/AchievementType.java diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/Achievement.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/Achievement.java similarity index 59% rename from src/main/java/io/oeid/mogakgo/domain/achievement/domain/Achievement.java rename to src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/Achievement.java index 6052841c..16ea0038 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/Achievement.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/Achievement.java @@ -1,6 +1,7 @@ -package io.oeid.mogakgo.domain.achievement.domain; +package io.oeid.mogakgo.domain.achievement.domain.entity; -import io.oeid.mogakgo.domain.achievement.domain.enums.AchievementType; +import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType; +import io.oeid.mogakgo.domain.achievement.domain.entity.enums.RequirementType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -9,7 +10,6 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.Table; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -33,16 +33,18 @@ public class Achievement { @Column(name = "img_url") private String imgUrl; + @Column(name = "progress_level") + private Integer progressLevel; + @Enumerated(EnumType.STRING) - @Column(name = "type") - private AchievementType achievementType; - - @Builder - private Achievement(String title, String description, String imgUrl, - AchievementType achievementType) { - this.title = title; - this.description = description; - this.imgUrl = imgUrl; - this.achievementType = achievementType; - } + @Column(name = "requirement_type") + private RequirementType requirementType; + + @Column(name = "requirement_value") + private Integer requirementValue; + + @Enumerated(EnumType.STRING) + @Column(name = "activity_type") + private ActivityType activityType; + } diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserAchievement.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserAchievement.java new file mode 100644 index 00000000..d0053180 --- /dev/null +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserAchievement.java @@ -0,0 +1,51 @@ +package io.oeid.mogakgo.domain.achievement.domain.entity; + +import io.oeid.mogakgo.domain.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Getter +@Entity +@Table(name = "user_achievement_tb") +@NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) +@EntityListeners(AuditingEntityListener.class) +public class UserAchievement { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "achievement_id") + private Achievement achievement; + + // TODO: 필요하면 개발하다가 추가 +// @Column(name = "progress_count") +// private Integer progressCount; + + @Column(name = "completed") + private Boolean completed; + + @CreatedDate + @Column(name = "created_at") + private LocalDateTime createdAt; + +} diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserActivity.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserActivity.java new file mode 100644 index 00000000..b5d1aa66 --- /dev/null +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/UserActivity.java @@ -0,0 +1,48 @@ +package io.oeid.mogakgo.domain.achievement.domain.entity; + +import io.oeid.mogakgo.domain.achievement.domain.entity.enums.ActivityType; +import io.oeid.mogakgo.domain.user.domain.User; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Getter +@Entity +@Table(name = "user_activity_tb") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@EntityListeners(AuditingEntityListener.class) +public class UserActivity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @Enumerated(EnumType.STRING) + @Column(name = "activity_type") + private ActivityType activityType; + + @CreatedDate + @Column(name = "created_at") + private LocalDateTime createdAt; + +} diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/ActivityType.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/ActivityType.java new file mode 100644 index 00000000..a21d987c --- /dev/null +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/ActivityType.java @@ -0,0 +1,32 @@ +package io.oeid.mogakgo.domain.achievement.domain.entity.enums; + +import java.util.List; +import lombok.Getter; + +@Getter +public enum ActivityType { + + FROM_ONE_STEP(List.of(2, 3, 4)), + GOOD_PERSON_GOOD_MEETUP(List.of(5, 6, 7)), + LIKE_E(List.of(8, 9, 10)), + MY_DESTINY(List.of(11)), + CAPTURE_FAIL_EXIST(List.of(12)), + RUN_AWAY_FROM_MONSTAR_BALL(List.of(13)), + PLEASE_GIVE_ME_MOGAK(List.of(14, 15, 16)), + BRAVE_EXPLORER(List.of(17)), + NOMAD_CODER(List.of(18)), + CATCH_ME_IF_YOU_CAN(List.of(19, 20, 21)), + LEAVE_YOUR_MARK(List.of(22)), + WHAT_A_POPULAR_PERSON(List.of(23, 24, 25)), + CONTACT_WITH_GOD(List.of(26)), + FRESH_DEVELOPER(List.of(28, 29, 30)), + ; + + private final List IncludedDbIdList; + + ActivityType(List includedDbIdList) { + IncludedDbIdList = includedDbIdList; + } + + +} diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/RequirementType.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/RequirementType.java new file mode 100644 index 00000000..ee757b34 --- /dev/null +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/entity/enums/RequirementType.java @@ -0,0 +1,8 @@ +package io.oeid.mogakgo.domain.achievement.domain.entity.enums; + +public enum RequirementType { + SEQUENCE, + ACCUMULATE, + ; + +} diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/enums/AchievementType.java b/src/main/java/io/oeid/mogakgo/domain/achievement/domain/enums/AchievementType.java deleted file mode 100644 index 3f2faaad..00000000 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/domain/enums/AchievementType.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.oeid.mogakgo.domain.achievement.domain.enums; - -public enum AchievementType { - ONCE - -} diff --git a/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/AchievementJpaRepository.java b/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/AchievementJpaRepository.java index cac992d4..8b1f5e56 100644 --- a/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/AchievementJpaRepository.java +++ b/src/main/java/io/oeid/mogakgo/domain/achievement/infrastructure/AchievementJpaRepository.java @@ -1,10 +1,10 @@ package io.oeid.mogakgo.domain.achievement.infrastructure; -import io.oeid.mogakgo.domain.achievement.domain.Achievement; +import io.oeid.mogakgo.domain.achievement.domain.entity.Achievement; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository public interface AchievementJpaRepository extends JpaRepository { -} \ No newline at end of file +}