|
3 | 3 | import java.util.ArrayList;
|
4 | 4 | import java.util.List;
|
5 | 5 |
|
| 6 | +import com.sponus.sponusbe.domain.organization.dto.OrganizationUpdateRequest; |
6 | 7 | import com.sponus.sponusbe.domain.organization.entity.enums.OrganizationStatus;
|
7 | 8 | import com.sponus.sponusbe.domain.organization.entity.enums.OrganizationType;
|
8 | 9 | import com.sponus.sponusbe.domain.organization.entity.enums.SuborganizationType;
|
|
12 | 13 | import jakarta.persistence.Entity;
|
13 | 14 | import jakarta.persistence.EnumType;
|
14 | 15 | import jakarta.persistence.Enumerated;
|
| 16 | +import jakarta.persistence.FetchType; |
15 | 17 | import jakarta.persistence.GeneratedValue;
|
16 | 18 | import jakarta.persistence.GenerationType;
|
17 | 19 | import jakarta.persistence.Id;
|
@@ -88,14 +90,44 @@ public class Organization extends BaseEntity {
|
88 | 90 | private OrganizationStatus organizationStatus;
|
89 | 91 |
|
90 | 92 | @Builder.Default
|
91 |
| - @OneToMany(mappedBy = "organization") |
| 93 | + @OneToMany(mappedBy = "organization", fetch = FetchType.EAGER) |
92 | 94 | private List<OrganizationTag> organizationTags = new ArrayList<>();
|
93 | 95 |
|
94 | 96 | @Builder.Default
|
95 |
| - @OneToMany(mappedBy = "organization") |
| 97 | + @OneToMany(mappedBy = "organization", fetch = FetchType.EAGER) |
96 | 98 | private List<OrganizationLink> organizationLinks = new ArrayList<>();
|
97 | 99 |
|
98 | 100 | public boolean isStudentOrganization() {
|
99 | 101 | return this.organizationType == OrganizationType.STUDENT;
|
100 | 102 | }
|
| 103 | + |
| 104 | + public void update(OrganizationUpdateRequest request) { |
| 105 | + this.name = request.name() == null ? this.name : request.name(); |
| 106 | + this.email = request.email() == null ? this.email : request.email(); |
| 107 | + this.password = request.password() == null ? this.password : request.password(); |
| 108 | + this.location = request.location() == null ? this.location : request.location(); |
| 109 | + this.description = request.description() == null ? this.description : request.description(); |
| 110 | + this.imageUrl = request.imageUrl() == null ? this.imageUrl : request.imageUrl(); |
| 111 | + this.organizationType = request.organizationType() == null ? this.organizationType : request.organizationType(); |
| 112 | + this.suborganizationType = |
| 113 | + request.suborganizationType() == null ? this.suborganizationType : request.suborganizationType(); |
| 114 | + this.managerName = request.managerName() == null ? this.managerName : request.managerName(); |
| 115 | + this.managerPosition = request.managerPosition() == null ? this.managerPosition : request.managerPosition(); |
| 116 | + this.managerEmail = request.managerEmail() == null ? this.managerEmail : request.managerEmail(); |
| 117 | + this.managerPhone = request.managerPhone() == null ? this.managerPhone : request.managerPhone(); |
| 118 | + this.managerAvailableDay = |
| 119 | + request.managerAvailableDay() == null ? this.managerAvailableDay : request.managerAvailableDay(); |
| 120 | + this.managerAvailableHour = |
| 121 | + request.managerAvailableHour() == null ? this.managerAvailableHour : request.managerAvailableHour(); |
| 122 | + this.managerContactPreference = request.managerContactPreference() == null ? this.managerContactPreference : |
| 123 | + request.managerContactPreference(); |
| 124 | + } |
| 125 | + |
| 126 | + public void deactivate() { |
| 127 | + this.organizationStatus = OrganizationStatus.INACTIVE; |
| 128 | + } |
| 129 | + |
| 130 | + public void activate() { |
| 131 | + this.organizationStatus = OrganizationStatus.ACTIVE; |
| 132 | + } |
101 | 133 | }
|
0 commit comments