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

feat : 발급 티켓 가져오기 API 작성 (#73) #73

Merged
merged 6 commits into from
Jan 11, 2023

Conversation

sanbonai06
Copy link
Member

@sanbonai06 sanbonai06 commented Jan 10, 2023

개요

작업사항

  • 발급된 티켓 가져오기 API 작성했습니다.
  • 아직 이벤트 쪽과 티켓 상품 쪽 생성 로직이 확실치 않아 갖고올 데이터는 피그마 보고 임의로 진행했습니다.
  • 처음 구상은 도메인 서비스에서 찾은 도메인 객체 반환 => UseCase에서 DTO 매핑 으로 하려 했으나
  • 지연 로딩을 쓰는 과정에서 Transaction이 끝난 시점 즉, UseCase에서 DTO로 매핑이 불가능하여 부득이하게 UseCase / DomainService간에 DTO를 통해 반환값을 갖게 되었습니다.
  • UseCase에서 각 도메인으로 찾는 로직을 모두 호출할 지, 아니면 지금처럼 지연로딩 정책을 사용하면서 DTO로 갈 지 고민입니다.
  • 응답값 예시
GET /api/v1/issuedTickets/1
{
  "success": true,
  "status": 200,
  "data": {
    "issuedTicketInfo": {
      "issuedTicketId": 1,
      "issuedTicketNo": "T10000001",
      "uuid": "sfasdfasfasdfsdfaf",
      "ticketName": "test",
      "ticketAccount": 4000
    },
    "eventInfo": {
      "eventName": "test",
      "posterImage": "test",
      "startAt": "2023-01-11 12:10:08",
      "placeName": "test",
      "eventStatus": "PREPARING"
    },
    "userName": "김민준"
  },
  "timeStamp": "2023-01-11T00:37:55.274378"
}
  • 에러 예시
NotFound
{
  "success": false,
  "status": 404,
  "code": "IssuedTicket-404-1",
  "reason": "IssuedTicket Not Found",
  "timeStamp": "2023-01-11T00:54:43.24574",
  "path": "http://localhost:8080/api/v1/issuedTickets/2"
}
Forbbiden
{
  "success": false,
  "status": 403,
  "code": "IssuedTicket-403-1",
  "reason": "IssuedTicket User Not Matched",
  "timeStamp": "2023-01-11T00:55:38.883135",
  "path": "http://localhost:8080/api/v1/issuedTickets/1"
}
  • 테스트는 연관 객체들 확정되면 작성하겠습니당.

변경로직

  • 내용을 적어주세요.

@sanbonai06 sanbonai06 added For: API [이슈 대상] 외부 API Status: WIP [이슈 상태] 작업 중 (임시 PR 등) Type: Feature [이슈 목적] 새로운 기능 추가 labels Jan 10, 2023
@sanbonai06 sanbonai06 requested a review from ImNM as a code owner January 10, 2023 12:06
@sanbonai06 sanbonai06 self-assigned this Jan 10, 2023
@sanbonai06 sanbonai06 removed the Status: WIP [이슈 상태] 작업 중 (임시 PR 등) label Jan 10, 2023
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 122 Code Smells

9.6% 9.6% Coverage
0.0% 0.0% Duplication

Copy link
Member

@ImNM ImNM left a comment

Choose a reason for hiding this comment

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

굿입니다요!

Comment on lines +25 to +36
*/
public RetrieveIssuedTicketDetailResponse execute(Long issuedTicketId) {
Long currentUserId = SecurityUtils.getCurrentUserId();
/*
Todo: 지연 로딩 트랜잭션 이슈 때문에 일단은 DTO로 감싸서 올림. But, 이게 최선일까? 고민해보자.
*/
IssuedTicketDTO issuedTicket =
issuedTicketDomainService.retrieveIssuedTicket(currentUserId, issuedTicketId);
User user = userDomainService.retrieveUser(currentUserId);
return new RetrieveIssuedTicketDetailResponse(issuedTicket, user);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

usecase 에서도 트랜잭션 걸어두됩니다요!

Copy link
Member Author

Choose a reason for hiding this comment

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

그럴까 말까 하다가 트랜잭션 전파 신경쓰기 귀찮아서 안했는데 그게 더 좋은 방법인거 같네요!

Copy link
Member

Choose a reason for hiding this comment

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

레디슨 락 쓸때만 주의하면 되긴하는데
저도 레디슨 락때문에 고생중인데 해결해서 함 올려볼게요

다른방법으론 쿼리용 레포지토리를 만들어서
페치조인 때리고 올려오는 방법이있을거같긴해요
뷰를 위한 쿼리로 cqrs 비슷하게 커맨드랑 쿼리를 구분해서

Copy link
Member Author

Choose a reason for hiding this comment

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

페치조인도 쓰고 요즘은 QueryDsl 많이 사용한다 하더라구요 나중에 복잡해지면 설정해서 사용해보겠습니당

Copy link
Member

@kim-wonjin kim-wonjin left a comment

Choose a reason for hiding this comment

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

굿굿 티켓상품 짤때 코드 참고해가며 맞춰볼게용✌️

@sanbonai06 sanbonai06 changed the title feat : 발급 티켓 가져오기 API 작성 (#72) feat : 발급 티켓 가져오기 API 작성 (#73) Jan 11, 2023
@sanbonai06 sanbonai06 merged commit 3704aff into dev Jan 11, 2023
@sanbonai06 sanbonai06 deleted the feature/72-issued-ticket-read branch January 11, 2023 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🚀 [feature] 예매 티켓 상세 API 개발 (발급 티켓 상세)
3 participants