feat: 관리자/활동/이슈 API 전체 구현
- Entity: LoginHistory, PageView, Issue, IssueComment 추가
- Repository: 각 엔티티별 JpaRepository 추가
- Service: UserService, RoleService, ActivityService, IssueService
- Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트
- Activity API: 페이지뷰 기록, 로그인 이력 조회
- Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원
- Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException
- AuthController: 로그인 시 LoginHistory 기록 추가
- Dockerfile 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:13:14 +09:00
|
|
|
package com.gcsc.guide.controller;
|
|
|
|
|
|
|
|
|
|
import com.gcsc.guide.dto.LoginHistoryResponse;
|
|
|
|
|
import com.gcsc.guide.dto.TrackPageViewRequest;
|
|
|
|
|
import com.gcsc.guide.service.ActivityService;
|
2026-02-14 21:30:48 +09:00
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
|
|
|
|
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.security.SecurityRequirement;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
feat: 관리자/활동/이슈 API 전체 구현
- Entity: LoginHistory, PageView, Issue, IssueComment 추가
- Repository: 각 엔티티별 JpaRepository 추가
- Service: UserService, RoleService, ActivityService, IssueService
- Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트
- Activity API: 페이지뷰 기록, 로그인 이력 조회
- Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원
- Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException
- AuthController: 로그인 시 LoginHistory 기록 추가
- Dockerfile 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:13:14 +09:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/activity")
|
|
|
|
|
@RequiredArgsConstructor
|
2026-02-14 21:30:48 +09:00
|
|
|
@Tag(name = "05. 활동 기록", description = "페이지 뷰 추적 및 로그인 이력 조회")
|
|
|
|
|
@SecurityRequirement(name = "Bearer JWT")
|
feat: 관리자/활동/이슈 API 전체 구현
- Entity: LoginHistory, PageView, Issue, IssueComment 추가
- Repository: 각 엔티티별 JpaRepository 추가
- Service: UserService, RoleService, ActivityService, IssueService
- Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트
- Activity API: 페이지뷰 기록, 로그인 이력 조회
- Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원
- Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException
- AuthController: 로그인 시 LoginHistory 기록 추가
- Dockerfile 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:13:14 +09:00
|
|
|
public class ActivityController {
|
|
|
|
|
|
|
|
|
|
private final ActivityService activityService;
|
|
|
|
|
|
2026-02-14 21:30:48 +09:00
|
|
|
@Operation(summary = "페이지 뷰 기록",
|
|
|
|
|
description = "현재 사용자가 특정 페이지를 조회했음을 기록합니다. 프론트엔드에서 페이지 이동 시 호출합니다.")
|
|
|
|
|
@ApiResponses({
|
|
|
|
|
@ApiResponse(responseCode = "200", description = "기록 성공"),
|
|
|
|
|
@ApiResponse(responseCode = "401", description = "인증 실패", content = @Content)
|
|
|
|
|
})
|
feat: 관리자/활동/이슈 API 전체 구현
- Entity: LoginHistory, PageView, Issue, IssueComment 추가
- Repository: 각 엔티티별 JpaRepository 추가
- Service: UserService, RoleService, ActivityService, IssueService
- Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트
- Activity API: 페이지뷰 기록, 로그인 이력 조회
- Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원
- Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException
- AuthController: 로그인 시 LoginHistory 기록 추가
- Dockerfile 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:13:14 +09:00
|
|
|
@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();
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-14 21:30:48 +09:00
|
|
|
@Operation(summary = "현재 사용자의 로그인 이력 조회",
|
|
|
|
|
description = "JWT로 인증된 현재 사용자의 최근 로그인 이력(IP, User-Agent, 시간)을 반환합니다.")
|
|
|
|
|
@ApiResponses({
|
|
|
|
|
@ApiResponse(responseCode = "200", description = "조회 성공",
|
|
|
|
|
content = @Content(array = @ArraySchema(schema = @Schema(implementation = LoginHistoryResponse.class)))),
|
|
|
|
|
@ApiResponse(responseCode = "401", description = "인증 실패", content = @Content)
|
|
|
|
|
})
|
feat: 관리자/활동/이슈 API 전체 구현
- Entity: LoginHistory, PageView, Issue, IssueComment 추가
- Repository: 각 엔티티별 JpaRepository 추가
- Service: UserService, RoleService, ActivityService, IssueService
- Admin API: 사용자 관리 7개, 롤/권한 관리 7개, 통계 1개 엔드포인트
- Activity API: 페이지뷰 기록, 로그인 이력 조회
- Issue API: CRUD + 코멘트, 프로젝트/위치/Gitea 링크 지원
- Exception: GlobalExceptionHandler, ResourceNotFoundException, BusinessException
- AuthController: 로그인 시 LoginHistory 기록 추가
- Dockerfile 추가
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 21:13:14 +09:00
|
|
|
@GetMapping("/login-history")
|
|
|
|
|
public ResponseEntity<List<LoginHistoryResponse>> getLoginHistory(Authentication authentication) {
|
|
|
|
|
Long userId = (Long) authentication.getPrincipal();
|
|
|
|
|
return ResponseEntity.ok(activityService.getLoginHistory(userId));
|
|
|
|
|
}
|
|
|
|
|
}
|