41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
|
|
package com.gcsc.guide.controller;
|
||
|
|
|
||
|
|
import com.gcsc.guide.dto.LoginHistoryResponse;
|
||
|
|
import com.gcsc.guide.dto.TrackPageViewRequest;
|
||
|
|
import com.gcsc.guide.service.ActivityService;
|
||
|
|
import jakarta.validation.Valid;
|
||
|
|
import lombok.RequiredArgsConstructor;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.security.core.Authentication;
|
||
|
|
import org.springframework.web.bind.annotation.*;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 활동 기록 API
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/activity")
|
||
|
|
@RequiredArgsConstructor
|
||
|
|
public class ActivityController {
|
||
|
|
|
||
|
|
private final ActivityService activityService;
|
||
|
|
|
||
|
|
/** 페이지 뷰 기록 */
|
||
|
|
@PostMapping("/track")
|
||
|
|
public ResponseEntity<Void> trackPageView(
|
||
|
|
Authentication authentication,
|
||
|
|
@Valid @RequestBody TrackPageViewRequest request) {
|
||
|
|
Long userId = (Long) authentication.getPrincipal();
|
||
|
|
activityService.trackPageView(userId, request.pagePath());
|
||
|
|
return ResponseEntity.ok().build();
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 현재 사용자의 로그인 이력 조회 */
|
||
|
|
@GetMapping("/login-history")
|
||
|
|
public ResponseEntity<List<LoginHistoryResponse>> getLoginHistory(Authentication authentication) {
|
||
|
|
Long userId = (Long) authentication.getPrincipal();
|
||
|
|
return ResponseEntity.ok(activityService.getLoginHistory(userId));
|
||
|
|
}
|
||
|
|
}
|