-
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 #39 from GoogleEyes-ewha/develop
develop 브랜치 → main 브랜치 병합
- Loading branch information
Showing
74 changed files
with
3,156 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
FROM openjdk:17-jdk | ||
ARG JAR_FILE=build/libs/hearo-0.0.1-SNAPSHOT.jar | ||
COPY ${JAR_FILE} /app.jar | ||
COPY src/main/resources/keystore.p12 keystore.p12 | ||
|
||
ENTRYPOINT ["java","-jar","/app.jar"] | ||
ENTRYPOINT ["java","-jar","/app.jar"] |
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
130 changes: 130 additions & 0 deletions
130
src/main/java/com/gdsc/hearo/domain/item/controller/ItemController.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,130 @@ | ||
package com.gdsc.hearo.domain.item.controller; | ||
|
||
import com.gdsc.hearo.domain.item.dto.*; | ||
import com.gdsc.hearo.domain.item.service.ItemService; | ||
import com.gdsc.hearo.global.common.BaseResponse; | ||
import com.gdsc.hearo.global.common.BaseResponseStatus; | ||
import com.gdsc.hearo.global.security.CustomUserDetails; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/item") | ||
public class ItemController { | ||
|
||
private final ItemService itemService; | ||
|
||
|
||
@Autowired | ||
public ItemController(ItemService itemService){ | ||
this.itemService = itemService; | ||
} | ||
|
||
/*@GetMapping("/{categoryId}") | ||
public ResponseEntity<BaseResponse<Map<String, Object>>> getItemByCategory(@PathVariable(name = "categoryId") Long categoryId) { | ||
BaseResponse<Map<String, Object>> response; | ||
try { | ||
List<CategoryResponseDto> itemList = itemService.getItemByCategory(categoryId); | ||
Map<String, Object> result = new HashMap<>(); | ||
if (itemList.isEmpty()) { | ||
response = new BaseResponse<>(BaseResponseStatus.NO_CONTENT, null); | ||
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(response); | ||
} | ||
result.put("itemCount", itemList.size()); | ||
result.put("itemList", itemList); | ||
response = new BaseResponse<>(BaseResponseStatus.SUCCESS, result); | ||
return ResponseEntity.ok(response); | ||
} catch (Exception e) { | ||
// 기타 예외에 대한 기본 처리 | ||
response = new BaseResponse<>(BaseResponseStatus.INTERNAL_SERVER_ERROR, null); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); | ||
} | ||
}*/ | ||
@GetMapping("/category/{categoryId}") | ||
public ResponseEntity<BaseResponse<CategoryResponseDto>> getItemByCategory(@PathVariable(name = "categoryId") Long categoryId) { | ||
BaseResponse<CategoryResponseDto> response; | ||
|
||
try { | ||
List<ItemDto> itemList = itemService.getItemByCategory(categoryId); | ||
CategoryResponseDto result = CategoryResponseDto.builder() | ||
.itemCount(itemList.size()) | ||
.list(itemList) | ||
.build(); | ||
|
||
if (itemList.isEmpty()) { | ||
response = new BaseResponse<>(BaseResponseStatus.NO_CONTENT, null); | ||
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(response); | ||
} | ||
|
||
response = new BaseResponse<>(BaseResponseStatus.SUCCESS,result); | ||
return ResponseEntity.ok(response); | ||
|
||
} catch (Exception e) { | ||
// 기타 예외에 따른 기본 처리 | ||
response = new BaseResponse<>(BaseResponseStatus.INTERNAL_SERVER_ERROR, null); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); | ||
} | ||
} | ||
|
||
|
||
@GetMapping | ||
public ResponseEntity<BaseResponse<SearchResponseDto>> getItemByKeyword( | ||
@RequestParam(name = "keyword") String keyword) { | ||
BaseResponse<SearchResponseDto> response; | ||
|
||
try { | ||
List<ItemDto> itemList = itemService.getItemByKeyword(keyword); | ||
SearchResponseDto result = SearchResponseDto.builder() | ||
.keyword(keyword) | ||
.itemCount(itemList.size()) | ||
.list(itemList) | ||
.build(); | ||
|
||
if (itemList.isEmpty()) { | ||
response = new BaseResponse<>(BaseResponseStatus.NO_CONTENT, null); | ||
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(response); | ||
} | ||
|
||
response = new BaseResponse<>(BaseResponseStatus.SUCCESS, result); | ||
return ResponseEntity.ok(response); | ||
|
||
} catch (Exception e) { | ||
// Handle exceptions | ||
response = new BaseResponse<>(BaseResponseStatus.INTERNAL_SERVER_ERROR, null); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); | ||
} | ||
} | ||
|
||
@GetMapping("/{itemId}") | ||
public ResponseEntity<BaseResponse<ItemDetailResponseDto>> getItemDetailById( | ||
@PathVariable(name = "itemId") Long itemId, | ||
@AuthenticationPrincipal CustomUserDetails userDetails) { | ||
BaseResponse<ItemDetailResponseDto> response; | ||
|
||
try { | ||
Long userId = userDetails != null? userDetails.getMember().getMemberId():null; | ||
ItemDetailResponseDto itemDetailResponse = itemService.getItemDetailById(itemId,userId); | ||
|
||
response = new BaseResponse<>(BaseResponseStatus.SUCCESS, itemDetailResponse); | ||
return ResponseEntity.ok(response); | ||
|
||
}catch (Exception e) { | ||
// Handle exceptions | ||
response = new BaseResponse<>(BaseResponseStatus.INTERNAL_SERVER_ERROR, null); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
68 changes: 68 additions & 0 deletions
68
src/main/java/com/gdsc/hearo/domain/item/controller/ItemTtsController.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,68 @@ | ||
package com.gdsc.hearo.domain.item.controller; | ||
|
||
import com.gdsc.hearo.domain.item.dto.ItemTtsFileResponseDto; | ||
import com.gdsc.hearo.domain.item.dto.ItemTtsRequestDto; | ||
import com.gdsc.hearo.domain.item.dto.ItemTtsResponseDto; | ||
import com.gdsc.hearo.domain.item.service.ItemTtsService; | ||
import com.gdsc.hearo.domain.review.dto.ReviewTTSDto; | ||
import com.gdsc.hearo.global.common.BaseException; | ||
import com.gdsc.hearo.global.common.BaseResponse; | ||
import com.gdsc.hearo.global.common.BaseResponseStatus; | ||
import com.gdsc.hearo.global.common.VoiceType; | ||
import com.gdsc.hearo.global.security.CustomUserDetails; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("item") | ||
public class ItemTtsController { | ||
|
||
private final ItemTtsService itemTtsService; | ||
|
||
@Autowired | ||
public ItemTtsController(ItemTtsService itemTtsService){ | ||
this.itemTtsService = itemTtsService; | ||
} | ||
|
||
//[post]상품 음성 파일 저장 | ||
@PostMapping("/tts/{itemId}") | ||
public BaseResponse<?> postItemTTSFile(@AuthenticationPrincipal CustomUserDetails user, @PathVariable(name="itemId") Long itemId, @RequestBody ItemTtsRequestDto request) { | ||
try { | ||
if (user != null) { // 로그인 한 경우 | ||
// 서비스를 호출하여 음성 파일 저장 | ||
ItemTtsResponseDto result = itemTtsService.saveItemTTS(user, itemId, request); | ||
|
||
return new BaseResponse<>(BaseResponseStatus.SUCCESS, result); | ||
|
||
} else { // 로그인하지 않은 경우 | ||
ItemTtsResponseDto result = itemTtsService.saveItemTTS(null, itemId, request); | ||
|
||
return new BaseResponse<>(BaseResponseStatus.SUCCESS, "음성 파일이 저장되었습니다."); | ||
} | ||
} catch (BaseException e) { | ||
return new BaseResponse<>(e.getStatus()); | ||
} | ||
} | ||
|
||
// 상품 음성 파일 조회 | ||
@GetMapping("/tts/{itemId}") | ||
public BaseResponse<ItemTtsFileResponseDto> getItemTts(@AuthenticationPrincipal CustomUserDetails user, | ||
@PathVariable(name = "itemId") Long itemId) { | ||
|
||
try{ | ||
if (user != null) { // 로그인 한 경우 | ||
ItemTtsFileResponseDto result = itemTtsService.getItemTts(user, itemId); | ||
return new BaseResponse<>(BaseResponseStatus.SUCCESS, result); | ||
} | ||
else{ | ||
ItemTtsFileResponseDto result = itemTtsService.getItemTts(null,itemId); | ||
return new BaseResponse<>(BaseResponseStatus.SUCCESS, result); | ||
} | ||
}catch(Exception e){ | ||
e.printStackTrace(); | ||
return null; // 예외처리 이상함.. | ||
} | ||
} | ||
} |
Oops, something went wrong.