Skip to content

Commit

Permalink
Feature | #88 | @YongsHub | 케이크 추가 도메인 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
YongsHub committed Jun 18, 2024
1 parent 5ea5a5a commit 0da784f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.hibernate.annotations.ColumnDefault;

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

Expand Down Expand Up @@ -58,6 +59,7 @@ public class Cake extends AuditEntity {
@Column(name = "deleted_at")
private LocalDateTime deletedAt;

@Builder
public Cake(String cakeImageUrl, CakeShop cakeShop) {
this.cakeImageUrl = cakeImageUrl;
this.cakeShop = cakeShop;
Expand Down Expand Up @@ -98,4 +100,19 @@ public void removeCakeCategories() {
public void removeCakeTags() {
this.cakeTags.clear();
}

public void registerTags(List<Tag> tags) {
tags.forEach(tag -> this.cakeTags.add(CakeTagMapper.supplyCakeTagBy(this, tag)));
}

public void registerCategories(List<CakeCategory> cakeCategories) {
cakeCategories.forEach(cakeCategory -> {
cakeCategory.updateCake(this);
this.cakeCategories.add(cakeCategory);
});
}

public void updateCakeShop(CakeShop cakeShop) {
this.cakeShop = cakeShop;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.cakk.domain.mysql.dto.param.shop.CakeShopUpdateParam;
import com.cakk.domain.mysql.dto.param.shop.UpdateShopAddressParam;
import com.cakk.domain.mysql.entity.audit.AuditEntity;
import com.cakk.domain.mysql.entity.cake.Cake;
import com.cakk.domain.mysql.entity.user.BusinessInformation;

@Getter
Expand Down Expand Up @@ -83,6 +84,9 @@ public class CakeShop extends AuditEntity {
@OneToMany(mappedBy = "cakeShop", cascade = CascadeType.PERSIST, orphanRemoval = true)
private List<CakeShopOperation> cakeShopOperations = new ArrayList<>();

@OneToMany(mappedBy = "cakeShop", cascade = CascadeType.PERSIST)
private List<Cake> cakes = new ArrayList<>();

@Builder
public CakeShop(
String shopName,
Expand Down Expand Up @@ -148,4 +152,9 @@ public void updateShopOperationDays(List<CakeShopOperation> cakeShopOperations)
this.cakeShopOperations.add(cakeShopOperation);
});
}

public void registerCake(Cake cake) {
cake.updateCakeShop(this);
this.cakes.add(cake);
}
}

0 comments on commit 0da784f

Please sign in to comment.