-
Notifications
You must be signed in to change notification settings - Fork 2
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 #138 from kakao-tech-campus-2nd-step3/feature/ISSU…
…E-82 멤버 프로필 작성
- Loading branch information
Showing
48 changed files
with
608 additions
and
347 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
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
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
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
25 changes: 25 additions & 0 deletions
25
src/main/java/poomasi/domain/image/deleteLinker/ImageDeleteFactory.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,25 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import org.springframework.stereotype.Component; | ||
import poomasi.domain.image.entity.ImageType; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Component | ||
public class ImageDeleteFactory { | ||
|
||
private final Map<ImageType, ImageDeleteLinker> handlerMap; | ||
|
||
public ImageDeleteFactory( | ||
ProductDeleteLinker productDeleteLinker, | ||
MemberProfileDeleteLinker memberProfileDeleteLinker) { | ||
this.handlerMap = new HashMap<>(); | ||
handlerMap.put(ImageType.PRODUCT, productDeleteLinker); | ||
handlerMap.put(ImageType.MEMBER_PROFILE, memberProfileDeleteLinker); | ||
} | ||
|
||
public ImageDeleteLinker getDeleteLinker(ImageType type) { | ||
return handlerMap.get(type); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/poomasi/domain/image/deleteLinker/ImageDeleteLinker.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,7 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import poomasi.domain.image.entity.Image; | ||
|
||
public interface ImageDeleteLinker { | ||
void handleImageDeletion(Image image); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/poomasi/domain/image/deleteLinker/MemberProfileDeleteLinker.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,24 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import org.springframework.stereotype.Component; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.member._profile.entity.MemberProfile; | ||
import poomasi.domain.member._profile.service.MemberProfileService; | ||
|
||
@Component | ||
public class MemberProfileDeleteLinker implements ImageDeleteLinker { | ||
|
||
private final MemberProfileService memberProfileService; | ||
|
||
public MemberProfileDeleteLinker(MemberProfileService memberProfileService) { | ||
this.memberProfileService = memberProfileService; | ||
} | ||
|
||
@Override | ||
public void handleImageDeletion(Image image) { | ||
MemberProfile memberProfile = memberProfileService.getMemberProfileById(image.getReferenceId()); | ||
memberProfile.setProfileImage(null); | ||
memberProfileService.saveMemberProfile(memberProfile); | ||
} | ||
} | ||
|
23 changes: 23 additions & 0 deletions
23
src/main/java/poomasi/domain/image/deleteLinker/ProductDeleteLinker.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,23 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import org.springframework.stereotype.Component; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.product.entity.Product; | ||
import poomasi.domain.product.service.ProductService; | ||
|
||
@Component | ||
public class ProductDeleteLinker implements ImageDeleteLinker { | ||
|
||
private final ProductService productService; | ||
|
||
public ProductDeleteLinker(ProductService productService) { | ||
this.productService = productService; | ||
} | ||
|
||
@Override | ||
public void handleImageDeletion(Image image) { | ||
Product product = productService.findProductById(image.getReferenceId()); | ||
product.setImageUrl(null); | ||
productService.saveExistedProduct(product); | ||
} | ||
} |
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
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,9 @@ | ||
package poomasi.domain.image.linker; | ||
|
||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
|
||
public interface ImageLinker { | ||
boolean supports(ImageType type); | ||
void link(Long referenceId, Image savedImage); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/poomasi/domain/image/linker/ImageLinkerFactory.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,23 @@ | ||
package poomasi.domain.image.linker; | ||
|
||
import org.springframework.stereotype.Component; | ||
import poomasi.domain.image.entity.ImageType; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class ImageLinkerFactory { | ||
|
||
private final List<ImageLinker> linkers; | ||
|
||
public ImageLinkerFactory(List<ImageLinker> linkers) { | ||
this.linkers = linkers; | ||
} | ||
|
||
public ImageLinker getLinker(ImageType type) { | ||
return linkers.stream() | ||
.filter(linker -> linker.supports(type)) | ||
.findFirst() | ||
.orElse(null); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/poomasi/domain/image/linker/MemberProfileImageLinker.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,31 @@ | ||
package poomasi.domain.image.linker; | ||
|
||
import org.springframework.stereotype.Service; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
import poomasi.domain.member._profile.entity.MemberProfile; | ||
import poomasi.domain.member._profile.service.MemberProfileService; | ||
|
||
@Service | ||
public class MemberProfileImageLinker implements ImageLinker { | ||
|
||
private final MemberProfileService memberProfileService; | ||
|
||
public MemberProfileImageLinker(MemberProfileService memberProfileService) { | ||
this.memberProfileService = memberProfileService; | ||
} | ||
|
||
@Override | ||
public boolean supports(ImageType type) { | ||
return type == ImageType.MEMBER_PROFILE; | ||
} | ||
|
||
@Override | ||
public void link(Long referenceId, Image savedImage) { | ||
MemberProfile memberProfile = memberProfileService.getMemberProfileById(referenceId); | ||
memberProfile.setProfileImage(savedImage); | ||
memberProfileService.saveMemberProfile(memberProfile); | ||
} | ||
} | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
src/main/java/poomasi/domain/image/linker/ProductImageLinker.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,29 @@ | ||
package poomasi.domain.image.linker; | ||
|
||
import org.springframework.stereotype.Service; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
import poomasi.domain.product.entity.Product; | ||
import poomasi.domain.product.service.ProductService; | ||
|
||
@Service | ||
public class ProductImageLinker implements ImageLinker { | ||
|
||
private final ProductService productService; | ||
|
||
public ProductImageLinker(ProductService productService) { | ||
this.productService = productService; | ||
} | ||
|
||
@Override | ||
public boolean supports(ImageType type) { | ||
return type == ImageType.PRODUCT; | ||
} | ||
|
||
@Override | ||
public void link(Long referenceId, Image savedImage) { | ||
Product product = productService.findProductById(referenceId); | ||
product.setImageUrl(savedImage.getImageUrl()); | ||
productService.saveExistedProduct(product); | ||
} | ||
} |
Oops, something went wrong.