-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #429 from mash-up-kr/feature/mashong-init
Feature/mashong
- Loading branch information
Showing
30 changed files
with
1,021 additions
and
0 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
11 changes: 11 additions & 0 deletions
11
...ava/kr/mashup/branding/domain/mashong/Exception/MashongMissionLevelNotFoundException.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,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); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ain/java/kr/mashup/branding/domain/mashong/Exception/MashongMissionNotFoundException.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,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); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongAttendance.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,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; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongMission.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,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); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongMissionLevel.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,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; | ||
} |
81 changes: 81 additions & 0 deletions
81
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongMissionLog.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,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; | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongMissionTeamLog.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,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; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MashongPopcorn.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,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; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MissionRepeatType.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,6 @@ | ||
package kr.mashup.branding.domain.mashong; | ||
|
||
public enum MissionRepeatType { | ||
DAILY, | ||
NONE | ||
} |
11 changes: 11 additions & 0 deletions
11
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MissionStrategyType.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,11 @@ | ||
package kr.mashup.branding.domain.mashong; | ||
|
||
public enum MissionStrategyType { | ||
MASHONG_ATTENDANCE_INDIVIDUAL, | ||
|
||
MASHONG_ATTENDANCE_TEAN, | ||
|
||
MASHONG_DANGGN_SHAKE_INDIVIDUAL, | ||
|
||
MASHONG_DANGGN_SHAKE_TEAM | ||
} |
6 changes: 6 additions & 0 deletions
6
mashup-domain/src/main/java/kr/mashup/branding/domain/mashong/MissionType.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,6 @@ | ||
package kr.mashup.branding.domain.mashong; | ||
|
||
public enum MissionType { | ||
INDIVIDUAL, | ||
TEAM | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/src/main/java/kr/mashup/branding/repository/mashong/MashongAttendanceRepository.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 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); | ||
} |
Oops, something went wrong.