Skip to content

Commit

Permalink
refactor: 돈길 걷기 API Mapper 구조로 리팩토링 #232
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbonai06 committed Sep 19, 2022
1 parent e6cabdc commit e86b66c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/ceos/bankids/controller/ChallengeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.ceos.bankids.dto.KidAchievedChallengeListDTO;
import com.ceos.bankids.dto.KidChallengeListDTO;
import com.ceos.bankids.dto.KidWeekDTO;
import com.ceos.bankids.dto.ProgressDTO;
import com.ceos.bankids.dto.WeekDTO;
import com.ceos.bankids.mapper.ChallengeMapper;
import com.ceos.bankids.mapper.request.ChallengeRequest;
Expand Down Expand Up @@ -168,4 +169,16 @@ public CommonResponse<AchievedChallengeDTO> patchInterestPayment(

return CommonResponse.onSuccess(achievedChallengeDTO);
}

@ApiOperation(value = "돈길 걷기")
@PatchMapping(value = "/{challengeId}/progress", produces = "application/json; charset=utf-8")
public CommonResponse<ProgressDTO> patchProgress(@AuthenticationPrincipal User authUser,
@PathVariable Long challengeId) {

log.info("api = 돈길 걷기, user = {}, challengeId = {}", authUser, challengeId);

ProgressDTO progressDTO = challengeMapper.patchProgress(authUser, challengeId);

return CommonResponse.onSuccess(progressDTO);
}
}
14 changes: 3 additions & 11 deletions src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.ceos.bankids.mapper;

import com.ceos.bankids.config.CommonResponse;
import com.ceos.bankids.constant.ChallengeStatus;
import com.ceos.bankids.constant.ErrorCode;
import com.ceos.bankids.domain.Challenge;
Expand Down Expand Up @@ -29,7 +28,6 @@
import com.ceos.bankids.service.KidServiceImpl;
import com.ceos.bankids.service.ParentServiceImpl;
import com.ceos.bankids.service.UserServiceImpl;
import io.swagger.annotations.ApiOperation;
import java.sql.Timestamp;
import java.time.DayOfWeek;
import java.time.LocalDateTime;
Expand All @@ -40,10 +38,7 @@
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;

@Slf4j
@Service
Expand Down Expand Up @@ -298,12 +293,9 @@ public AchievedChallengeDTO patchInterestPayment(User authUser, Long challengeId
challengeId);
}

@ApiOperation(value = "돈길 걷기")
@PatchMapping(value = "/{challengeId}/progress", produces = "application/json; charset=utf-8")
public CommonResponse<ProgressDTO> patchProgress(@AuthenticationPrincipal User authUser,
@PathVariable Long challengeId) {
// 돈길 걷기 API Mapper
public ProgressDTO patchProgress(User authUser, Long challengeId) {

log.info("api = 돈길 걷기, user = {}, challengeId = {}", authUser, challengeId);
userRoleValidation(authUser, true);
Challenge challenge = challengeService.readChallenge(challengeId);
if (challenge.getChallengeStatus() != ChallengeStatus.WALKING) {
Expand All @@ -320,7 +312,7 @@ public CommonResponse<ProgressDTO> patchProgress(@AuthenticationPrincipal User a
challenge);
}

return CommonResponse.onSuccess(progressDTO);
return progressDTO;
}

// 일요일 처리 validation
Expand Down

0 comments on commit e86b66c

Please sign in to comment.