Skip to content

Commit

Permalink
Merge pull request #359 from Team-Sopetit/feature/#358/chan
Browse files Browse the repository at this point in the history
[FEAT] 캘린더 조회
  • Loading branch information
Chan531 authored Dec 4, 2024
2 parents a0cddef + 24851bd commit fbc0adf
Show file tree
Hide file tree
Showing 35 changed files with 727 additions and 55 deletions.
41 changes: 41 additions & 0 deletions src/main/java/com/soptie/server/api/controller/CalendarApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.soptie.server.api.controller;

import java.security.Principal;
import java.time.LocalDate;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.CalendarApiDocs;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
import com.soptie.server.api.controller.dto.response.calendar.DateHistoryResponse;
import com.soptie.server.api.controller.generic.SuccessMessage;
import com.soptie.server.domain.calendar.CalendarService;

import lombok.RequiredArgsConstructor;
import lombok.val;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v3/calendar")
public class CalendarApi implements CalendarApiDocs {

private final CalendarService calendarService;

@ResponseStatus(HttpStatus.OK)
@GetMapping
public SuccessResponse<Map<LocalDate, DateHistoryResponse>> getCalendar(
final Principal principal,
@RequestParam final int year,
@RequestParam final int month
) {
val memberId = Long.parseLong(principal.getName());
val response = calendarService.getCalendar(memberId, year, month);
return SuccessResponse.success(SuccessMessage.GET_CALENDAR.getMessage(), response);
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/soptie/server/api/controller/MemoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.soptie.server.api.controller.docs.MemoApiDocs;
import com.soptie.server.api.controller.dto.request.memo.CreateMemoRequest;
import com.soptie.server.api.controller.dto.request.memo.ModifyMemoRequest;
import com.soptie.server.api.controller.dto.response.SuccessResponse;
Expand All @@ -25,7 +26,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v3/memos")
public class MemoApi {
public class MemoApi implements MemoApiDocs {

private final MemoService memoService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "auth", description = "인증 API")
@Tag(name = "[Auth] 인증 API", description = "인증 API")
public interface AuthApiDocs {

@Operation(
Expand Down Expand Up @@ -69,10 +69,7 @@ SuccessResponse<TokenGetResponse> reissueToken(
summary = "로그 아웃",
description = "로그 아웃을 한다.",
responses = {
@ApiResponse(
responseCode = "200",
description = "성공",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "404",
description = "유효하지 않은 회원",
Expand All @@ -92,10 +89,7 @@ SuccessResponse<TokenGetResponse> reissueToken(
summary = "회원 탈퇴",
description = "회원 탈퇴를 진행한다.",
responses = {
@ApiResponse(
responseCode = "200",
description = "성공",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "404",
description = "유효하지 않은 회원",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.soptie.server.api.controller.docs;

import java.security.Principal;
import java.time.LocalDate;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestParam;

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.calendar.DateHistoryResponse;

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.tags.Tag;

@Tag(name = "[Calendar] 캘린더 API Version3", description = "캘린더 API Version3")
public interface CalendarApiDocs {

@Operation(
summary = "캘린더 조회",
description = "루틴 달성 기록, 메모가 포함되어있는 캘린더를 조회한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<Map<LocalDate, DateHistoryResponse>> getCalendar(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "year",
description = "조회할 캘린더의 년도",
in = ParameterIn.QUERY,
required = true,
example = "2024"
) @RequestParam int year,
@Parameter(
name = "month",
description = "조회할 캘린더의 월",
in = ParameterIn.QUERY,
required = true,
example = "12"
) @RequestParam int month
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

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

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "makers", description = "메이커 API")
@Tag(name = "[Maker] 메이커 루틴 API", description = "메이커 루틴 API")
public interface MakerApiDocs {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "[Member] 회원 API", description = "회원 관련 api 입니다.")
@Tag(name = "[Member] 회원 API", description = "회원 API")
public interface MemberApiDocs {

@Operation(
summary = "회원 프로필 생성",
description = "회원의 프로필을 생성한다.",
responses = {
@ApiResponse(
responseCode = "201",
description = "CREATED success",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "201", description = "Created success"),
@ApiResponse(
responseCode = "400",
description = "유효하지 않은 인형 타입",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "MemberMissionApi", description = "회원의 도전 루틴 API")
@Tag(name = "[MemberMission] 회원의 도전 루틴", description = "회원의 도전 루틴 API")
public interface MemberMissionApiDocs {

@Operation(
Expand All @@ -44,10 +44,7 @@ SuccessResponse<CreateMemberMissionResponse> createMemberMission(
summary = "미션 삭제",
description = "회원의 미션을 삭제한다.",
responses = {
@ApiResponse(
responseCode = "200",
description = "OK success",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
Expand All @@ -71,10 +68,7 @@ SuccessResponse<?> deleteMemberMission(
summary = "미션 달성",
description = "회원의 미션을 달성한다.",
responses = {
@ApiResponse(
responseCode = "200",
description = "OK success",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "MemberMissionApi_v2", description = "회원의 도전 루틴 API version2")
@Tag(name = "[MemberMission] 회원의 도전 루틴 Version2", description = "회원의 도전 루틴 API Version2")
public interface MemberMissionApiV2Docs {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "MemberRoutineApi", description = "회원의 데일리 루틴 API")
@Tag(name = "[MemberRoutine] 회원의 데일리 루틴", description = "회원의 데일리 루틴 API")
public interface MemberRoutineApiDocs {

@Operation(
summary = "데일리 루틴 삭제",
description = "회원의 데일리 루틴을 삭제한다.",
responses = {
@ApiResponse(
responseCode = "200",
description = "성공",
content = @Content(schema = @Schema(implementation = SuccessResponse.class))),
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "MemberRoutineApi_v2", description = "회원 데일리 루틴 API version2")
@Tag(name = "[MemberRoutine] 회원의 데일리 루틴 Version2", description = "회원의 데일리 루틴 API Version2")
public interface MemberRoutineApiV2Docs {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.soptie.server.api.controller.docs;

import java.security.Principal;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

import com.soptie.server.api.controller.dto.request.memo.CreateMemoRequest;
import com.soptie.server.api.controller.dto.request.memo.ModifyMemoRequest;
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.memo.CreateMemoResponse;

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.tags.Tag;

@Tag(name = "[Memo] 메모 API Version3", description = "메모 API Version3")
public interface MemoApiDocs {

@Operation(
summary = "메모 생성",
description = "메모를 생성한다.",
responses = {
@ApiResponse(responseCode = "201", description = "CREATED Success"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<CreateMemoResponse> createMemo(
@Parameter(hidden = true) Principal principal,
@RequestBody CreateMemoRequest request
);

@Operation(
summary = "메모 수정",
description = "메모를 수정한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<?> modifyMemo(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "memoId",
description = "수정할 메모 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable final long memoId,
@RequestBody ModifyMemoRequest request
);

@Operation(
summary = "메모 삭제",
description = "메모를 삭제한다.",
responses = {
@ApiResponse(responseCode = "200", description = "성공"),
@ApiResponse(
responseCode = "4xx",
description = "클라이언트(요청) 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(
responseCode = "500",
description = "서버 내부 오류",
content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}
)
SuccessResponse<?> deleteMemo(
@Parameter(hidden = true) Principal principal,
@Parameter(
name = "memoId",
description = "삭제할 메모 id",
in = ParameterIn.PATH,
example = "1"
) @PathVariable final long memoId
);
}
Loading

0 comments on commit fbc0adf

Please sign in to comment.