1
- package com .example .dosirakbe .domain .activity_log .controller ;
2
-
3
- import com .example .dosirakbe .domain .activity_log .dto .response .ActivityLogResponse ;
4
- import com .example .dosirakbe .domain .activity_log .service .ActivityLogService ;
5
- import com .example .dosirakbe .domain .auth .dto .response .CustomOAuth2User ;
6
- import com .example .dosirakbe .global .util .ApiResult ;
7
- import com .example .dosirakbe .global .util .StatusEnum ;
8
- import lombok .RequiredArgsConstructor ;
9
- import org .springframework .format .annotation .DateTimeFormat ;
10
- import org .springframework .http .HttpStatus ;
11
- import org .springframework .http .ResponseEntity ;
12
- import org .springframework .security .core .annotation .AuthenticationPrincipal ;
13
- import org .springframework .web .bind .annotation .*;
14
-
15
- import java .time .LocalDate ;
16
- import java .time .YearMonth ;
17
- import java .util .List ;
18
-
19
- /**
20
- * packageName : com.example.dosirakbe.domain.activity_log.controller<br>
21
- * fileName : ActivityLogController<br>
22
- * author : Fiat_lux<br>
23
- * date : 11/03/24<br>
24
- * description : 활동 로그 관련 API 요청을 처리하는 컨트롤러 클래스입니다.<br>
25
- * ===========================================================<br>
26
- * DATE AUTHOR NOTE<br>
27
- * -----------------------------------------------------------<br>
28
- * 11/03/24 Fiat_lux 최초 생성<br>
29
- * 12/20/24 Fiat_lux api 수정<br>
30
- */
31
- @ RestController
32
- @ RequiredArgsConstructor
33
- @ RequestMapping ("/api/activity-logs" )
34
- public class ActivityLogController {
35
- private final ActivityLogService activityLogService ;
36
-
37
- /**
38
- * 특정 날짜의 활동 로그를 조회합니다.
39
- *
40
- * <p>
41
- * 이 메서드는 인증된 사용자의 지정된 날짜에 해당하는 활동 로그를 조회하여 반환합니다.
42
- * </p>
43
- *
44
- * @param customOAuth2User 인증된 사용자 정보
45
- * @param date 조회할 날짜 (yyyy-MM-dd 형식)
46
- * @return 지정된 날짜의 활동 로그를 포함한 {@link ApiResult} 객체
47
- */
48
- @ GetMapping
49
- public ResponseEntity <ApiResult <List <ActivityLogResponse >>> getTodayActivityLog (@ AuthenticationPrincipal CustomOAuth2User customOAuth2User ,
50
- @ RequestParam (name = "date" , required = false ) @ DateTimeFormat (iso = DateTimeFormat .ISO .DATE ) LocalDate date ) {
51
- Long userId = getUserIdByOAuth (customOAuth2User );
52
- List <ActivityLogResponse > activityLogs = activityLogService .getThatDateActivityLog (userId , date );
53
-
54
- ApiResult <List <ActivityLogResponse >> result = ApiResult .<List <ActivityLogResponse >>builder ()
55
- .status (StatusEnum .SUCCESS )
56
- .message ("Activity history for today retrieved successfully" )
57
- .data (activityLogs )
58
- .build ();
59
-
60
- return ResponseEntity
61
- .status (HttpStatus .OK )
62
- .body (result );
63
- }
64
-
65
- /**
66
- * 특정 월의 첫째 날의 활동 로그를 조회합니다.
67
- *
68
- * <p>
69
- * 이 메서드는 인증된 사용자의 지정된 월의 첫째 날에 해당하는 활동 로그를 조회하여 반환합니다.
70
- * </p>
71
- *
72
- * @param customOAuth2User 인증된 사용자 정보
73
- * @param month 조회할 월 (yyyy-MM 형식)
74
- * @return 지정된 월의 첫째 날의 활동 로그를 포함한 {@link ApiResult} 객체
75
- */
76
- @ GetMapping ("/first-day/{month}" )
77
- public ResponseEntity <ApiResult <List <ActivityLogResponse >>> getActivityLogForFirstDayOfMonth (@ AuthenticationPrincipal CustomOAuth2User customOAuth2User ,
78
- @ PathVariable ("month" ) @ DateTimeFormat (pattern = "yyyy-MM" ) YearMonth month ) {
79
-
80
- Long userId = getUserIdByOAuth (customOAuth2User );
81
- List <ActivityLogResponse > firstDayLogs = activityLogService .getActivityLogForFirstDayOfMonth (userId , month );
82
-
83
- ApiResult <List <ActivityLogResponse >> result = ApiResult .<List <ActivityLogResponse >>builder ()
84
- .status (StatusEnum .SUCCESS )
85
- .message ("Activity history for first date retrieved successfully" )
86
- .data (firstDayLogs )
87
- .build ();
88
-
89
- return ResponseEntity
90
- .status (HttpStatus .OK )
91
- .body (result );
92
- }
93
-
94
- /**
95
- * 인증된 사용자의 ID를 추출합니다.
96
- *
97
- * <p>
98
- * 이 메서드는 인증된 {@link CustomOAuth2User} 객체로부터 사용자의 ID를 추출하여 반환합니다.
99
- * </p>
100
- *
101
- * @param customOAuth2User 인증된 사용자 정보
102
- * @return 사용자의 고유 ID
103
- */
104
- private Long getUserIdByOAuth (CustomOAuth2User customOAuth2User ) {
105
- return customOAuth2User .getUserDTO ().getUserId ();
106
- }
107
- }
1
+ //package com.example.dosirakbe.domain.activity_log.controller;
2
+ //
3
+ //import com.example.dosirakbe.domain.activity_log.dto.response.ActivityLogResponse;
4
+ //import com.example.dosirakbe.domain.activity_log.service.ActivityLogService;
5
+ //import com.example.dosirakbe.domain.auth.dto.response.CustomOAuth2User;
6
+ //import com.example.dosirakbe.global.api.ApiResponseWrapper;
7
+ //import com.example.dosirakbe.global.util.ApiResult;
8
+ //import com.example.dosirakbe.global.util.StatusEnum;
9
+ //import lombok.RequiredArgsConstructor;
10
+ //import org.springframework.format.annotation.DateTimeFormat;
11
+ //import org.springframework.http.HttpStatus;
12
+ //import org.springframework.http.ResponseEntity;
13
+ //import org.springframework.security.core.annotation.AuthenticationPrincipal;
14
+ //import org.springframework.web.bind.annotation.*;
15
+ //
16
+ //import java.time.LocalDate;
17
+ //import java.time.YearMonth;
18
+ //import java.util.List;
19
+ //
20
+ ///**
21
+ // * packageName : com.example.dosirakbe.domain.activity_log.controller<br>
22
+ // * fileName : ActivityLogController<br>
23
+ // * author : Fiat_lux<br>
24
+ // * date : 11/03/24<br>
25
+ // * description : 활동 로그 관련 API 요청을 처리하는 컨트롤러 클래스입니다.<br>
26
+ // * ===========================================================<br>
27
+ // * DATE AUTHOR NOTE<br>
28
+ // * -----------------------------------------------------------<br>
29
+ // * 11/03/24 Fiat_lux 최초 생성<br>
30
+ // * 12/20/24 Fiat_lux api 수정<br>
31
+ // */
32
+ //@RestController
33
+ //@RequiredArgsConstructor
34
+ //@RequestMapping("/api/activity-logs")
35
+ //public class ActivityLogController {
36
+ // private final ActivityLogService activityLogService;
37
+ //
38
+ // /**
39
+ // * 특정 날짜의 활동 로그를 조회합니다.
40
+ // *
41
+ // * <p>
42
+ // * 이 메서드는 인증된 사용자의 지정된 날짜에 해당하는 활동 로그를 조회하여 반환합니다.
43
+ // * </p>
44
+ // *
45
+ // * @param customOAuth2User 인증된 사용자 정보
46
+ // * @param date 조회할 날짜 (yyyy-MM-dd 형식)
47
+ // * @return 지정된 날짜의 활동 로그를 포함한 {@link ApiResult} 객체
48
+ // */
49
+ // @GetMapping
50
+ // @ApiResponseWrapper(status = HttpStatus.OK, message = "Activity history for today retrieved successfully")
51
+ // public Object getTodayActivityLog(@AuthenticationPrincipal CustomOAuth2User customOAuth2User,
52
+ // @RequestParam(name = "date", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
53
+ // Long userId = getUserIdByOAuth(customOAuth2User);
54
+ //
55
+ // return activityLogService.getThatDateActivityLog(userId, date);
56
+ // }
57
+ //
58
+ // /**
59
+ // * 특정 월의 첫째 날의 활동 로그를 조회합니다.
60
+ // *
61
+ // * <p>
62
+ // * 이 메서드는 인증된 사용자의 지정된 월의 첫째 날에 해당하는 활동 로그를 조회하여 반환합니다.
63
+ // * </p>
64
+ // *
65
+ // * @param customOAuth2User 인증된 사용자 정보
66
+ // * @param month 조회할 월 (yyyy-MM 형식)
67
+ // * @return 지정된 월의 첫째 날의 활동 로그를 포함한 {@link ApiResult} 객체
68
+ // */
69
+ // @GetMapping("/first-day/{month}")
70
+ // @ApiResponseWrapper(status = HttpStatus.OK, message = "Activity history for first date retrieved successfully")
71
+ // public Object getActivityLogForFirstDayOfMonth(@AuthenticationPrincipal CustomOAuth2User customOAuth2User,
72
+ // @PathVariable("month") @DateTimeFormat(pattern = "yyyy-MM") YearMonth month) {
73
+ // Long userId = getUserIdByOAuth(customOAuth2User);
74
+ //
75
+ // return activityLogService.getActivityLogForFirstDayOfMonth(userId, month);
76
+ // }
77
+ //
78
+ // /**
79
+ // * 인증된 사용자의 ID를 추출합니다.
80
+ // *
81
+ // * <p>
82
+ // * 이 메서드는 인증된 {@link CustomOAuth2User} 객체로부터 사용자의 ID를 추출하여 반환합니다.
83
+ // * </p>
84
+ // *
85
+ // * @param customOAuth2User 인증된 사용자 정보
86
+ // * @return 사용자의 고유 ID
87
+ // */
88
+ // private Long getUserIdByOAuth(CustomOAuth2User customOAuth2User) {
89
+ // return customOAuth2User.getUserDTO().getUserId();
90
+ // }
91
+ //}
0 commit comments