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

[refactor] schedule, staff, cast 수정 DTO 각각을 add, delete,update DTO로 세분화 #177

Closed
5 tasks done
hoonyworld opened this issue Aug 19, 2024 · 0 comments · Fixed by #184
Closed
5 tasks done

Comments

@hoonyworld
Copy link
Member

hoonyworld commented Aug 19, 2024

Feature Issue 📌

문제 상황

ID 생성의 책임이 클라이언트에 있음

  • 공연 1에 회차를 1개 더 추가하려고 가정할 때, requestBody로 scheduleId를 줘야하는데, 마지막 회차아이디 + 1을 해서 줘야하는데 그걸 클라이언트에서는 알 수 없습니다.
  • 또한, 여러 클라이언트가 동시에 새로운 회차를 추가하려고 할 때, 클라이언트들이 서버의 최신 상태를 알 수 없으므로 중복된 ID를 생성하거나, 올바르지 않은 ID를 생성할 가능성이 있습니다.
  • schedule뿐만이 아닌, cast, staff에서도 동일한 문제가 발생합니다.

ID 생성의 책임을 서버로 이전한다면?

  • requestBody에 회차 아이디를 주지 않고, 서버가 자동으로 autoIncrement로 회차 ID를 생성하는 방법을 도입할 수 있는데, 이러면 회차를 삭제하려고 할 때 회차 ID를 requestBody 지정해주지 못하는 문제가 발생합니다.

회차 추가, 회차 삭제 API를 분리하면 되지 않나요?

  • 현재 프로젝트의 공연 수정 로직 기획은 회차 추가 및 삭제를 버튼 1개로 동시에 수정할 수 있는 방법입니다. 따라서 추가와 삭제를 분리할 수 없습니다.

고안한 방법

  1. UUID 도입
  2. DTO 분리

최종 선택

  • 2번 DTO 분리를 채택하게 되었습니다.
  • 이유는 UUID의 경우 ID 생성의 책임이 클라이언트에 있을 때, 마지막 회차아이디 + 1을 할 필요 없이 UUID를 생성해서 주면 되며 ID 중복문제도 해결이 됩니다.
  • 하지만 schedule, cast, staff의 id를 모두 UUID로 바꿔야 하며, 시간 리소스가 너무 많이 소모가 됩니다.
  • 따라서 기존 PerformanceUpdateRequest와 PerformanceUpdateResponse DTO 내부에 ScheduleUpdateRequest, CastUpdateRequest, StaffUpdateRequest, ScheduleUpdateResponse, CastUpdateResponse, StaffUpdateRespone를 각각 ADD, DELETE, UPDATE 요청 및 응답으로 세분화 하는 방법을 채택하게 되었습니다.
  • 해당 방법을 사용한다면, 시간 리소스도 적으며 ID 생성의 책임을 서버로 이전했을 때, 삭제시에는 DeleteRequests에 id를 넣고, 업데이트시에는 UpdateRequests에 업데이트 하고자 하는 id와 정보들을 넣고, 추가시에는 AddRequests에 추가 정보를 넣고 id를 autoIncrement 하는 방식으로 한다면 문제는 해결됩니다.

Todo ✔️

  • 기존 PerformanceUpdateRequest DTO 내부 ScheduleUpdateRequest, CastUpdateRequest, StaffUpdateRequest DTO 각각을 ADD. DELETE, UPDATE DTO로 세분화
  • 기존 PerformanceUpdateResponse DTO 내부 ScheduleUpdateResponse, CastUpdateResponse, StaffUpdateRespone DTO 각각을 ADD. DELETE, UPDATE DTO로 세분화
  • PerformanceUpdateService에서 추가, 삭제, 업데이트 작업을 각각의 리스트를 통해 처리하도록 수정
  • 예매자가 존재할 시 가격 정보를 수정하지 못하도록 하는 로직 추가
  • 예매자가 존재하지 않을 시 가격 정보를 수정할 수 있도록 하는 로직 추가
@hoonyworld hoonyworld self-assigned this Aug 19, 2024
@hoonyworld hoonyworld changed the title [refactor] 동적 DTO [refactor] shedule, cast, staff DTO 분리 Aug 20, 2024
@hoonyworld hoonyworld changed the title [refactor] shedule, cast, staff DTO 분리 [refactor] schedule, staff, cast 수정 DTO 각각을 add와 delete DTO로 세분화 Aug 20, 2024
hoonyworld added a commit that referenced this issue Aug 21, 2024
@hoonyworld hoonyworld changed the title [refactor] schedule, staff, cast 수정 DTO 각각을 add와 delete DTO로 세분화 [refactor] schedule, staff, cast 수정 DTO 각각을 add, delete,update DTO로 세분화 Aug 21, 2024
hoonyworld added a commit that referenced this issue Aug 21, 2024
hoonyworld added a commit that referenced this issue Aug 22, 2024
… 및 예매자가 존재하지 않을 시 가격정보 업데이트가 가능하도록 리팩토링 (#184)

* [#177] feat(ScheduleAddRequest): 회차 추가 요청 DTO 생성

* [#177] feat(ScheduleDeleteRequest): 회차 삭제 요청 DTO 생성

* [#177] feat(CastAddRequest): 등장인물 추가 요청 DTO 생성

* [#177] feat(CastDeleteRequest): 등장인물 삭제 요청 DTO 생성

* [#177] feat(StaffAddRequest): 스태프 추가 요청 DTO 생성

* [#177] feat(StaffDeleteRequest): 스태프 삭제 요청 DTO 생성

* [#177] feat(ScheduleAddResponse): 회차 추가 응답 DTO 생성

* [#177] feat(ScheduleDeleteResponse): 회차 삭제 응답 DTO 생성

* [#177] feat(CastAddResponse): 등장인물 추가 응답 DTO 생성

* [#177] feat(CastDeleteResponse): 등장인물 삭제 응답 DTO 생성

* [#177] feat(StaffAddResponse): 스태프 추가 응답 DTO 생성

* [#177] feat(StaffDeleteResponse): 스태프 삭제 응답 DTO 생성

* [#177] refactor(PerformanceUpdateRequest): 추가된 요청 DTO필드로 변경

* [#177] refactor(PerformanceUpdateResponse): 추가된 응답 DTO필드로 변경

* [#177] refactor(ScheduleUpdateRequest): 객체로 자료형 변경

* [#177] refactor(PerformanceUpdateRequest): 업데이트 변수 추가

* [#177] refactor(PerformanceUpdateResponse): 업데이트 변수 추가

* [#177] chore(build.gradle): devtools 비활성화

* [#177] refactor(PerformanceUpdateService): 회차, 등장인물, 스태프 추가,삭제,수정이 가능하도록 서비스 로직 변

* [#177] refactor(PerformanceUpdateService): 롬복 라이브러리로 변경

* [#177] refactor: 경로명 변경

* [#177] refactor(PerformanceErrorCode): 회차 추가 3개 초과 시 에러 메시지 추가

* [#177] refactor(ScheduleRepository): 공연 아이디로 회차 개수를 반환하는 메서드 추가

* [#177] refactor(PerformanceUpdateService): 기존 회차 수 + 회차 추가 수가 3 초과시 에러처리 추가

* [#177] refactor(PerformanceUpdateService): 해당 공연의 메이커만 공연 수정이 가능하도록 검증하는 메서드 추가

* [#177] refactor(PerformanceController): Swagger ApiResponse 추가

* [#177] refactor(application-dev.yml): 로그 레벨 속성 추가

* [#177] refactor(Performance): 티켓 가격 업데이트 메서드 추가

* [#177] refactor(PerformanceErrorCode): 변경 티켓 가격이 음수일 시, 예매자가 존재하는데 가격수정을 시도할 때 보여줄 에러 메시지 추가

* [#177] refactor(PerformanceUpdateRequest): ticketPrice 변수 추가

* [#177] refactor(PerformanceUpdateService): 예매자 여부에 따른 티켓 가격 변경 서비스 로직 추가

* [#177] refactor(PerformanceController): ApiResponse 추가

* [#177] refactor(PerformanceController): ApiResponse description 설명 변경
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment