Skip to content

Commit

Permalink
Merge pull request #429 from mash-up-kr/feature/mashong-init
Browse files Browse the repository at this point in the history
Feature/mashong
  • Loading branch information
eunjungL authored Jun 29, 2024
2 parents 2001d8e + ae8014e commit e130b37
Show file tree
Hide file tree
Showing 30 changed files with 1,021 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public enum ResultCode {

RANKING_REWARD_ALREADY_WRITTEN("이미 해당 리워드에 코멘트를 작성하였습니다"),

// Mashong
MASHONG_MISSION_NOT_FOUND("매숑 미션이 존재하지 않습니다."),

MASHONG_MISSION_LEVEL_NOT_FOUND("매숑 미션 레벨이 존재하지 않습니다."),

// JsonUtil
JSON_DESERIALIZE_UNABLE("객체를 json string 을 deserialize 할 수 없습니다"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kr.mashup.branding.domain.mashong.Exception;

import kr.mashup.branding.domain.exception.NotFoundException;

import static kr.mashup.branding.domain.ResultCode.MASHONG_MISSION_LEVEL_NOT_FOUND;

public class MashongMissionLevelNotFoundException extends NotFoundException {
public MashongMissionLevelNotFoundException() {
super(MASHONG_MISSION_LEVEL_NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kr.mashup.branding.domain.mashong.Exception;

import kr.mashup.branding.domain.exception.NotFoundException;

import static kr.mashup.branding.domain.ResultCode.MASHONG_MISSION_NOT_FOUND;

public class MashongMissionNotFoundException extends NotFoundException {
public MashongMissionNotFoundException() {
super(MASHONG_MISSION_NOT_FOUND);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package kr.mashup.branding.domain.mashong;

import kr.mashup.branding.domain.member.MemberGeneration;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongAttendance {
@Id
@GeneratedValue
private Long id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "member_generation_id")
private MemberGeneration memberGeneration;

private LocalDateTime attendanceAt;

public static MashongAttendance of(
MemberGeneration memberGeneration,
LocalDateTime attendanceAt
) {
return new MashongAttendance(memberGeneration, attendanceAt);
}

private MashongAttendance(
MemberGeneration memberGeneration,
LocalDateTime attendanceAt
) {
this.memberGeneration = memberGeneration;
this.attendanceAt = attendanceAt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package kr.mashup.branding.domain.mashong;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Comparator;
import java.util.List;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongMission {
@Id
@GeneratedValue
private Long id;

@Enumerated(EnumType.STRING)
private MissionType missionType;

@Enumerated(EnumType.STRING)
private MissionRepeatType missionRepeatType;

@Enumerated(EnumType.STRING)
private MissionStrategyType missionStrategyType;

private String name;

@OneToMany(mappedBy = "mashongMission")
private List<MashongMissionLevel> mashongMissionLevelList;

public MashongMissionLevel getFirstMissionLevel() {
return this.mashongMissionLevelList.stream().max(Comparator.comparing(MashongMissionLevel::getLevel)).orElseThrow(IllegalStateException::new);
}

public MashongMissionLevel getNextMissionLevel(Long level) {
return mashongMissionLevelList.stream()
.filter(missionLevel -> missionLevel.getLevel() == level + 1)
.findFirst()
.orElseGet(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package kr.mashup.branding.domain.mashong;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.*;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongMissionLevel {
@Id
@GeneratedValue
private Long id;

private Long level;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "mission_id")
private MashongMission mashongMission;

private Long missionGoalValue;

private Long compensationValue;

private String title;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package kr.mashup.branding.domain.mashong;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongMissionLog {
@Id
@GeneratedValue
private Long id;

private Long memberGenerationId;

private Long missionLevelId;

private String baseDate;

private Long level;

private Long missionId;

@Setter
private Double currentStatus;

private LocalDateTime achievedAt;

private Boolean isCompensated;

public static MashongMissionLog of(
Long memberGenerationId,
MashongMissionLevel mashongMissionLevel
) {
return new MashongMissionLog(memberGenerationId, mashongMissionLevel.getId(), null, mashongMissionLevel.getLevel(), mashongMissionLevel.getMashongMission().getId(), 0.0, null, false);
}

public static MashongMissionLog of(
Long memberGenerationId,
MashongMissionLevel mashongMissionLevel,
String baseDate
) {
return new MashongMissionLog(memberGenerationId, mashongMissionLevel.getId(), baseDate, mashongMissionLevel.getLevel(), mashongMissionLevel.getMashongMission().getId(), 0.0, null, false);
}

public void incrementCurrentStatus(
Double value
) {
this.currentStatus += value;
}

public void compensated() {
this.achievedAt = LocalDateTime.now();
this.isCompensated = true;
}

private MashongMissionLog(
Long memberGenerationId,
Long missionLevelId,
String baseDate,
Long level,
Long missionId,
Double currentStatus,
LocalDateTime achievedAt,
Boolean isCompensated
) {
this.memberGenerationId = memberGenerationId;
this.missionLevelId = missionLevelId;
this.baseDate = baseDate;
this.level = level;
this.missionId = missionId;
this.currentStatus = currentStatus;
this.achievedAt = achievedAt;
this.isCompensated = isCompensated;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package kr.mashup.branding.domain.mashong;

import kr.mashup.branding.domain.member.Platform;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.time.LocalDateTime;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongMissionTeamLog {
@Id
@GeneratedValue
private Long id;

@Enumerated(EnumType.STRING)
private Platform platform;

private Long generationId;

private Long missionLevelId;

private String baseDate;

private Long level;

private Long missionId;

@Setter
private Double currentStatus;

private LocalDateTime achievedAt;

private Boolean isCompensated;

public static MashongMissionTeamLog of(
Platform platform,
Long generationId,
MashongMissionLevel mashongMissionLevel
) {
return new MashongMissionTeamLog(platform, generationId, mashongMissionLevel.getId(), null, mashongMissionLevel.getLevel(), mashongMissionLevel.getMashongMission().getId(), 0.0, null, false);
}

public static MashongMissionTeamLog of(
Platform platform,
Long generationId,
MashongMissionLevel mashongMissionLevel,
String baseDate
) {
return new MashongMissionTeamLog(platform, generationId, mashongMissionLevel.getId(), baseDate, mashongMissionLevel.getLevel(), mashongMissionLevel.getMashongMission().getId(), 0.0, null, false);
}

public void incrementCurrentStatus(
Double value
) {
this.currentStatus += value;
}

public void compensated() {
this.achievedAt = LocalDateTime.now();
this.isCompensated = true;
}

private MashongMissionTeamLog(
Platform platform,
Long generationId,
Long missionLevelId,
String baseDate,
Long level,
Long missionId,
Double currentStatus,
LocalDateTime achievedAt,
Boolean isCompensated
) {
this.platform = platform;
this.generationId = generationId;
this.missionLevelId = missionLevelId;
this.baseDate = baseDate;
this.level = level;
this.missionId = missionId;
this.currentStatus = currentStatus;
this.achievedAt = achievedAt;
this.isCompensated = isCompensated;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package kr.mashup.branding.domain.mashong;

import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class MashongPopcorn {
@Id
@GeneratedValue
private Long id;

private Long memberGenerationId;

private Long popcorn;

public static MashongPopcorn of(
Long memberGenerationId
) {
return new MashongPopcorn(memberGenerationId, 0L);
}

private MashongPopcorn(
Long memberGenerationId,
Long popcorn
) {
this.memberGenerationId = memberGenerationId;
this.popcorn = popcorn;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.mashup.branding.domain.mashong;

public enum MissionRepeatType {
DAILY,
NONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kr.mashup.branding.domain.mashong;

public enum MissionStrategyType {
MASHONG_ATTENDANCE_INDIVIDUAL,

MASHONG_ATTENDANCE_TEAN,

MASHONG_DANGGN_SHAKE_INDIVIDUAL,

MASHONG_DANGGN_SHAKE_TEAM
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.mashup.branding.domain.mashong;

public enum MissionType {
INDIVIDUAL,
TEAM
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package kr.mashup.branding.repository.mashong;

import kr.mashup.branding.domain.mashong.MashongAttendance;
import kr.mashup.branding.domain.member.Platform;
import org.springframework.data.jpa.repository.JpaRepository;

import java.time.LocalDateTime;
import java.util.List;

public interface MashongAttendanceRepository extends JpaRepository<MashongAttendance, Long> {
List<MashongAttendance> findAllByMemberGenerationIdAndAttendanceAtBetween(Long memberGenerationId, LocalDateTime start, LocalDateTime end);

List<MashongAttendance> findAllByMemberGeneration_PlatformAndAttendanceAtBetween(Platform platform, LocalDateTime start, LocalDateTime end);
}
Loading

0 comments on commit e130b37

Please sign in to comment.