diff --git a/src/main/java/com/ceos/bankids/controller/ChallengeController.java b/src/main/java/com/ceos/bankids/controller/ChallengeController.java index c1fab02c..9b3b3640 100644 --- a/src/main/java/com/ceos/bankids/controller/ChallengeController.java +++ b/src/main/java/com/ceos/bankids/controller/ChallengeController.java @@ -3,17 +3,21 @@ import com.ceos.bankids.config.CommonResponse; import com.ceos.bankids.domain.User; import com.ceos.bankids.dto.ChallengeDTO; +import com.ceos.bankids.dto.KidChallengeListDTO; import com.ceos.bankids.mapper.ChallengeMapper; import com.ceos.bankids.mapper.request.ChallengeRequest; import io.swagger.annotations.ApiOperation; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @Slf4j @@ -49,4 +53,32 @@ public CommonResponse deleteChallenge(@AuthenticationPrincipal Use return CommonResponse.onSuccess(challengeDTO); } + @ApiOperation(value = "돈길 리스트 가져오기") + @GetMapping(produces = "application/json; charset=utf-8") + public CommonResponse> getListChallenge( + @AuthenticationPrincipal User authUser, @RequestParam String status) { + + log.info("api = 돈길 리스트 가져오기, user = {}, status = {}", authUser.getUsername(), status); + + List challengeDTOList = challengeMapper.getListChallenge(authUser, status); + + return CommonResponse.onSuccess(challengeDTOList); + } + + @ApiOperation(value = "자녀의 돈길 리스트 가져오기") + @GetMapping(value = "/kid/{kidId}", produces = "application/json; charset=utf-8") + public CommonResponse getListKidChallenge( + @AuthenticationPrincipal User authUser, @PathVariable Long kidId, + @RequestParam String status) { + + log.info("api = 자녀의 돈길 리스트 가져오기, user = {}, kidId = {}, status = {}", + authUser.getUsername(), kidId, status); + + KidChallengeListDTO kidChallengeListDTO = challengeMapper.getListKidChallenge(authUser, + kidId, + status); + + return CommonResponse.onSuccess(kidChallengeListDTO); + } + } diff --git a/src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java b/src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java index 3ff85a7c..ad408efa 100644 --- a/src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java +++ b/src/main/java/com/ceos/bankids/mapper/ChallengeMapper.java @@ -122,10 +122,7 @@ public ChallengeDTO deleteChallenge(User authUser, Long challengeId) { throw new BadRequestException(ErrorCode.CANT_DELETE_CHALLENGE_STATUS.getErrorCode()); } - @ApiOperation(value = "돈길 리스트 가져오기") - @GetMapping(produces = "application/json; charset=utf-8") - public CommonResponse> getListChallenge( - @AuthenticationPrincipal User authUser, @RequestParam String status) { + public List getListChallenge(User authUser, String status) { log.info("api = 돈길 리스트 가져오기, user = {}, status = {}", authUser.getUsername(), status); if (!Objects.equals(status, "walking") && !Objects.equals(status, "pending")) { @@ -167,17 +164,11 @@ public CommonResponse> getListChallenge( }); } - return CommonResponse.onSuccess(challengeDTOList); + return challengeDTOList; } - @ApiOperation(value = "자녀의 돈길 리스트 가져오기") - @GetMapping(value = "/kid/{kidId}", produces = "application/json; charset=utf-8") - public CommonResponse getListKidChallenge( - @AuthenticationPrincipal User authUser, @PathVariable Long kidId, - @RequestParam String status) { + public KidChallengeListDTO getListKidChallenge(User authUser, Long kidId, String status) { - log.info("api = 자녀의 돈길 리스트 가져오기, user = {}, kidId = {}, status = {}", - authUser.getUsername(), kidId, status); Kid kid = kidService.getKid(kidId); User kidUser = kid.getUser(); List challengeDTOList = new ArrayList<>(); @@ -219,7 +210,7 @@ public CommonResponse getListKidChallenge( } KidChallengeListDTO kidChallengeListDTO = new KidChallengeListDTO(kidUser, challengeDTOList); - return CommonResponse.onSuccess(kidChallengeListDTO); + return kidChallengeListDTO; } @ApiOperation(value = "자녀의 돈길 수락 / 거절")