-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.java
More file actions
90 lines (69 loc) · 2.75 KB
/
Team.java
File metadata and controls
90 lines (69 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package site.codemonster.comon.domain.team.entity;
import site.codemonster.comon.domain.team.dto.request.TeamInfoEditRequest;
import site.codemonster.comon.domain.team.enums.Topic;
import site.codemonster.comon.domain.teamMember.entity.TeamMember;
import site.codemonster.comon.domain.teamRecruit.entity.TeamRecruit;
import site.codemonster.comon.global.entityListeners.TimeStamp;
import jakarta.persistence.*;
import lombok.Builder;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import site.codemonster.comon.global.images.enums.ImageConstant;
@Entity
@Getter
public class Team extends TimeStamp {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long teamId;
private String teamName;
private String teamIconUrl = ImageConstant.DEFAULT_TEAM.getObjectKey();
private Topic teamTopic;
private String teamExplain;
private int maxParticipant;
private String teamPassword;
private int streakDays = 0;
private String teamAnnouncement="";
@OneToOne(mappedBy = "team", fetch = FetchType.LAZY)
private TeamRecruit teamRecruit;
@OneToMany(mappedBy = "team")
private List<TeamMember> teamMembers = new ArrayList<>();
protected Team(){
}
@Builder
public Team(String teamName, Topic teamTopic, String teamExplain, int maxParticipant, String teamPassword) {
this.teamName = teamName;
this.teamTopic = teamTopic;
this.teamExplain = teamExplain;
this.maxParticipant = maxParticipant;
this.teamPassword = teamPassword;
}
public void updateTeamIconUrl(String teamIconUrl){
this.teamIconUrl = teamIconUrl;
}
public void updateTeamInfo(TeamInfoEditRequest teamInfoEditRequest){
if (teamInfoEditRequest.teamName() != null){
this.teamName = teamInfoEditRequest.teamName();
}
if (teamInfoEditRequest.teamExplain() != null){
this.teamExplain = teamInfoEditRequest.teamExplain();
}
if (teamInfoEditRequest.topic() != null){
this.teamTopic = Topic.fromName(teamInfoEditRequest.topic());
}
this.maxParticipant = teamInfoEditRequest.memberLimit();
if (teamInfoEditRequest.password() != null && !teamInfoEditRequest.password().isEmpty()){
this.teamPassword = teamInfoEditRequest.password();
}
}
public void updateTeamRecruit(TeamRecruit teamRecruit){
this.teamRecruit = teamRecruit;
}
public void updateTeamAnnouncement(String teamAnnouncement) { this.teamAnnouncement = teamAnnouncement; }
public boolean checkExceedTeamSize(){
return this.teamMembers.size() >= maxParticipant;
}
public void addTeamRecruit(TeamRecruit teamRecruit){
this.teamRecruit = teamRecruit;
}
}