-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ines [FEAT] Daily Routine 목록 조회(in add view) 기능 구현
- Loading branch information
Showing
11 changed files
with
242 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 44 additions & 1 deletion
45
src/main/java/com/soptie/server/routine/controller/v2/docs/DailyRoutineControllerV2Docs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,60 @@ | ||
package com.soptie.server.routine.controller.v2.docs; | ||
|
||
import java.security.Principal; | ||
import java.util.LinkedHashSet; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
|
||
import com.soptie.server.common.dto.SuccessResponse; | ||
import com.soptie.server.routine.controller.v2.dto.response.DailyRoutineListAcquireResponseV2; | ||
import com.soptie.server.routine.controller.v2.dto.response.DailyRoutinesAcquireResponseV2; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.enums.ParameterIn; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
|
||
@Tag(name = "DailyRoutineApiV2", description = "데일리 루틴 API (version2)") | ||
public interface DailyRoutineControllerV2Docs { | ||
|
||
@Operation( | ||
summary = "데일리 루틴 목록 조회", | ||
description = "특정 테마 id 목록에 속하는 데일리 루틴 목록을 조회합니다." | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "OK Success", | ||
content = @Content(schema = @Schema(implementation = DailyRoutineListAcquireResponseV2.class)))}) | ||
ResponseEntity<SuccessResponse<DailyRoutineListAcquireResponseV2>> acquireAllByThemes( | ||
@Parameter(name = "themeIds", description = "조회할 테마 id 목록") LinkedHashSet<Long> themeIds | ||
@Parameter( | ||
name = "themeIds", | ||
description = "조회할 테마 id 목록", | ||
required = true, | ||
in = ParameterIn.QUERY | ||
) LinkedHashSet<Long> themeIds | ||
); | ||
|
||
@Operation( | ||
summary = "데일리 루틴 목록 조회", | ||
description = "특정 테마에 속하는 데일리 루틴 목록을 조회합니다. 회원이 가진 유무를 함께 확인할 수 있습니다." | ||
) | ||
@ApiResponses(value = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "OK Success", | ||
content = @Content(schema = @Schema(implementation = DailyRoutinesAcquireResponseV2.class)))}) | ||
SuccessResponse<DailyRoutinesAcquireResponseV2> acquireAllByThemeAndMember( | ||
@Parameter(hidden = true) Principal principal, | ||
@Parameter( | ||
name = "themeId", | ||
description = "조회하려는 루틴의 테마 id", | ||
required = true, | ||
in = ParameterIn.PATH | ||
) long themeId | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
.../com/soptie/server/routine/controller/v2/dto/response/DailyRoutinesAcquireResponseV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.soptie.server.routine.controller.v2.dto.response; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.soptie.server.routine.entity.Routine; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.val; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record DailyRoutinesAcquireResponseV2( | ||
@Schema(description = "조회하려는 루틴 목록") | ||
@NotNull | ||
List<DailyRoutineResponse> routines | ||
) { | ||
|
||
public static DailyRoutinesAcquireResponseV2 from(Map<Boolean, List<Routine>> routineToMember) { | ||
val routines = new ArrayList<DailyRoutineResponse>(); | ||
for (val key : routineToMember.keySet()) { | ||
routines.addAll(routineToMember.get(key).stream() | ||
.map(routine -> DailyRoutineResponse.of(routine, key)) | ||
.toList()); | ||
} | ||
return DailyRoutinesAcquireResponseV2.builder() | ||
.routines(routines) | ||
.build(); | ||
} | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
private record DailyRoutineResponse( | ||
@Schema(description = "루틴 id") | ||
long id, | ||
@Schema(description = "루틴 내용") | ||
@NotNull | ||
String content, | ||
@Schema(description = "회원이 가지고 있는 루틴 유무") | ||
boolean existedInMember | ||
) { | ||
|
||
private static DailyRoutineResponse of(Routine routine, boolean existedInMember) { | ||
return DailyRoutineResponse.builder() | ||
.id(routine.getId()) | ||
.content(routine.getContent()) | ||
.existedInMember(existedInMember) | ||
.build(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.