Skip to content

Commit

Permalink
[FIX] DTO 변수명 request & response 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
thguss committed Sep 18, 2023
1 parent 17fff74 commit 30467f9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/smeme/server/controller/AuthController.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class AuthController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "로그인 성공",
content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = SignInResponseDTO.class)))})
@PostMapping
public ResponseEntity<ApiResponse> signIn(@RequestHeader("Authorization") String socialAccessToken, @RequestBody SignInRequestDTO requestDTO) throws NoSuchAlgorithmException, InvalidKeySpecException {
SignInResponseDTO response = authService.signIn(socialAccessToken, requestDTO);
public ResponseEntity<ApiResponse> signIn(@RequestHeader("Authorization") String socialAccessToken, @RequestBody SignInRequestDTO request) throws NoSuchAlgorithmException, InvalidKeySpecException {
SignInResponseDTO response = authService.signIn(socialAccessToken, request);
return ResponseEntity.ok(success(SUCCESS_SIGNIN.getMessage(), response));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class BetaAuthController {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "베타 테스트용 임시 토큰 발급 성공"
, content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = BetaTokenResponseDTO.class)))})
@PostMapping("/token")
public ResponseEntity<ApiResponse> getToken(@RequestBody BetaSignInRequestDTO requestDTO) {
BetaTokenResponseDTO response = betaAuthService.createBetaMember(requestDTO);
public ResponseEntity<ApiResponse> getToken(@RequestBody BetaSignInRequestDTO request) {
BetaTokenResponseDTO response = betaAuthService.createBetaMember(request);
return ResponseEntity.ok(ApiResponse.success(SUCCESS_BETA_AUTH_TOKEN.getMessage(), response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public class CorrectionController {
public ResponseEntity<ApiResponse> createCorrection(
@Parameter(hidden = true) Principal principal,
@Parameter(description = "일기 id") @PathVariable Long diaryId,
@RequestBody CorrectionRequestDTO requestDTO
@RequestBody CorrectionRequestDTO request
) {
CorrectionResponseDTO response = correctionService.createCorrection(getMemberId(principal), diaryId, requestDTO);
CorrectionResponseDTO response = correctionService.createCorrection(getMemberId(principal), diaryId, request);
return ResponseEntity
.created(getURI(diaryId))
.body(success(SUCCESS_CREATE_CORRECTION.getMessage(), response));
Expand All @@ -74,8 +74,8 @@ public ResponseEntity<ApiResponse> deleteCorrection(@Parameter(description = "
description = "첨삭 수정 성공")
})
@PatchMapping("/{correctionId}")
public ResponseEntity<ApiResponse> updateCorrection(@Parameter(description = "첨삭 id") @PathVariable Long correctionId, @RequestBody CorrectionRequestDTO requestDTO) {
correctionService.updateCorrection(correctionId, requestDTO);
public ResponseEntity<ApiResponse> updateCorrection(@Parameter(description = "첨삭 id") @PathVariable Long correctionId, @RequestBody CorrectionRequestDTO request) {
correctionService.updateCorrection(correctionId, request);
return ResponseEntity.ok(success(SUCCESS_UPDATE_CORRECTION.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class DiaryController {
content = @Content(schema = @Schema(implementation = CreatedDiaryResponseDTO.class)))
})
@PostMapping
public ResponseEntity<ApiResponse> createDiary(@Parameter(hidden = true) Principal principal, @RequestBody DiaryRequestDTO requestDTO) {
CreatedDiaryResponseDTO response = diaryService.createDiary(getMemberId(principal), requestDTO);
public ResponseEntity<ApiResponse> createDiary(@Parameter(hidden = true) Principal principal, @RequestBody DiaryRequestDTO request) {
CreatedDiaryResponseDTO response = diaryService.createDiary(getMemberId(principal), request);
return ResponseEntity
.created(getURI(response.diaryId()))
.body(success(SUCCESS_CREATE_DIARY.getMessage(), response));
Expand All @@ -79,8 +79,8 @@ public ResponseEntity<ApiResponse> getDiaryDetail(@Parameter(name = "일기 id")
})
@PatchMapping("/{diaryId}")
public ResponseEntity<ApiResponse> updateDiary(
@Parameter(name = "일기 id") @PathVariable Long diaryId, @RequestBody DiaryRequestDTO requestDTO) {
diaryService.updateDiary(diaryId, requestDTO);
@Parameter(name = "일기 id") @PathVariable Long diaryId, @RequestBody DiaryRequestDTO request) {
diaryService.updateDiary(diaryId, request);
return ResponseEntity.ok(success(SUCCESS_UPDATE_DAIRY.getMessage()));
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/smeme/server/controller/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public class MemberController {
@ApiResponses(value = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "사용자 정보 수정 성공")})
@PatchMapping()
public ResponseEntity<ApiResponse> updateUserProfile(Principal principal, @RequestBody MemberUpdateRequestDTO requestDTO) {
MemberUpdateResponseDTO response = memberService.updateMember(getMemberId(principal), requestDTO);
public ResponseEntity<ApiResponse> updateUserProfile(Principal principal, @RequestBody MemberUpdateRequestDTO request) {
MemberUpdateResponseDTO response = memberService.updateMember(getMemberId(principal), request);
return ResponseEntity.ok(success(SUCCESS_UPDATE_USERNAME.getMessage(), response));
}

Expand All @@ -53,8 +53,8 @@ public ResponseEntity<ApiResponse> getUserProfile(Principal principal) {
@ApiResponses(value = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "사용자 학습 계획 성공")})
@PatchMapping("/plan")
public ResponseEntity<ApiResponse> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequestDTO requestDTO) {
memberService.updateMemberPlan(getMemberId(principal), requestDTO);
public ResponseEntity<ApiResponse> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequestDTO request) {
memberService.updateMemberPlan(getMemberId(principal), request);
return ResponseEntity.ok(success(SUCCESS_UPDATE_USER_PLAN.getMessage()));
}

Expand All @@ -72,8 +72,8 @@ public ResponseEntity<ApiResponse> checkDuplicatedName(@Parameter(description =
@ApiResponses(value = {
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "사용자 푸쉬 알람 동의 여부 수정 성공")})
@PatchMapping("/push")
public ResponseEntity<ApiResponse> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequestDTO requestDTO) {
memberService.updateMemberPush(getMemberId(principal), requestDTO);
public ResponseEntity<ApiResponse> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequestDTO request) {
memberService.updateMemberPush(getMemberId(principal), request);
return ResponseEntity.ok(success(SUCCESS_UPDATE_USER_PUSH.getMessage()));
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/smeme/server/service/CorrectionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class CorrectionService {
private final BadgeService badgeService;

@Transactional
public CorrectionResponseDTO createCorrection(Long memberId, Long diaryId, CorrectionRequestDTO requestDTO) {
public CorrectionResponseDTO createCorrection(Long memberId, Long diaryId, CorrectionRequestDTO request) {
Diary diary = getDiary(diaryId);
correctionRepository.save(new Correction(requestDTO.sentence(), requestDTO.content(), diary));
correctionRepository.save(new Correction(request.sentence(), request.content(), diary));
Member member = getMember(memberId);
Badge badge = getCorrectionBadge(member);
if (Objects.nonNull(badge) && !memberBadgeRepository.existsByMemberAndBadge(member, badge)) {
Expand Down Expand Up @@ -67,9 +67,9 @@ public void deleteCorrection(Long correctionId) {
}

@Transactional
public void updateCorrection(Long correctionId, CorrectionRequestDTO requestDTO) {
public void updateCorrection(Long correctionId, CorrectionRequestDTO request) {
Correction correction = getCorrection(correctionId);
correction.updateCorrection(requestDTO.content());
correction.updateCorrection(request.content());
}

private Diary getDiary(Long diaryId) {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/smeme/server/service/DiaryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public class DiaryService {
private final BadgeService badgeService;

@Transactional
public CreatedDiaryResponseDTO createDiary(Long memberId, DiaryRequestDTO requestDTO) {
public CreatedDiaryResponseDTO createDiary(Long memberId, DiaryRequestDTO request) {
Member member = getMember(memberId);
Topic topic = getTopic(requestDTO.topicId());
Diary diary = checkExistTodayDiary(member, new Diary(requestDTO.content(), topic, member));
Topic topic = getTopic(request.topicId());
Diary diary = checkExistTodayDiary(member, new Diary(request.content(), topic, member));
List<Badge> badges = getDiaryBadge(member, diary.getCreatedAt());
return CreatedDiaryResponseDTO.of(diary.getId(), badges);
}
Expand All @@ -61,9 +61,9 @@ public DiaryResponseDTO getDiaryDetail(Long diaryId) {
}

@Transactional
public void updateDiary(Long diaryId, DiaryRequestDTO requestDTO) {
public void updateDiary(Long diaryId, DiaryRequestDTO request) {
Diary diary = getDiary(diaryId);
diary.updateContent(requestDTO.content());
diary.updateContent(request.content());
}

@Transactional
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/smeme/server/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public class MemberService {
private final ValueConfig valueConfig;

@Transactional
public MemberUpdateResponseDTO updateMember(Long memberId, MemberUpdateRequestDTO dto) {
checkMemberDuplicate(dto.username());
public MemberUpdateResponseDTO updateMember(Long memberId, MemberUpdateRequestDTO request) {
checkMemberDuplicate(request.username());
Member member = getMemberById(memberId);

if (nonNull(dto.termAccepted())) {
member.updateTermAccepted(dto.termAccepted());
if (nonNull(request.termAccepted())) {
member.updateTermAccepted(request.termAccepted());
}

ArrayList<Badge> badges = new ArrayList<>();
Expand All @@ -59,7 +59,7 @@ public MemberUpdateResponseDTO updateMember(Long memberId, MemberUpdateRequestDT
memberBadgeRepository.save(new MemberBadge(member, welcomeBadge));
badges.add(welcomeBadge);
}
member.updateUsername(dto.username());
member.updateUsername(request.username());
return MemberUpdateResponseDTO.of(badges);
}

Expand Down Expand Up @@ -89,40 +89,40 @@ public MemberGetResponseDTO getMember(Long memberId) {


@Transactional
public void updateMemberPlan(Long memberId, MemberPlanUpdateRequestDTO requestDTO) {
public void updateMemberPlan(Long memberId, MemberPlanUpdateRequestDTO request) {
Member member = getMemberById(memberId);

if (nonNull(requestDTO.target())) {
member.updateGoal(requestDTO.target());
if (nonNull(request.target())) {
member.updateGoal(request.target());
}

if (nonNull(requestDTO.hasAlarm())) {
member.updateHasAlarm(requestDTO.hasAlarm());
if (nonNull(request.hasAlarm())) {
member.updateHasAlarm(request.hasAlarm());
}

if (nonNull(requestDTO.trainingTime()) && StringUtils.hasText(requestDTO.trainingTime().day())) {
updateMemberTrainingTime(member, requestDTO);
if (nonNull(request.trainingTime()) && StringUtils.hasText(request.trainingTime().day())) {
updateMemberTrainingTime(member, request);
}
}

@Transactional
public void updateMemberPush(Long memberId, MemberPushUpdateRequestDTO requestDTO) {
public void updateMemberPush(Long memberId, MemberPushUpdateRequestDTO request) {
Member member = getMemberById(memberId);
member.updateHasAlarm(requestDTO.hasAlarm());
member.updateHasAlarm(request.hasAlarm());
}

public MemberNameResponseDTO checkDuplicatedName(String name) {
boolean isExist = memberRepository.existsByUsername(name);
return new MemberNameResponseDTO(isExist);
}

private void updateMemberTrainingTime(Member member, MemberPlanUpdateRequestDTO requestDTO) {
private void updateMemberTrainingTime(Member member, MemberPlanUpdateRequestDTO request) {
trainingTimeRepository.deleteAll(member.getTrainingTimes());
for (String day : parseDay(requestDTO.trainingTime().day())) {
for (String day : parseDay(request.trainingTime().day())) {
TrainingTime trainingTime = TrainingTime.builder()
.day(DayType.valueOf(day))
.hour(requestDTO.trainingTime().hour())
.minute(requestDTO.trainingTime().minute())
.hour(request.trainingTime().hour())
.minute(request.trainingTime().minute())
.member(member)
.build();
trainingTimeRepository.save(trainingTime);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/smeme/server/service/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class AuthService {
private final CorrectionRepository correctionRepository;

@Transactional
public SignInResponseDTO signIn(String socialAccessToken, SignInRequestDTO signInRequestDTO) throws NoSuchAlgorithmException, InvalidKeySpecException {
public SignInResponseDTO signIn(String socialAccessToken, SignInRequestDTO request) throws NoSuchAlgorithmException, InvalidKeySpecException {

SocialType socialType = signInRequestDTO.socialType();
SocialType socialType = request.socialType();
String socialId = login(socialType, socialAccessToken);

boolean hasMember = isMemberBySocialAndSocialId(socialType, socialId);
Expand All @@ -61,7 +61,7 @@ public SignInResponseDTO signIn(String socialAccessToken, SignInRequestDTO signI
.social(socialType)
.socialId(socialId)
.targetLang(LangType.en)
.fcmToken(signInRequestDTO.fcmToken())
.fcmToken(request.fcmToken())
.build();
memberRepository.save(member);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ public class BetaAuthService {
private static final Long BETA_USER_EXPIRED = 60 * 60 * 1000 * 24 * 21L;

@Transactional
public BetaTokenResponseDTO createBetaMember(BetaSignInRequestDTO requestDTO) {
public BetaTokenResponseDTO createBetaMember(BetaSignInRequestDTO request) {

AtomicInteger atomicInteger = new AtomicInteger(1);
Member betaMember = Member.builder()
.social(BETA)
.targetLang(en)
.socialId("beta" + atomicInteger.getAndIncrement())
.fcmToken(requestDTO.fcmToken())
.fcmToken(request.fcmToken())
.build();
memberRepository.save(betaMember);
Authentication authentication = new UserAuthentication(betaMember.getId(), null, null);
Expand Down

0 comments on commit 30467f9

Please sign in to comment.