Skip to content

Commit e1f7e7f

Browse files
Merge pull request #360 from Podo-Store/develop
VER 2.0.0 반영
2 parents 3253297 + 0970ab3 commit e1f7e7f

File tree

13 files changed

+241
-76
lines changed

13 files changed

+241
-76
lines changed

src/main/java/PodoeMarket/podoemarket/admin/service/AdminService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import PodoeMarket.podoemarket.common.repository.OrderItemRepository;
1313
import PodoeMarket.podoemarket.common.repository.OrderRepository;
1414
import PodoeMarket.podoemarket.common.repository.ProductRepository;
15+
import PodoeMarket.podoemarket.service.MailSendService;
1516
import com.amazonaws.services.s3.AmazonS3;
1617
import com.amazonaws.services.s3.model.AmazonS3Exception;
1718
import com.amazonaws.services.s3.model.S3Object;
@@ -41,6 +42,7 @@ public class AdminService {
4142
private final OrderRepository orderRepo;
4243
private final OrderItemRepository orderItemRepo;
4344
private final AmazonS3 amazonS3;
45+
private final MailSendService mailSendService;
4446

4547
@Value("${cloud.aws.s3.bucket}")
4648
private String bucket;
@@ -115,6 +117,12 @@ public void updateProduct(final UUID productId, final PlayTypeRequestDTO dto) {
115117
product.setChecked(dto.getProductStatus());
116118

117119
productRepo.save(product);
120+
121+
if (dto.getProductStatus() == ProductStatus.PASS)
122+
mailSendService.joinRegisterPassMail(product.getUser().getEmail(), product.getTitle());
123+
else if (dto.getProductStatus() == ProductStatus.REJECT)
124+
mailSendService.joinRegisterRejectMail(product.getUser().getEmail(), product.getTitle());
125+
118126
} catch (Exception e) {
119127
throw new RuntimeException("상품 업데이트 실패", e);
120128
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package PodoeMarket.podoemarket.api.controller;
2+
3+
import PodoeMarket.podoemarket.api.dto.response.SignInStatusResponseDTO;
4+
import PodoeMarket.podoemarket.common.dto.ResponseDTO;
5+
import PodoeMarket.podoemarket.common.entity.UserEntity;
6+
import lombok.RequiredArgsConstructor;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.springframework.http.ResponseEntity;
9+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
10+
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
@RequiredArgsConstructor
15+
@RestController
16+
@Slf4j
17+
@RequestMapping("/api")
18+
public class ApiController {
19+
20+
@GetMapping("/status")
21+
public ResponseEntity<?> signInStatus(@AuthenticationPrincipal UserEntity userInfo) {
22+
try {
23+
boolean isSignIn = userInfo != null;
24+
final SignInStatusResponseDTO resDTO = new SignInStatusResponseDTO(isSignIn);
25+
26+
return ResponseEntity.ok().body(resDTO);
27+
} catch (Exception e) {
28+
ResponseDTO resDTO = ResponseDTO.builder().error(e.getMessage()).build();
29+
return ResponseEntity.badRequest().body(resDTO);
30+
}
31+
}
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package PodoeMarket.podoemarket.api.dto.response;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
@Data
9+
@Builder
10+
@NoArgsConstructor
11+
@AllArgsConstructor
12+
public class SignInStatusResponseDTO {
13+
private Boolean isSignIn;
14+
}

src/main/java/PodoeMarket/podoemarket/common/config/WebConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class WebConfig implements WebMvcConfigurer {
2828
private final JwtAuthenticationFilter jwtAuthenticationFilter;
2929
private final String[] swaggerPath = {"/swagger-ui/**", "/v3/api-docs/**", "/swagger-resources/**", "/error"};
30-
private final String[] permitPath = {"/", "/auth/**", "/scripts/**", "/user/**", "/mailLogo.png"};
30+
private final String[] permitPath = {"/", "/auth/**", "/scripts/**", "/user/**", "/mailLogo.png", "/api/**"};
3131

3232
@Bean
3333
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

src/main/java/PodoeMarket/podoemarket/common/repository/ProductRepository.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ public interface ProductRepository extends JpaRepository<ProductEntity, Long> {
2121

2222
ProductEntity findById(UUID id);
2323

24-
List<ProductEntity> findAllByPlayTypeAndChecked(PlayType playType, ProductStatus checked, Pageable pageable);
24+
@Query("SELECT p FROM ProductEntity p " +
25+
"WHERE p.playType = :playType " +
26+
"AND p.checked = :checked " +
27+
"AND p.isDelete = false " +
28+
"AND (p.script = true OR p.performance = true)")
29+
List<ProductEntity> findAllValidPlays(
30+
@Param("playType") PlayType playType,
31+
@Param("checked") ProductStatus checked,
32+
Pageable pageable
33+
);
34+
35+
2536

2637
Long countAllByChecked(ProductStatus checked);
2738

src/main/java/PodoeMarket/podoemarket/order/service/OrderService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public OrderItemResponseDTO getOrderItemInfo(UserEntity userInfo, OrderInfoReque
6464
.totalPrice(totalPrice)
6565
.build();
6666
} catch (Exception e) {
67-
throw new RuntimeException("주문 상품 정보 조회 중 오류 발생", e);
67+
throw e;
6868
}
6969
}
7070

@@ -92,7 +92,7 @@ public List<OrderCompleteResponseDTO> purchaseProduct(UserEntity userInfo, Order
9292

9393
return orderResult(orders);
9494
} catch (Exception e) {
95-
throw new RuntimeException("주문 처리 실패", e);
95+
throw e;
9696
}
9797
}
9898

@@ -117,7 +117,7 @@ public OrderInfoResponseDTO orderSuccess(Long orderId) {
117117

118118
return orderInfo;
119119
} catch (Exception e) {
120-
throw new RuntimeException("주문 성공 처리 중 오류 발생", e);
120+
throw e;
121121
}
122122
}
123123

src/main/java/PodoeMarket/podoemarket/product/controller/ProductController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public ResponseEntity<?> allProducts(@AuthenticationPrincipal UserEntity userInf
3333
try{
3434
final ScriptListResponseDTO lists = new ScriptListResponseDTO(
3535
productService.getPlayList(0, userInfo, PlayType.LONG, 10, sortType),
36-
productService.getPlayList(0, userInfo, PlayType.SHORT, 20, sortType)
36+
productService.getPlayList(0, userInfo, PlayType.SHORT, 10, sortType)
3737
);
3838

3939
return ResponseEntity.ok().body(lists);

src/main/java/PodoeMarket/podoemarket/product/service/ProductService.java

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,9 @@ public List<ScriptListResponseDTO.ProductListDTO> getPlayList(int page, UserEnti
5959
try {
6060
Sort sort = createSort(sortType);
6161
final Pageable pageable = PageRequest.of(page, pageSize, sort);
62-
final List<ProductEntity> plays = productRepo.findAllByPlayTypeAndChecked(playType, ProductStatus.PASS, pageable);
62+
final List<ProductEntity> plays = productRepo.findAllValidPlays(playType, ProductStatus.PASS, pageable);
6363

6464
return plays.stream()
65-
.filter(play -> play.getUser() != null)
66-
.filter(play -> play.getScript() || play.getPerformance())
67-
.filter(play -> !play.getIsDelete())
6865
.map(play -> {
6966
ScriptListResponseDTO.ProductListDTO productListDTO = new ScriptListResponseDTO.ProductListDTO();
7067
String encodedScriptImage = play.getImagePath() != null ? bucketURL + URLEncoder.encode(play.getImagePath(), StandardCharsets.UTF_8) : "";
@@ -86,15 +83,15 @@ public List<ScriptListResponseDTO.ProductListDTO> getPlayList(int page, UserEnti
8683
return productListDTO;
8784
}).toList();
8885
} catch (Exception e) {
89-
throw new RuntimeException("상품 목록 조회 실패", e);
86+
throw e;
9087
}
9188
}
9289

9390
public ProductEntity getProduct(UUID id) {
9491
try {
9592
return productRepo.findById(id);
9693
} catch (Exception e) {
97-
throw new RuntimeException("상품 조회 실패", e);
94+
throw e;
9895
}
9996
}
10097

@@ -136,37 +133,33 @@ public ScriptDetailResponseDTO getScriptDetailInfo(UserEntity userInfo, UUID pro
136133
.viewCount(viewCountService.getProductViewCount(productId)) // 총 조회수
137134
.build();
138135
} catch (Exception e) {
139-
throw new RuntimeException("상품 상세 정보 조회 실패", e);
136+
throw e;
140137
}
141138

142139
}
143140

144141
// 트랜잭션 없는 PDF 처리 메서드
145142
public ResponseEntity<StreamingResponseBody> generateScriptPreview(String preSignedURL, int pagesToExtract) {
146-
try {
147-
// PDF 처리는 트랜잭션과 분리
148-
PdfExtractionResult result = processPreviewPdf(preSignedURL, pagesToExtract);
149-
150-
StreamingResponseBody streamingResponseBody = outputStream -> {
151-
try (InputStream extractedPdfStream = new ByteArrayInputStream(result.getExtractedPdfBytes())) {
152-
byte[] buffer = new byte[8192];
153-
int bytesRead;
154-
while ((bytesRead = extractedPdfStream.read(buffer)) != -1) {
155-
outputStream.write(buffer, 0, bytesRead);
156-
outputStream.flush();
157-
}
158-
} catch (Exception e) {
159-
log.error("PDF 스트리밍 중 오류 발생: {}", e.getMessage());
143+
// PDF 처리는 트랜잭션과 분리
144+
PdfExtractionResult result = processPreviewPdf(preSignedURL, pagesToExtract);
145+
146+
StreamingResponseBody streamingResponseBody = outputStream -> {
147+
try (InputStream extractedPdfStream = new ByteArrayInputStream(result.getExtractedPdfBytes())) {
148+
byte[] buffer = new byte[8192];
149+
int bytesRead;
150+
while ((bytesRead = extractedPdfStream.read(buffer)) != -1) {
151+
outputStream.write(buffer, 0, bytesRead);
152+
outputStream.flush();
160153
}
161-
};
154+
} catch (Exception e) {
155+
throw new RuntimeException("PDF 스트리밍 중 오류 발생");
156+
}
157+
};
162158

163-
return ResponseEntity.ok()
164-
.contentType(MediaType.APPLICATION_PDF)
165-
.header("X-Total-Pages", String.valueOf(result.getTotalPageCount()))
166-
.body(streamingResponseBody);
167-
} catch (Exception e) {
168-
throw new RuntimeException("스크립트 미리보기 생성 실패", e);
169-
}
159+
return ResponseEntity.ok()
160+
.contentType(MediaType.APPLICATION_PDF)
161+
.header("X-Total-Pages", String.valueOf(result.getTotalPageCount()))
162+
.body(streamingResponseBody);
170163
}
171164

172165
@Transactional
@@ -185,7 +178,7 @@ public String toggleLike(UserEntity userInfo, UUID productId) {
185178
return "like";
186179
}
187180
} catch (Exception e) {
188-
throw new RuntimeException("좋아요 처리 실패", e);
181+
throw e;
189182
}
190183
}
191184

@@ -199,7 +192,7 @@ public ResponseEntity<StreamingResponseBody> generateFullScriptDirect(String pre
199192
outputStream.flush();
200193
}
201194
} catch (Exception e) {
202-
log.error("PDF 스트리밍 중 오류 발생: {}", e.getMessage());
195+
throw new RuntimeException("PDF 스트리밍 중 오류 발생");
203196
}
204197
};
205198

@@ -215,8 +208,6 @@ public boolean getLikeStatus(final UserEntity userInfo, final UUID productId) {
215208

216209
return productLikeRepo.existsByUserAndProductId(userInfo, productId);
217210
} catch (Exception e) {
218-
log.error("좋아요 상태 확인 중 오류 발생: userId={}, productId={}, error={}",
219-
userInfo != null ? userInfo.getId() : "null", productId, e.getMessage());
220211
return false; // 오류 발생 시 좋아요하지 않은 것으로 처리
221212
}
222213
}

0 commit comments

Comments
 (0)