Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#182 업적 도메인 구현 #189

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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<Integer> includedDbIdList;

ActivityType(List<Integer> includedDbIdList) {
this.includedDbIdList = includedDbIdList;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.oeid.mogakgo.domain.achievement.domain.entity.enums;

public enum RequirementType {
SEQUENCE,
ACCUMULATE,
;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<Achievement, Long> {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.oeid.mogakgo.domain.user.application;

import io.oeid.mogakgo.domain.achievement.domain.Achievement;
import io.oeid.mogakgo.domain.achievement.domain.entity.Achievement;
import io.oeid.mogakgo.domain.achievement.infrastructure.AchievementJpaRepository;
import io.oeid.mogakgo.domain.profile.application.ProfileCardService;
import io.oeid.mogakgo.domain.profile.application.dto.req.UserProfileCardReq;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/oeid/mogakgo/domain/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static io.oeid.mogakgo.exception.code.ErrorCode400.USER_AVAILABLE_LIKE_AMOUNT_IS_FULL;
import static io.oeid.mogakgo.exception.code.ErrorCode400.USER_AVAILABLE_LIKE_COUNT_IS_ZERO;

import io.oeid.mogakgo.domain.achievement.domain.Achievement;
import io.oeid.mogakgo.domain.achievement.domain.entity.Achievement;
import io.oeid.mogakgo.domain.geo.domain.enums.Region;
import io.oeid.mogakgo.domain.user.domain.enums.Role;
import io.oeid.mogakgo.domain.user.exception.UserException;
Expand Down
Loading