Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAPHY-70 feat: 기기 등록 기능 (관리자) #88

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ services:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci

redis: # Redis 서비스
redis:
image: redis:6.2.4
container_name: saphy-redis-container
restart: always
ports:
- 16379:6379
environment: # 환경 변수 설정
environment:
- REDIS_HOST=${REDIS_HOST}
- REDIS_PASSWORD=${REDIS_PASSWORD}
- REDIS_PORT=${REDIS_PORT}
- REDIS_PASSWORD=${REDIS_PASSWORD} # REDIS 패스워드 설정
- TZ=Asia/Seoul
command: redis-server --requirepass ${REDIS_PASSWORD} --port 16379
command: >
Comment on lines +29 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쉘을 통해 실행하는 명령어로 변경하셨군요!! 더 유연한 방식이라서 좋은 거 같습니당

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 찾아봐야겠습니다

sh -c "redis-server --requirepass ${REDIS_PASSWORD} --port ${REDIS_PORT:-6379}"
24 changes: 15 additions & 9 deletions src/main/java/saphy/saphy/item/presentation/ItemController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ public class ItemController {
@PostMapping("/items/phones")
@Operation(summary = "휴대폰 생성 API", description = "상품을 생성하는 API 입니다.")
public ApiResponse<Void> save(
@RequestPart("request") PhoneCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
@AuthenticationPrincipal CustomUserDetails customUserDetails,
@RequestPart("request") PhoneCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
){
Item item = itemService.savePhone(request);
Member loggedInMember = customUserDetails.getMember();
Item item = itemService.savePhone(loggedInMember, request);
imageService.saveItemImages(multipartFiles, item.getId());

return new ApiResponse<>(ErrorCode.REQUEST_OK);
Expand All @@ -46,10 +48,12 @@ public ApiResponse<Void> save(
@PostMapping("/items/tablets")
@Operation(summary = "태블릿 생성 API", description = "상품을 생성하는 API 입니다.")
public ApiResponse<Void> save(
@RequestPart("request") TabletCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
@AuthenticationPrincipal CustomUserDetails customUserDetails,
@RequestPart("request") TabletCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
) {
Item item = itemService.saveTablet(request);
Member loggedInMember = customUserDetails.getMember();
Item item = itemService.saveTablet(loggedInMember, request);
imageService.saveItemImages(multipartFiles, item.getId());

return new ApiResponse<>(ErrorCode.REQUEST_OK);
Expand All @@ -58,10 +62,12 @@ public ApiResponse<Void> save(
@PostMapping("/items/laptops")
@Operation(summary = "노트북 생성 API", description = "상품을 생성하는 API 입니다.")
public ApiResponse<Void> save(
@RequestPart("request") LaptopCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
@AuthenticationPrincipal CustomUserDetails customUserDetails,
@RequestPart("request") LaptopCreateRequest request,
@RequestPart("imageFiles") List<MultipartFile> multipartFiles
) {
Item item = itemService.saveLaptop(request);
Member loggedInMember = customUserDetails.getMember();
Item item = itemService.saveLaptop(loggedInMember, request);
imageService.saveItemImages(multipartFiles, item.getId());

return new ApiResponse<>(ErrorCode.REQUEST_OK);
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/saphy/saphy/item/service/ItemService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class ItemService {
/**
* 휴대폰
*/
public Item savePhone(PhoneCreateRequest request) {
public Item savePhone(Member member, PhoneCreateRequest request) {
isAdmin(member);

Phone phone = request.toEntity();

return itemRepository.save(phone);
Expand Down Expand Up @@ -69,7 +71,9 @@ public List<ItemResponse> findByDeviceType(String deviceType) {
/**
* 태블릿
*/
public Item saveTablet(TabletCreateRequest request) {
public Item saveTablet(Member member, TabletCreateRequest request) {
isAdmin(member);

Tablet tablet = request.toEntity();

return itemRepository.save(tablet);
Expand Down Expand Up @@ -100,7 +104,9 @@ public List<TabletResponse> findAllTablets() {
/**
* 노트북
*/
public Item saveLaptop(LaptopCreateRequest request) {
public Item saveLaptop(Member member, LaptopCreateRequest request) {
isAdmin(member);

Laptop laptop = request.toEntity();

return itemRepository.save(laptop);
Expand Down
Loading