From 48049bba9e1475696638957ad1ffd323936bc954 Mon Sep 17 00:00:00 2001 From: SEAN Date: Wed, 25 Feb 2026 17:06:11 +0900 Subject: [PATCH] =?UTF-8?q?improvement:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20?= =?UTF-8?q?=EA=B8=B0=EA=B8=B0=20=EC=82=AD=EC=A0=9C/=EC=B0=A8=EB=8B=A8=20AP?= =?UTF-8?q?I=20=EC=B6=94=EA=B0=80=20(#239)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - IDeviceService: AdminDeleteAsync(long deviceId) 추가 - DeviceService: Device 조회 → IsActive=false → 토큰 캐시 무효화 - DeviceController: POST /v1/in/device/admin/delete [Authorize] 엔드포인트 추가 - 기존 SDK 삭제 API와 분리, JWT 인증 기반 관리자 전용 Closes #239 --- SPMS.API/Controllers/DeviceController.cs | 9 +++++++++ SPMS.Application/Interfaces/IDeviceService.cs | 1 + SPMS.Application/Services/DeviceService.cs | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/SPMS.API/Controllers/DeviceController.cs b/SPMS.API/Controllers/DeviceController.cs index 093c7bc..ab3f1a4 100644 --- a/SPMS.API/Controllers/DeviceController.cs +++ b/SPMS.API/Controllers/DeviceController.cs @@ -73,6 +73,15 @@ public class DeviceController : ControllerBase return Ok(ApiResponse.Success()); } + [HttpPost("admin/delete")] + [Authorize] + [SwaggerOperation(Summary = "관리자 기기 삭제", Description = "관리자가 기기를 삭제(비활성화)합니다. 삭제 즉시 발송이 차단됩니다. JWT 인증 필요.")] + public async Task AdminDeleteAsync([FromBody] DeviceDeleteRequestDto request) + { + await _deviceService.AdminDeleteAsync(request.DeviceId); + return Ok(ApiResponse.Success()); + } + [HttpPost("list")] [Authorize] [SwaggerOperation(Summary = "디바이스 목록", Description = "대시보드에서 디바이스 목록을 조회합니다. JWT 인증 필요.")] diff --git a/SPMS.Application/Interfaces/IDeviceService.cs b/SPMS.Application/Interfaces/IDeviceService.cs index b2cdb44..a8d9a98 100644 --- a/SPMS.Application/Interfaces/IDeviceService.cs +++ b/SPMS.Application/Interfaces/IDeviceService.cs @@ -8,6 +8,7 @@ public interface IDeviceService Task GetInfoAsync(long serviceId, DeviceInfoRequestDto request); Task UpdateAsync(long serviceId, DeviceUpdateRequestDto request); Task DeleteAsync(long serviceId, DeviceDeleteRequestDto request); + Task AdminDeleteAsync(long deviceId); Task GetListAsync(long? serviceId, DeviceListRequestDto request); Task SetTagsAsync(long serviceId, DeviceTagsRequestDto request); Task SetAgreeAsync(long serviceId, DeviceAgreeRequestDto request); diff --git a/SPMS.Application/Services/DeviceService.cs b/SPMS.Application/Services/DeviceService.cs index bde9344..68ccdbd 100644 --- a/SPMS.Application/Services/DeviceService.cs +++ b/SPMS.Application/Services/DeviceService.cs @@ -119,6 +119,19 @@ public class DeviceService : IDeviceService await _tokenCache.InvalidateAsync(serviceId, device.Id); } + public async Task AdminDeleteAsync(long deviceId) + { + var device = await _deviceRepository.GetByIdAsync(deviceId); + if (device == null) + throw new SpmsException(ErrorCodes.DeviceNotFound, "존재하지 않는 디바이스입니다.", 404); + + device.IsActive = false; + device.UpdatedAt = DateTime.UtcNow; + _deviceRepository.Update(device); + await _unitOfWork.SaveChangesAsync(); + await _tokenCache.InvalidateAsync(device.ServiceId, device.Id); + } + public async Task GetListAsync(long? serviceId, DeviceListRequestDto request) { Platform? platform = null; -- 2.45.1