-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/main/java/poomasi/domain/auth/config/SecurityConfig.java
- Loading branch information
Showing
55 changed files
with
804 additions
and
55 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
6 changes: 5 additions & 1 deletion
6
src/main/java/poomasi/domain/auth/token/reissue/dto/ReissueRequest.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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
package poomasi.domain.auth.token.reissue.dto; | ||
|
||
public record ReissueRequest(String refreshToken) { | ||
import jakarta.validation.constraints.NotBlank; | ||
|
||
public record ReissueRequest( | ||
@NotBlank(message = "리프레시 토큰을 입력해야 합니다.") | ||
String refreshToken) { | ||
} |
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
2 changes: 2 additions & 0 deletions
2
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
|
||
public interface ImageDeleteLinker { | ||
boolean supports(ImageType type); | ||
void handleImageDeletion(Image image); | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/main/java/poomasi/domain/image/deleteLinker/ProductIntroDeleteLinker.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,45 @@ | ||
package poomasi.domain.image.deleteLinker; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
import poomasi.domain.product._intro.entity.ProductIntro; | ||
import poomasi.domain.product._intro.service.ProductIntroService; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
@Component | ||
public class ProductIntroDeleteLinker implements ImageDeleteLinker { | ||
|
||
private final ProductIntroService productIntroService; | ||
|
||
public ProductIntroDeleteLinker(ProductIntroService productIntroService) { | ||
this.productIntroService = productIntroService; | ||
} | ||
|
||
@Override | ||
public boolean supports(ImageType type) { | ||
return type == ImageType.PRODUCT_INTRO; | ||
} | ||
|
||
@Transactional | ||
@Override | ||
public void handleImageDeletion(Image image) { | ||
ProductIntro productIntro = productIntroService.getIntroByIntroId(image.getReferenceId()); | ||
|
||
List<Image> images = Arrays.asList(productIntro.getMainImage(), productIntro.getSubImage1(), productIntro.getSubImage2(), productIntro.getSubImage3()); | ||
for (int i = 0; i < images.size(); i++) { | ||
if (images.get(i) == image) { | ||
switch (i) { | ||
case 0 -> productIntro.setMainImage(null); | ||
case 1 -> productIntro.setSubImage1(null); | ||
case 2 -> productIntro.setSubImage2(null); | ||
case 3 -> productIntro.setSubImage3(null); | ||
} | ||
} | ||
} | ||
productIntroService.saveExistedProductIntro(productIntro); | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
src/main/java/poomasi/domain/image/linker/ProductIntroImageLinker.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,64 @@ | ||
package poomasi.domain.image.linker; | ||
|
||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import poomasi.domain.image.entity.Image; | ||
import poomasi.domain.image.entity.ImageType; | ||
import poomasi.domain.product._intro.entity.ProductIntro; | ||
import poomasi.domain.product._intro.service.ProductIntroService; | ||
import poomasi.global.error.BusinessException; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import static poomasi.global.error.BusinessError.IMAGE_LIMIT_EXCEED; | ||
|
||
@Service | ||
public class ProductIntroImageLinker implements ImageLinker { | ||
|
||
private final ProductIntroService productIntroService; | ||
|
||
public ProductIntroImageLinker(ProductIntroService productIntroService) { | ||
this.productIntroService = productIntroService; | ||
} | ||
|
||
@Override | ||
public boolean supports(ImageType type) { | ||
return type == ImageType.PRODUCT_INTRO; | ||
} | ||
|
||
@Transactional | ||
@Override | ||
public void link(Long referenceId, Image savedImage) { | ||
ProductIntro productIntro = productIntroService.getIntroByIntroId(referenceId); | ||
addImageToProductIntro(productIntro, savedImage); | ||
productIntroService.saveExistedProductIntro(productIntro); | ||
} | ||
|
||
private void addImageToProductIntro(ProductIntro productIntro, Image savedImage) { | ||
List<Image> images = Arrays.asList( | ||
productIntro.getMainImage(), | ||
productIntro.getSubImage1(), | ||
productIntro.getSubImage2(), | ||
productIntro.getSubImage3() | ||
); | ||
|
||
for (int i = 0; i < images.size(); i++) { | ||
if (images.get(i) == null) { | ||
setImageByIndex(productIntro, i, savedImage); | ||
return; | ||
} | ||
} | ||
|
||
throw new BusinessException(IMAGE_LIMIT_EXCEED); | ||
} | ||
|
||
private void setImageByIndex(ProductIntro productIntro, int index, Image image) { | ||
switch (index) { | ||
case 0 -> productIntro.setMainImage(image); | ||
case 1 -> productIntro.setSubImage1(image); | ||
case 2 -> productIntro.setSubImage2(image); | ||
case 3 -> productIntro.setSubImage3(image); | ||
} | ||
} | ||
} |
Oops, something went wrong.