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

[FIX] 챌린지 depth 축소 #365

Merged
merged 24 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import com.soptie.server.api.controller.docs.ChallengeApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.challenge.GetChallengesByMemberResponse;
import com.soptie.server.api.controller.dto.response.challenge.ChallengesResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.challenge.ChallengeService;

Expand All @@ -20,16 +20,13 @@

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v2/routines/challenge")
@RequestMapping("/api/v2/challenges")
public class ChallengeApi implements ChallengeApiDocs {
private final ChallengeService challengeService;

@ResponseStatus(HttpStatus.OK)
@GetMapping
public SuccessResponse<GetChallengesByMemberResponse> getChallengesByTheme(
Principal principal,
@RequestParam long themeId
) {
public SuccessResponse<ChallengesResponse> getChallengesByTheme(Principal principal, @RequestParam long themeId) {
val memberId = Long.parseLong(principal.getName());
val response = challengeService.getChallengesByTheme(memberId, themeId);
return SuccessResponse.success(SuccessMessage.GET_CHALLENGE.getMessage(), response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import java.security.Principal;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -12,53 +14,62 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemberMissionApiDocs;
import com.soptie.server.api.controller.dto.request.membermission.CreateMemberMissionRequest;
import com.soptie.server.api.controller.docs.MemberChallengeApiDocs;
import com.soptie.server.api.controller.dto.request.membermission.CreateMemberChallengeRequest;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.membermission.CreateMemberMissionResponse;
import com.soptie.server.api.controller.dto.response.membermission.CreateMemberChallengeResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.membermission.MemberMissionService;
import com.soptie.server.domain.challenge.MemberChallengeService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/routines/happiness/member")
public class MemberMissionApi implements MemberMissionApiDocs {
private final MemberMissionService memberMissionService;
@RequestMapping("/api/v2/members/challenges")
public class MemberChallengeApi implements MemberChallengeApiDocs {
private final MemberChallengeService memberChallengeService;

@GetMapping
public ResponseEntity<?> getMemberChallenge(Principal principal) {
val memberId = Long.parseLong(principal.getName());
return memberChallengeService.getMemberChallenge(memberId)
.map(response ->
ResponseEntity.ok(SuccessResponse.success(SuccessMessage.GET_ROUTINE.getMessage(), response)))
.orElseGet(() -> ResponseEntity.noContent().build());
}

@ResponseStatus(HttpStatus.CREATED)
@PostMapping
public SuccessResponse<CreateMemberMissionResponse> createMemberMission(
public SuccessResponse<CreateMemberChallengeResponse> createMemberChallenge(
Principal principal,
@RequestBody CreateMemberMissionRequest request
@RequestBody CreateMemberChallengeRequest request
) {
val memberId = Long.parseLong(principal.getName());
val response = memberMissionService.createMemberMission(memberId, request);
val response = memberChallengeService.createMemberChallenge(memberId, request);
return SuccessResponse.success(SuccessMessage.CREATE_ROUTINE.getMessage(), response);
}

@ResponseStatus(HttpStatus.OK)
@DeleteMapping("/routine/{routineId}")
public SuccessResponse<?> deleteMemberMission(Principal principal, @PathVariable long routineId) {
@DeleteMapping
public SuccessResponse<?> deleteMemberChallenge(Principal principal) {
val memberId = Long.parseLong(principal.getName());
memberMissionService.deleteMemberMission(memberId, routineId);
memberChallengeService.deleteMemberChallenge(memberId);
return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@PatchMapping("/routine/{routineId}")
public SuccessResponse<?> achieveMemberMission(Principal principal, @PathVariable long routineId) {
@PatchMapping("/achievement")
public SuccessResponse<?> achieveMemberChallenge(Principal principal) {
val memberId = Long.parseLong(principal.getName());
memberMissionService.achieveMemberMission(memberId, routineId);
memberChallengeService.achieveMemberChallenge(memberId);
return SuccessResponse.success(SuccessMessage.ACHIEVE_ROUTINE.getMessage());
}

@ResponseStatus(HttpStatus.OK)
@DeleteMapping("/history/{historyId}")
public SuccessResponse<?> deleteMissionHistory(@PathVariable long historyId) {
memberMissionService.deleteHistory(historyId);
public SuccessResponse<?> deleteHistory(@PathVariable long historyId) {
memberChallengeService.deleteHistory(historyId);
return SuccessResponse.success(SuccessMessage.DELETE_ROUTINE.getMessage());
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import com.soptie.server.api.controller.dto.response.ErrorResponse;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.challenge.GetChallengesByMemberResponse;
import com.soptie.server.api.controller.dto.response.challenge.ChallengesResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -16,12 +16,12 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "[Challenge] 도전 루틴 API", description = "도전 루틴 API version2")
@Tag(name = "[Challenge] 챌린지 API", description = "챌린지 API version2")
public interface ChallengeApiDocs {

@Operation(
summary = "테마별 도전 루틴 목록 조회",
description = "테마에 해당되는 도전 루틴 목록을 조회한다.",
summary = "테마별 챌린지 목록 조회",
description = "테마별 챌린지 목록을 조회한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
Expand All @@ -33,11 +33,11 @@ public interface ChallengeApiDocs {
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<GetChallengesByMemberResponse> getChallengesByTheme(
SuccessResponse<ChallengesResponse> getChallengesByTheme(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "themeId",
description = "조회할 도전 루틴 테마 id",
description = "조회하려는 테마 id",
in = ParameterIn.QUERY,
example = "1"
) @RequestParam long themeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import java.security.Principal;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;

import com.soptie.server.api.controller.dto.request.membermission.CreateMemberMissionRequest;
import com.soptie.server.api.controller.dto.request.membermission.CreateMemberChallengeRequest;
import com.soptie.server.api.controller.dto.response.ErrorResponse;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.membermission.CreateMemberMissionResponse;
import com.soptie.server.api.controller.dto.response.membermission.CreateMemberChallengeResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -18,12 +19,31 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "[MemberMission] 회원의 도전 루틴", description = "회원의 도전 루틴 API")
public interface MemberMissionApiDocs {
@Tag(name = "[MemberChallenge] 회원 챌린지 API", description = "회원 챌린지 API version2")
public interface MemberChallengeApiDocs {

@Operation(
summary = "미션(도전 루틴) 추가",
description = "회원의 미션을 추가한다.",
summary = "회원 챌린지 조회",
description = "회원의 챌린지를 조회한다.",
responses = {
@ApiResponse(responseCode = "200", description = "OK success"),
@ApiResponse(responseCode = "204", description = "NoContent success"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
ResponseEntity<?> getMemberChallenge(
@Parameter(hidden = true) Principal principal
);

@Operation(
summary = "회원 챌린지 추가",
description = "회원의 챌린지를 추가한다.",
responses = {
@ApiResponse(responseCode = "201", description = "Created success"),
@ApiResponse(
Expand All @@ -35,14 +55,14 @@ public interface MemberMissionApiDocs {
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<CreateMemberMissionResponse> createMemberMission(
SuccessResponse<CreateMemberChallengeResponse> createMemberChallenge(
@Parameter(hidden = true) Principal principal,
@RequestBody CreateMemberMissionRequest request
@RequestBody CreateMemberChallengeRequest request
);

@Operation(
summary = "미션 삭제",
description = "회원의 미션을 삭제한다.",
summary = "회원 챌린지 삭제",
description = "회원의 챌린지를 삭제한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
Expand All @@ -54,19 +74,13 @@ SuccessResponse<CreateMemberMissionResponse> createMemberMission(
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<?> deleteMemberMission(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "routineId",
description = "삭제할 회원의 미션 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long routineId
SuccessResponse<?> deleteMemberChallenge(
@Parameter(hidden = true) Principal principal
);

@Operation(
summary = "미션 달성",
description = "회원의 미션을 달성한다.",
summary = "회원 챌린지 달성",
description = "회원의 챌린지를 달성한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
Expand All @@ -78,20 +92,13 @@ SuccessResponse<?> deleteMemberMission(
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<?> achieveMemberMission(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "routineId",
description = "달성할 회원의 미션 id",
in = ParameterIn.PATH,
example = "1"
)
@PathVariable long routineId
SuccessResponse<?> achieveMemberChallenge(
@Parameter(hidden = true) Principal principal
);

@Operation(
summary = "미션 기록 삭제",
description = "달성한 미션 기록을 삭제합니다.",
summary = "챌린지 기록 삭제",
description = "달성한 챌린지 기록을 삭제합니다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
Expand All @@ -103,10 +110,10 @@ SuccessResponse<?> achieveMemberMission(
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<?> deleteMissionHistory(
SuccessResponse<?> deleteHistory(
@Parameter(
name = "historyId",
description = "달성 이력 id",
description = "삭제하려는 이력 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable long historyId
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.soptie.server.api.controller.dto.request.membermission;

import io.swagger.v3.oas.annotations.media.Schema;

public record CreateMemberChallengeRequest(
@Schema(description = "추가하려는 챌린지 id", example = "1")
long challengeId
) {
}

This file was deleted.

Loading