Skip to content

Commit

Permalink
Merge pull request #86 from onetime-with-members/feature/#82/refactor…
Browse files Browse the repository at this point in the history
…-record

[refactor] : DTO를 Record로 리팩토링한다
  • Loading branch information
bbbang105 authored Oct 21, 2024
2 parents 11091e6 + dbecf1a commit 54d3770
Show file tree
Hide file tree
Showing 50 changed files with 882 additions and 854 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repositories {
dependencies {
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// DB
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/side/onetime/controller/EventController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import side.onetime.dto.EventDto;
import side.onetime.dto.event.request.CreateEventRequest;
import side.onetime.dto.event.response.*;
import side.onetime.global.common.ApiResponse;
import side.onetime.global.common.status.SuccessStatus;
import side.onetime.service.EventService;
Expand All @@ -18,11 +19,11 @@ public class EventController {

// 이벤트 생성 API
@PostMapping
public ResponseEntity<ApiResponse<EventDto.CreateEventResponse>> createEvent(
@RequestBody EventDto.CreateEventRequest createEventRequest,
public ResponseEntity<ApiResponse<CreateEventResponse>> createEvent(
@RequestBody CreateEventRequest createEventRequest,
@RequestHeader(value = "Authorization", required = false) String authorizationHeader) {

EventDto.CreateEventResponse createEventResponse;
CreateEventResponse createEventResponse;
if (authorizationHeader != null) {
createEventResponse = eventService.createEventForAuthenticatedUser(createEventRequest, authorizationHeader);
} else {
Expand All @@ -34,37 +35,37 @@ public ResponseEntity<ApiResponse<EventDto.CreateEventResponse>> createEvent(

// 이벤트 조회 API
@GetMapping("/{event_id}")
public ResponseEntity<ApiResponse<EventDto.GetEventResponse>> getEvent(
public ResponseEntity<ApiResponse<GetEventResponse>> getEvent(
@PathVariable("event_id") String eventId) {

EventDto.GetEventResponse getEventResponse = eventService.getEvent(eventId);
GetEventResponse getEventResponse = eventService.getEvent(eventId);
return ApiResponse.onSuccess(SuccessStatus._GET_EVENT, getEventResponse);
}

// 참여자 조회 API
@GetMapping("/{event_id}/participants")
public ResponseEntity<ApiResponse<EventDto.GetParticipantsResponse>> getParticipants(
public ResponseEntity<ApiResponse<GetParticipantsResponse>> getParticipants(
@PathVariable("event_id") String eventId) {

EventDto.GetParticipantsResponse getParticipantsResponse = eventService.getParticipants(eventId);
GetParticipantsResponse getParticipantsResponse = eventService.getParticipants(eventId);
return ApiResponse.onSuccess(SuccessStatus._GET_PARTICIPANTS, getParticipantsResponse);
}

// 가장 많이 되는 시간 조회 API
@GetMapping("/{event_id}/most")
public ResponseEntity<ApiResponse<List<EventDto.GetMostPossibleTime>>> getMostPossibleTime(
public ResponseEntity<ApiResponse<List<GetMostPossibleTime>>> getMostPossibleTime(
@PathVariable("event_id") String eventId) {

List<EventDto.GetMostPossibleTime> getMostPossibleTimes = eventService.getMostPossibleTime(eventId);
List<GetMostPossibleTime> getMostPossibleTimes = eventService.getMostPossibleTime(eventId);
return ApiResponse.onSuccess(SuccessStatus._GET_MOST_POSSIBLE_TIME, getMostPossibleTimes);
}

// 유저 참여 이벤트 목록 조회 API
@GetMapping("/user/all")
public ResponseEntity<ApiResponse<List<EventDto.GetUserParticipatedEventsResponse>>> getUserParticipatedEvents(
public ResponseEntity<ApiResponse<List<GetUserParticipatedEventsResponse>>> getUserParticipatedEvents(
@RequestHeader("Authorization") String authorizationHeader) {

List<EventDto.GetUserParticipatedEventsResponse> getUserParticipatedEventsResponses = eventService.getUserParticipatedEvents(authorizationHeader);
List<GetUserParticipatedEventsResponse> getUserParticipatedEventsResponses = eventService.getUserParticipatedEvents(authorizationHeader);
return ApiResponse.onSuccess(SuccessStatus._GET_USER_PARTICIPATED_EVENTS, getUserParticipatedEventsResponses);
}

Expand Down
30 changes: 19 additions & 11 deletions src/main/java/side/onetime/controller/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import side.onetime.dto.MemberDto;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import side.onetime.dto.member.request.IsDuplicateRequest;
import side.onetime.dto.member.request.LoginMemberRequest;
import side.onetime.dto.member.request.RegisterMemberRequest;
import side.onetime.dto.member.response.IsDuplicateResponse;
import side.onetime.dto.member.response.LoginMemberResponse;
import side.onetime.dto.member.response.RegisterMemberResponse;
import side.onetime.global.common.ApiResponse;
import side.onetime.global.common.status.SuccessStatus;
import side.onetime.service.MemberService;
Expand All @@ -16,28 +24,28 @@ public class MemberController {

// 멤버 등록 API
@PostMapping("/action-register")
public ResponseEntity<ApiResponse<MemberDto.RegisterMemberResponse>> registerMember(
@RequestBody MemberDto.RegisterMemberRequest registerMemberRequest) {
public ResponseEntity<ApiResponse<RegisterMemberResponse>> registerMember(
@RequestBody RegisterMemberRequest registerMemberRequest) {

MemberDto.RegisterMemberResponse registerMemberResponse = memberService.registerMember(registerMemberRequest);
RegisterMemberResponse registerMemberResponse = memberService.registerMember(registerMemberRequest);
return ApiResponse.onSuccess(SuccessStatus._REGISTER_MEMBER, registerMemberResponse);
}

// 멤버 로그인 API
@PostMapping("/action-login")
public ResponseEntity<ApiResponse<MemberDto.LoginMemberResponse>> loginMember(
@RequestBody MemberDto.LoginMemberRequest loginMemberRequest) {
public ResponseEntity<ApiResponse<LoginMemberResponse>> loginMember(
@RequestBody LoginMemberRequest loginMemberRequest) {

MemberDto.LoginMemberResponse loginMemberResponse = memberService.loginMember(loginMemberRequest);
LoginMemberResponse loginMemberResponse = memberService.loginMember(loginMemberRequest);
return ApiResponse.onSuccess(SuccessStatus._LOGIN_MEMBER, loginMemberResponse);
}

// 이름 중복 확인 API
@PostMapping("/name/action-check")
public ResponseEntity<ApiResponse<MemberDto.IsDuplicateResponse>> isDuplicate(
@RequestBody MemberDto.IsDuplicateRequest isDuplicateRequest) {
public ResponseEntity<ApiResponse<IsDuplicateResponse>> isDuplicate(
@RequestBody IsDuplicateRequest isDuplicateRequest) {

MemberDto.IsDuplicateResponse isDuplicateResponse = memberService.isDuplicate(isDuplicateRequest);
IsDuplicateResponse isDuplicateResponse = memberService.isDuplicate(isDuplicateRequest);
return ApiResponse.onSuccess(SuccessStatus._IS_POSSIBLE_NAME, isDuplicateResponse);
}
}
46 changes: 25 additions & 21 deletions src/main/java/side/onetime/controller/ScheduleController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import side.onetime.dto.ScheduleDto;
import side.onetime.dto.schedule.request.CreateDateScheduleRequest;
import side.onetime.dto.schedule.request.CreateDayScheduleRequest;
import side.onetime.dto.schedule.request.GetFilteredSchedulesRequest;
import side.onetime.dto.schedule.response.PerDateSchedulesResponse;
import side.onetime.dto.schedule.response.PerDaySchedulesResponse;
import side.onetime.global.common.ApiResponse;
import side.onetime.global.common.status.SuccessStatus;
import side.onetime.service.ScheduleService;
Expand All @@ -19,7 +23,7 @@ public class ScheduleController {
// 요일 스케줄 등록 API
@PostMapping("/day")
public ResponseEntity<ApiResponse<SuccessStatus>> createDaySchedules(
@RequestBody ScheduleDto.CreateDayScheduleRequest createDayScheduleRequest,
@RequestBody CreateDayScheduleRequest createDayScheduleRequest,
@RequestHeader(value = "Authorization", required = false) String authorizationHeader) {

if (authorizationHeader != null) {
Expand All @@ -33,7 +37,7 @@ public ResponseEntity<ApiResponse<SuccessStatus>> createDaySchedules(
// 날짜 스케줄 등록 API
@PostMapping("/date")
public ResponseEntity<ApiResponse<SuccessStatus>> createDateSchedules(
@RequestBody ScheduleDto.CreateDateScheduleRequest createDateScheduleRequest,
@RequestBody CreateDateScheduleRequest createDateScheduleRequest,
@RequestHeader(value = "Authorization", required = false) String authorizationHeader) {

if (authorizationHeader != null) {
Expand All @@ -46,77 +50,77 @@ public ResponseEntity<ApiResponse<SuccessStatus>> createDateSchedules(

// 전체 요일 스케줄 조회 API
@GetMapping("/day/{event_id}")
public ResponseEntity<ApiResponse<List<ScheduleDto.PerDaySchedulesResponse>>> getAllDaySchedules(
public ResponseEntity<ApiResponse<List<PerDaySchedulesResponse>>> getAllDaySchedules(
@PathVariable("event_id") String eventId) {

List<ScheduleDto.PerDaySchedulesResponse> perDaySchedulesResponses = scheduleService.getAllDaySchedules(eventId);
List<PerDaySchedulesResponse> perDaySchedulesResponses = scheduleService.getAllDaySchedules(eventId);
return ApiResponse.onSuccess(SuccessStatus._GET_ALL_DAY_SCHEDULES, perDaySchedulesResponses);
}

// 개인 요일 스케줄 조회 API (비로그인)
@GetMapping("/day/{event_id}/{member_id}")
public ResponseEntity<ApiResponse<ScheduleDto.PerDaySchedulesResponse>> getMemberDaySchedules(
public ResponseEntity<ApiResponse<PerDaySchedulesResponse>> getMemberDaySchedules(
@PathVariable("event_id") String eventId,
@PathVariable("member_id") String memberId) {

ScheduleDto.PerDaySchedulesResponse perDaySchedulesResponse = scheduleService.getMemberDaySchedules(eventId, memberId);
PerDaySchedulesResponse perDaySchedulesResponse = scheduleService.getMemberDaySchedules(eventId, memberId);
return ApiResponse.onSuccess(SuccessStatus._GET_MEMBER_DAY_SCHEDULES, perDaySchedulesResponse);
}

// 개인 요일 스케줄 조회 API (로그인)
@GetMapping("/day/{event_id}/user")
public ResponseEntity<ApiResponse<ScheduleDto.PerDaySchedulesResponse>> getUserDaySchedules(
public ResponseEntity<ApiResponse<PerDaySchedulesResponse>> getUserDaySchedules(
@PathVariable("event_id") String eventId,
@RequestHeader(value = "Authorization") String authorizationHeader) {

ScheduleDto.PerDaySchedulesResponse perDaySchedulesResponse = scheduleService.getUserDaySchedules(eventId, authorizationHeader);
PerDaySchedulesResponse perDaySchedulesResponse = scheduleService.getUserDaySchedules(eventId, authorizationHeader);
return ApiResponse.onSuccess(SuccessStatus._GET_USER_DAY_SCHEDULES, perDaySchedulesResponse);
}

// 멤버 필터링 요일 스케줄 조회 API
@GetMapping("/day/action-filtering")
public ResponseEntity<ApiResponse<List<ScheduleDto.PerDaySchedulesResponse>>> getFilteredDaySchedules(
@RequestBody ScheduleDto.GetFilteredSchedulesRequest getFilteredSchedulesRequest) {
public ResponseEntity<ApiResponse<List<PerDaySchedulesResponse>>> getFilteredDaySchedules(
@RequestBody GetFilteredSchedulesRequest getFilteredSchedulesRequest) {

List<ScheduleDto.PerDaySchedulesResponse> perDaySchedulesResponses = scheduleService.getFilteredDaySchedules(getFilteredSchedulesRequest);
List<PerDaySchedulesResponse> perDaySchedulesResponses = scheduleService.getFilteredDaySchedules(getFilteredSchedulesRequest);
return ApiResponse.onSuccess(SuccessStatus._GET_FILTERED_DAY_SCHEDULES, perDaySchedulesResponses);
}

// 전체 날짜 스케줄 조회 API
@GetMapping("/date/{event_id}")
public ResponseEntity<ApiResponse<List<ScheduleDto.PerDateSchedulesResponse>>> getAllDateSchedules(
public ResponseEntity<ApiResponse<List<PerDateSchedulesResponse>>> getAllDateSchedules(
@PathVariable("event_id") String eventId) {

List<ScheduleDto.PerDateSchedulesResponse> perDateSchedulesResponses = scheduleService.getAllDateSchedules(eventId);
List<PerDateSchedulesResponse> perDateSchedulesResponses = scheduleService.getAllDateSchedules(eventId);
return ApiResponse.onSuccess(SuccessStatus._GET_ALL_DATE_SCHEDULES, perDateSchedulesResponses);
}

// 개인 날짜 스케줄 조회 API (비로그인)
@GetMapping("/date/{event_id}/{member_id}")
public ResponseEntity<ApiResponse<ScheduleDto.PerDateSchedulesResponse>> getMemberDateSchedules(
public ResponseEntity<ApiResponse<PerDateSchedulesResponse>> getMemberDateSchedules(
@PathVariable("event_id") String eventId,
@PathVariable("member_id") String memberId) {

ScheduleDto.PerDateSchedulesResponse perDateSchedulesResponse = scheduleService.getMemberDateSchedules(eventId, memberId);
PerDateSchedulesResponse perDateSchedulesResponse = scheduleService.getMemberDateSchedules(eventId, memberId);
return ApiResponse.onSuccess(SuccessStatus._GET_MEMBER_DATE_SCHEDULES, perDateSchedulesResponse);
}

// 개인 날짜 스케줄 조회 API (로그인)
@GetMapping("/date/{event_id}/user")
public ResponseEntity<ApiResponse<ScheduleDto.PerDateSchedulesResponse>> getUserDateSchedules(
public ResponseEntity<ApiResponse<PerDateSchedulesResponse>> getUserDateSchedules(
@PathVariable("event_id") String eventId,
@RequestHeader(value = "Authorization") String authorizationHeader) {

ScheduleDto.PerDateSchedulesResponse perDateSchedulesResponse = scheduleService.getUserDateSchedules(eventId, authorizationHeader);
PerDateSchedulesResponse perDateSchedulesResponse = scheduleService.getUserDateSchedules(eventId, authorizationHeader);
return ApiResponse.onSuccess(SuccessStatus._GET_USER_DATE_SCHEDULES, perDateSchedulesResponse);
}

// 멤버 필터링 날짜 스케줄 조회 API
@GetMapping("/date/action-filtering")
public ResponseEntity<ApiResponse<List<ScheduleDto.PerDateSchedulesResponse>>> getFilteredDateSchedules(
@RequestBody ScheduleDto.GetFilteredSchedulesRequest getFilteredSchedulesRequest) {
public ResponseEntity<ApiResponse<List<PerDateSchedulesResponse>>> getFilteredDateSchedules(
@RequestBody GetFilteredSchedulesRequest getFilteredSchedulesRequest) {

List<ScheduleDto.PerDateSchedulesResponse> perDateSchedulesResponses = scheduleService.getFilteredDateSchedules(getFilteredSchedulesRequest);
List<PerDateSchedulesResponse> perDateSchedulesResponses = scheduleService.getFilteredDateSchedules(getFilteredSchedulesRequest);
return ApiResponse.onSuccess(SuccessStatus._GET_FILTERED_DATE_SCHEDULES, perDateSchedulesResponses);
}
}
9 changes: 5 additions & 4 deletions src/main/java/side/onetime/controller/TokenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import side.onetime.dto.TokenDto;
import side.onetime.dto.token.request.ReissueTokenRequest;
import side.onetime.dto.token.response.ReissueTokenResponse;
import side.onetime.global.common.ApiResponse;
import side.onetime.global.common.status.SuccessStatus;
import side.onetime.service.TokenService;
Expand All @@ -19,10 +20,10 @@ public class TokenController {

// 액세스 토큰 재발행 API
@PostMapping("/action-reissue")
public ResponseEntity<ApiResponse<TokenDto.ReissueTokenResponse>> reissueToken(
@RequestBody TokenDto.ReissueTokenRequest reissueAccessTokenRequest) {
public ResponseEntity<ApiResponse<ReissueTokenResponse>> reissueToken(
@RequestBody ReissueTokenRequest reissueAccessTokenRequest) {

TokenDto.ReissueTokenResponse reissueTokenResponse = tokenService.reissueToken(reissueAccessTokenRequest);
ReissueTokenResponse reissueTokenResponse = tokenService.reissueToken(reissueAccessTokenRequest);
return ApiResponse.onSuccess(SuccessStatus._REISSUE_TOKENS, reissueTokenResponse);
}
}
17 changes: 10 additions & 7 deletions src/main/java/side/onetime/controller/UrlController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import side.onetime.dto.UrlDto;
import side.onetime.dto.url.request.ConvertToOriginalUrlRequest;
import side.onetime.dto.url.request.ConvertToShortenUrlRequest;
import side.onetime.dto.url.response.ConvertToOriginalUrlResponse;
import side.onetime.dto.url.response.ConvertToShortenUrlResponse;
import side.onetime.global.common.ApiResponse;
import side.onetime.global.common.status.SuccessStatus;
import side.onetime.service.UrlService;
Expand All @@ -19,19 +22,19 @@ public class UrlController {

// 원본 -> 단축 URL API
@PostMapping("/action-shorten")
public ResponseEntity<ApiResponse<UrlDto.ConvertToShortenUrlResponse>> convertToShortenUrl(
@RequestBody UrlDto.ConvertToShortenUrlRequest covertToShortenUrlRequest) {
public ResponseEntity<ApiResponse<ConvertToShortenUrlResponse>> convertToShortenUrl(
@RequestBody ConvertToShortenUrlRequest covertToShortenUrlRequest) {

UrlDto.ConvertToShortenUrlResponse convertToShortenUrlResponse = urlService.convertToShortenUrl(covertToShortenUrlRequest);
ConvertToShortenUrlResponse convertToShortenUrlResponse = urlService.convertToShortenUrl(covertToShortenUrlRequest);
return ApiResponse.onSuccess(SuccessStatus._CONVERT_TO_SHORTEN_URL, convertToShortenUrlResponse);
}

// 단축 -> 원본 URL API
@PostMapping("/action-original")
public ResponseEntity<ApiResponse<UrlDto.ConvertToOriginalUrlResponse>> convertToOriginalUrl(
@RequestBody UrlDto.ConvertToOriginalUrlRequest convertToOriginalUrlRequest) {
public ResponseEntity<ApiResponse<ConvertToOriginalUrlResponse>> convertToOriginalUrl(
@RequestBody ConvertToOriginalUrlRequest convertToOriginalUrlRequest) {

UrlDto.ConvertToOriginalUrlResponse convertToOriginalUrlResponse = urlService.convertToOriginalUrl(convertToOriginalUrlRequest);
ConvertToOriginalUrlResponse convertToOriginalUrlResponse = urlService.convertToOriginalUrl(convertToOriginalUrlRequest);
return ApiResponse.onSuccess(SuccessStatus._CONVERT_TO_ORIGINAL_URL, convertToOriginalUrlResponse);
}
}
Loading

0 comments on commit 54d3770

Please sign in to comment.