Skip to content

Commit

Permalink
Merge branch 'feat/DEV-299' into feat/DEV-312
Browse files Browse the repository at this point in the history
  • Loading branch information
dla0510 committed Jun 11, 2024
2 parents e763745 + 6781e55 commit f3fb5f5
Show file tree
Hide file tree
Showing 39 changed files with 855 additions and 252 deletions.
24 changes: 23 additions & 1 deletion docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,26 @@ services:
- '--collation-server=utf8mb4_unicode_ci'
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_DATABASE: ${DB_DATABASE}

redis:
image: redis:6.2-alpine
ports:
- ${REDIS_PORT}:6379
environment:
REDIS_PASSWORD: '${REDIS_PASSWORD}'
command: redis-server /usr/local/etc/redis/redis.conf --save 20 1 --loglevel warning --requirepass $REDIS_PASSWORD
volumes:
- ./db/redis/data:/data
- ./redis.conf:/usr/local/etc/redis/redis.conf
restart: always

nginx:
image: nginx:latest
restart: unless-stopped
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- 8888:8888
volumes:
- ./nginx.dev.conf:/etc/nginx/nginx.conf
12 changes: 0 additions & 12 deletions docker-compose.nginx.yml

This file was deleted.

18 changes: 17 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ services:
environment:
SPRING_CONFIG_LOCATION: file:///etc/additional.yml
volumes:
- ./src/main/resources/application-prod.yml:/etc/additional.yml
- type: bind
source: ./src/main/resources/application-prod.yml
target: /etc/additional.yml


nginx:
image: nginx:latest
Expand All @@ -27,6 +30,7 @@ services:
- was
networks:
- common-network

mysql:
image: mysql:8.0.33
expose:
Expand All @@ -43,6 +47,7 @@ services:
restart: unless-stopped
networks:
- common-network

redis:
image: redis:6.2-alpine
expose:
Expand All @@ -68,6 +73,17 @@ services:
networks:
- common-network

client:
image: tiketeer-fe
expose:
- 80
depends_on:
- was
- waiting
restart: unless-stopped
networks:
- common-network

networks:
common-network:
driver: bridge
Expand Down
12 changes: 0 additions & 12 deletions docker-compose.redis.yml

This file was deleted.

10 changes: 9 additions & 1 deletion nginx.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ http {
keepalive 10;
}

upstream client {
zone upstream 64K;
server host.docker.internal:3000 fail_timeout=5s;
keepalive 10;
}

server {
listen 8888;
server_name tiketeer;

location / {
return 200 "NginX Health Check";
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Connection "";
}

location /api/waiting {
Expand Down
10 changes: 9 additions & 1 deletion nginx.prod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ http {
keepalive 10;
}

upstream client {
zone upstream 64K;
server client:80 fail_timeout=5s;
keepalive 10;
}

server {
listen 8888;
server_name tiketeer;

location / {
return 200 "NginX Health Check";
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Connection "";
}

location /api/waiting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
import com.tiketeer.Tiketeer.auth.SecurityContextHelper;
import com.tiketeer.Tiketeer.domain.member.controller.dto.ChargePointRequestDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.ChargePointResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.GetMemberPurchasesResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.GetMemberAllPurchasesResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.GetMemberPurchaseResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.GetMemberResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.GetMemberTicketingSalesResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.MemberRegisterRequestDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.MemberRegisterResponseDto;
import com.tiketeer.Tiketeer.domain.member.controller.dto.ResetPasswordRequestDto;
import com.tiketeer.Tiketeer.domain.member.usecase.ChargeMemberPointUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.DeleteMemberUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.GetMemberPurchasesUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.GetMemberAllPurchasesUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.GetMemberPurchaseUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.GetMemberTicketingSalesUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.GetMemberUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.MemberRegisterUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.ResetPasswordUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.SendPasswordChangeEmailUseCase;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.DeleteMemberCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberAllPurchasesCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchasesCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchaseCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberTicketingSalesCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.MemberRegisterCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.SendPwdChangeEmailCommandDto;
Expand All @@ -49,7 +52,8 @@ public class MemberController {
private final ChargeMemberPointUseCase chargeMemberPointUseCase;
private final GetMemberTicketingSalesUseCase getMemberTicketingSalesUseCase;
private final GetMemberUseCase getMemberUseCase;
private final GetMemberPurchasesUseCase getMemberPurchasesUseCase;
private final GetMemberAllPurchasesUseCase getMemberAllPurchasesUseCase;
private final GetMemberPurchaseUseCase getMemberPurchasesUseCase;
private final ResetPasswordUseCase resetPasswordUseCase;
private final SendPasswordChangeEmailUseCase sendPasswordChangeEmailUseCase;
private final DeleteMemberUseCase deleteMemberUseCase;
Expand All @@ -59,7 +63,8 @@ public class MemberController {
public MemberController(MemberRegisterUseCase memberRegisterUseCase,
ChargeMemberPointUseCase chargeMemberPointUseCase, ResetPasswordUseCase resetPasswordUseCase,
GetMemberTicketingSalesUseCase getMemberTicketingSalesUseCase,
GetMemberUseCase getMemberUseCase, GetMemberPurchasesUseCase getMemberPurchasesUseCase,
GetMemberUseCase getMemberUseCase, GetMemberAllPurchasesUseCase getMemberAllPurchasesUseCase,
GetMemberPurchaseUseCase getMemberPurchasesUseCase,
SendPasswordChangeEmailUseCase sendPasswordChangeEmailUseCase,
DeleteMemberUseCase deleteMemberUseCase,
SecurityContextHelper securityContextHelper) {
Expand All @@ -68,6 +73,7 @@ public MemberController(MemberRegisterUseCase memberRegisterUseCase,
this.getMemberTicketingSalesUseCase = getMemberTicketingSalesUseCase;
this.getMemberUseCase = getMemberUseCase;
this.resetPasswordUseCase = resetPasswordUseCase;
this.getMemberAllPurchasesUseCase = getMemberAllPurchasesUseCase;
this.getMemberPurchasesUseCase = getMemberPurchasesUseCase;
this.sendPasswordChangeEmailUseCase = sendPasswordChangeEmailUseCase;
this.deleteMemberUseCase = deleteMemberUseCase;
Expand Down Expand Up @@ -105,13 +111,23 @@ public ResponseEntity<ApiResponse<ChargePointResponseDto>> chargePoint(@PathVari
}

@GetMapping("/{memberId}/purchases")
public ResponseEntity<ApiResponse<List<GetMemberPurchasesResponseDto>>> getMemberPurchases(
public ResponseEntity<ApiResponse<List<GetMemberAllPurchasesResponseDto>>> getMemberAllPurchases(
@PathVariable UUID memberId) {
var email = securityContextHelper.getEmailInToken();
var results = getMemberPurchasesUseCase.getMemberPurchases(
GetMemberPurchasesCommandDto.builder().memberEmail(email).build());
var results = getMemberAllPurchasesUseCase.getMemberPurchases(
GetMemberAllPurchasesCommandDto.builder().memberEmail(email).build());
var responseBody = ApiResponse.wrap(
results.stream().map(GetMemberPurchasesResponseDto::convertFromDto).toList());
results.stream().map(GetMemberAllPurchasesResponseDto::convertFromDto).toList());
return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}

@GetMapping("/{memberId}/purchases/{purchaseId}")
public ResponseEntity<ApiResponse<GetMemberPurchaseResponseDto>> getMemberPurchase(
@PathVariable UUID memberId, @PathVariable UUID purchaseId) {
var email = securityContextHelper.getEmailInToken();
var result = getMemberPurchasesUseCase.getMemberPurchases(
GetMemberPurchaseCommandDto.builder().memberEmail(email).purchaseId(purchaseId).build());
var responseBody = ApiResponse.wrap(GetMemberPurchaseResponseDto.convertFromDto(result));
return ResponseEntity.status(HttpStatus.OK).body(responseBody);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.tiketeer.Tiketeer.domain.member.controller.dto;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberAllPurchasesResultDto;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public final class GetMemberAllPurchasesResponseDto {
private final UUID purchaseId;
private final UUID ticketingId;
private final String title;
private final LocalDateTime eventTime;
private final LocalDateTime createdAt;
private final String category;
private final String thumbnailPath;
private final List<GetMemberAllPurchasesResultDto.PurchaseItem> purchaseItems;

@Builder
public GetMemberAllPurchasesResponseDto(UUID purchaseId, UUID ticketingId, String title,
LocalDateTime eventTime, LocalDateTime createdAt, String category, String thumbnailPath,
List<GetMemberAllPurchasesResultDto.PurchaseItem> purchaseItems) {
this.purchaseId = purchaseId;
this.ticketingId = ticketingId;
this.title = title;
this.eventTime = eventTime;
this.createdAt = createdAt;
this.category = category;
this.thumbnailPath = thumbnailPath;
this.purchaseItems = purchaseItems;
}

public static GetMemberAllPurchasesResponseDto convertFromDto(GetMemberAllPurchasesResultDto dto) {
return GetMemberAllPurchasesResponseDto.builder()
.purchaseId(dto.getPurchaseId())
.ticketingId(dto.getTicketingId())
.title(dto.getTitle())
.eventTime(dto.getEventTime())
.createdAt(dto.getCreatedAt())
.category(dto.getCategory())
.thumbnailPath(dto.getThumbnailPath())
.purchaseItems(dto.getPurchaseItems())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import java.util.List;
import java.util.UUID;

import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchasesResultDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchaseResultDto;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public final class GetMemberPurchasesResponseDto {
public final class GetMemberPurchaseResponseDto {
private final UUID purchaseId;
private final UUID ticketingId;
private final String title;
Expand All @@ -21,13 +21,13 @@ public final class GetMemberPurchasesResponseDto {
private final LocalDateTime createdAt;
private final String category;
private final int runningMinute;
private final List<GetMemberPurchasesResultDto.PurchaseItem> purchaseItems;
private final List<GetMemberPurchaseResultDto.PurchaseItem> purchaseItems;

@Builder
public GetMemberPurchasesResponseDto(UUID purchaseId, UUID ticketingId, String title, String location,
public GetMemberPurchaseResponseDto(UUID purchaseId, UUID ticketingId, String title, String location,
LocalDateTime eventTime, LocalDateTime createdAt, String category,
int runningMinute,
List<GetMemberPurchasesResultDto.PurchaseItem> purchaseItems) {
List<GetMemberPurchaseResultDto.PurchaseItem> purchaseItems) {
this.purchaseId = purchaseId;
this.ticketingId = ticketingId;
this.title = title;
Expand All @@ -39,8 +39,8 @@ public GetMemberPurchasesResponseDto(UUID purchaseId, UUID ticketingId, String t
this.purchaseItems = purchaseItems;
}

public static GetMemberPurchasesResponseDto convertFromDto(GetMemberPurchasesResultDto dto) {
return GetMemberPurchasesResponseDto.builder()
public static GetMemberPurchaseResponseDto convertFromDto(GetMemberPurchaseResultDto dto) {
return GetMemberPurchaseResponseDto.builder()
.purchaseId(dto.getPurchaseId())
.ticketingId(dto.getTicketingId())
.title(dto.getTitle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

import com.tiketeer.Tiketeer.domain.member.exception.MemberNotFoundException;
import com.tiketeer.Tiketeer.domain.member.repository.MemberRepository;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchasesCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchasesResultDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberAllPurchasesCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberAllPurchasesResultDto;
import com.tiketeer.Tiketeer.domain.purchase.repository.PurchaseRepository;

@Service
@Transactional(readOnly = true)
public class GetMemberPurchasesUseCase {
public class GetMemberAllPurchasesUseCase {
private final MemberRepository memberRepository;
private final PurchaseRepository purchaseRepository;

@Autowired
public GetMemberPurchasesUseCase(MemberRepository memberRepository, PurchaseRepository purchaseRepository) {
public GetMemberAllPurchasesUseCase(MemberRepository memberRepository, PurchaseRepository purchaseRepository) {
this.memberRepository = memberRepository;
this.purchaseRepository = purchaseRepository;
}

public List<GetMemberPurchasesResultDto> getMemberPurchases(GetMemberPurchasesCommandDto command) {
public List<GetMemberAllPurchasesResultDto> getMemberPurchases(GetMemberAllPurchasesCommandDto command) {
var member = memberRepository.findByEmail(command.getMemberEmail()).orElseThrow(MemberNotFoundException::new);
var results = purchaseRepository.findWithTicketingByMember(member);
return results.stream().map(GetMemberPurchasesResultDto::new).toList();
return results.stream().map(GetMemberAllPurchasesResultDto::new).toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.tiketeer.Tiketeer.domain.member.usecase;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tiketeer.Tiketeer.domain.member.exception.MemberNotFoundException;
import com.tiketeer.Tiketeer.domain.member.repository.MemberRepository;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchaseCommandDto;
import com.tiketeer.Tiketeer.domain.member.usecase.dto.GetMemberPurchaseResultDto;
import com.tiketeer.Tiketeer.domain.purchase.exception.PurchaseNotFoundException;
import com.tiketeer.Tiketeer.domain.purchase.repository.PurchaseRepository;

@Service
@Transactional(readOnly = true)
public class GetMemberPurchaseUseCase {
private final MemberRepository memberRepository;
private final PurchaseRepository purchaseRepository;

@Autowired
public GetMemberPurchaseUseCase(MemberRepository memberRepository, PurchaseRepository purchaseRepository) {
this.memberRepository = memberRepository;
this.purchaseRepository = purchaseRepository;
}

public GetMemberPurchaseResultDto getMemberPurchases(GetMemberPurchaseCommandDto command) {
var member = memberRepository.findByEmail(command.getMemberEmail()).orElseThrow(MemberNotFoundException::new);
var results = purchaseRepository.findWithTicketingByMember(member);
if (results.isEmpty()) {
throw new PurchaseNotFoundException();
}
return new GetMemberPurchaseResultDto(results.getFirst());
}
}
Loading

0 comments on commit f3fb5f5

Please sign in to comment.