- Admin 엔티티에 Organization 컬럼 추가 + Migration - ProfileResponseDto에 last_login_at, organization 필드 추가 - UpdateProfileRequestDto에 organization 필드 추가 - AuthService 프로필 조회/수정 매핑 확장 - 활동 내역 DTO 및 GetActivityListAsync 메서드 추가 - ProfileController 활동 내역 조회 엔드포인트 추가 Closes #249
73 lines
3.1 KiB
C#
73 lines
3.1 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using SPMS.Application.DTOs.Account;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Common;
|
|
using SPMS.Domain.Exceptions;
|
|
|
|
namespace SPMS.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/in/account/profile")]
|
|
[ApiExplorerSettings(GroupName = "account")]
|
|
[Authorize]
|
|
public class ProfileController : ControllerBase
|
|
{
|
|
private readonly IAuthService _authService;
|
|
|
|
public ProfileController(IAuthService authService)
|
|
{
|
|
_authService = authService;
|
|
}
|
|
|
|
[HttpPost("info")]
|
|
[SwaggerOperation(
|
|
Summary = "내 정보 조회",
|
|
Description = "현재 로그인된 관리자의 프로필 정보를 조회합니다.")]
|
|
[SwaggerResponse(200, "조회 성공", typeof(ApiResponse<ProfileResponseDto>))]
|
|
[SwaggerResponse(401, "인증되지 않은 요청")]
|
|
public async Task<IActionResult> GetProfileAsync()
|
|
{
|
|
var adminIdClaim = User.FindFirst("adminId")?.Value;
|
|
if (string.IsNullOrEmpty(adminIdClaim) || !long.TryParse(adminIdClaim, out var adminId))
|
|
throw SpmsException.Unauthorized("인증 정보가 유효하지 않습니다.");
|
|
|
|
var result = await _authService.GetProfileAsync(adminId);
|
|
return Ok(ApiResponse<ProfileResponseDto>.Success(result));
|
|
}
|
|
|
|
[HttpPost("update")]
|
|
[SwaggerOperation(
|
|
Summary = "내 정보 수정",
|
|
Description = "현재 로그인된 관리자의 프로필 정보(이름, 전화번호)를 수정합니다.")]
|
|
[SwaggerResponse(200, "수정 성공", typeof(ApiResponse<ProfileResponseDto>))]
|
|
[SwaggerResponse(400, "변경된 내용 없음")]
|
|
[SwaggerResponse(401, "인증되지 않은 요청")]
|
|
public async Task<IActionResult> UpdateProfileAsync([FromBody] UpdateProfileRequestDto request)
|
|
{
|
|
var adminIdClaim = User.FindFirst("adminId")?.Value;
|
|
if (string.IsNullOrEmpty(adminIdClaim) || !long.TryParse(adminIdClaim, out var adminId))
|
|
throw SpmsException.Unauthorized("인증 정보가 유효하지 않습니다.");
|
|
|
|
var result = await _authService.UpdateProfileAsync(adminId, request);
|
|
return Ok(ApiResponse<ProfileResponseDto>.Success(result));
|
|
}
|
|
|
|
[HttpPost("activity/list")]
|
|
[SwaggerOperation(
|
|
Summary = "활동 내역 조회",
|
|
Description = "현재 로그인된 관리자의 활동 내역을 페이징 조회합니다.")]
|
|
[SwaggerResponse(200, "조회 성공", typeof(ApiResponse<ActivityListResponseDto>))]
|
|
[SwaggerResponse(401, "인증되지 않은 요청")]
|
|
public async Task<IActionResult> GetActivityListAsync([FromBody] ActivityListRequestDto request)
|
|
{
|
|
var adminIdClaim = User.FindFirst("adminId")?.Value;
|
|
if (string.IsNullOrEmpty(adminIdClaim) || !long.TryParse(adminIdClaim, out var adminId))
|
|
throw SpmsException.Unauthorized("인증 정보가 유효하지 않습니다.");
|
|
|
|
var result = await _authService.GetActivityListAsync(adminId, request);
|
|
return Ok(ApiResponse<ActivityListResponseDto>.Success(result));
|
|
}
|
|
}
|