improvement: 태그 관리 API 프론트엔드 연동 수정 (#267)
- TagSummaryDto에 tag_index 필드 추가 (서비스별 Id 순서 1-based 동적 계산) - ServiceSummaryDto/ServiceResponseDto에 service_id 필드 추가 - ServiceCodeMiddleware OPTIONAL_FOR_ADMIN에 /v1/in/tag 경로 추가 Closes #267
This commit is contained in:
parent
432fde0baf
commit
1ca4980293
|
|
@ -34,7 +34,8 @@ public class ServiceCodeMiddleware
|
||||||
// === OPTIONAL_FOR_ADMIN: 관리자는 X-Service-Code 선택 ===
|
// === OPTIONAL_FOR_ADMIN: 관리자는 X-Service-Code 선택 ===
|
||||||
if (path.StartsWithSegments("/v1/in/stats") ||
|
if (path.StartsWithSegments("/v1/in/stats") ||
|
||||||
path.StartsWithSegments("/v1/in/device/list") ||
|
path.StartsWithSegments("/v1/in/device/list") ||
|
||||||
path.StartsWithSegments("/v1/in/message/list"))
|
path.StartsWithSegments("/v1/in/message/list") ||
|
||||||
|
path.StartsWithSegments("/v1/in/tag"))
|
||||||
{
|
{
|
||||||
if (context.Request.Headers.TryGetValue("X-Service-Code", out var optionalCode) &&
|
if (context.Request.Headers.TryGetValue("X-Service-Code", out var optionalCode) &&
|
||||||
!string.IsNullOrWhiteSpace(optionalCode))
|
!string.IsNullOrWhiteSpace(optionalCode))
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public class ServiceListResponseDto
|
||||||
|
|
||||||
public class ServiceSummaryDto
|
public class ServiceSummaryDto
|
||||||
{
|
{
|
||||||
|
public long ServiceId { get; set; }
|
||||||
public string ServiceCode { get; set; } = string.Empty;
|
public string ServiceCode { get; set; } = string.Empty;
|
||||||
public string ServiceName { get; set; } = string.Empty;
|
public string ServiceName { get; set; } = string.Empty;
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ namespace SPMS.Application.DTOs.Service;
|
||||||
|
|
||||||
public class ServiceResponseDto
|
public class ServiceResponseDto
|
||||||
{
|
{
|
||||||
|
public long ServiceId { get; set; }
|
||||||
public string ServiceCode { get; set; } = string.Empty;
|
public string ServiceCode { get; set; } = string.Empty;
|
||||||
public string ServiceName { get; set; } = string.Empty;
|
public string ServiceName { get; set; } = string.Empty;
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ public class TagListResponseDto
|
||||||
|
|
||||||
public class TagSummaryDto
|
public class TagSummaryDto
|
||||||
{
|
{
|
||||||
|
[JsonPropertyName("tag_index")]
|
||||||
|
public int TagIndex { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("tag_id")]
|
[JsonPropertyName("tag_id")]
|
||||||
public long TagId { get; set; }
|
public long TagId { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -982,6 +982,7 @@ public class ServiceManagementService : IServiceManagementService
|
||||||
{
|
{
|
||||||
return new ServiceSummaryDto
|
return new ServiceSummaryDto
|
||||||
{
|
{
|
||||||
|
ServiceId = service.Id,
|
||||||
ServiceCode = service.ServiceCode,
|
ServiceCode = service.ServiceCode,
|
||||||
ServiceName = service.ServiceName,
|
ServiceName = service.ServiceName,
|
||||||
Description = service.Description,
|
Description = service.Description,
|
||||||
|
|
@ -997,6 +998,7 @@ public class ServiceManagementService : IServiceManagementService
|
||||||
{
|
{
|
||||||
return new ServiceResponseDto
|
return new ServiceResponseDto
|
||||||
{
|
{
|
||||||
|
ServiceId = service.Id,
|
||||||
ServiceCode = service.ServiceCode,
|
ServiceCode = service.ServiceCode,
|
||||||
ServiceName = service.ServiceName,
|
ServiceName = service.ServiceName,
|
||||||
Description = service.Description,
|
Description = service.Description,
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,22 @@ public class TagService : ITagService
|
||||||
var tagIds = items.Select(t => t.Id).ToList();
|
var tagIds = items.Select(t => t.Id).ToList();
|
||||||
var deviceCounts = await _deviceRepository.GetDeviceCountsByTagIdsAsync(tagIds);
|
var deviceCounts = await _deviceRepository.GetDeviceCountsByTagIdsAsync(tagIds);
|
||||||
|
|
||||||
|
// 서비스별 태그 순번 계산 (Id 오름차순 기준 1-based)
|
||||||
|
var serviceIds = items.Select(t => t.ServiceId).Distinct().ToList();
|
||||||
|
var serviceTagOrders = new Dictionary<long, List<long>>();
|
||||||
|
foreach (var sid in serviceIds)
|
||||||
|
{
|
||||||
|
var allTags = await _tagRepository.FindAsync(t => t.ServiceId == sid);
|
||||||
|
serviceTagOrders[sid] = allTags.OrderBy(t => t.Id).Select(t => t.Id).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
var totalPages = (int)Math.Ceiling((double)totalCount / request.Size);
|
var totalPages = (int)Math.Ceiling((double)totalCount / request.Size);
|
||||||
|
|
||||||
return new TagListResponseDto
|
return new TagListResponseDto
|
||||||
{
|
{
|
||||||
Items = items.Select(t => new TagSummaryDto
|
Items = items.Select(t => new TagSummaryDto
|
||||||
{
|
{
|
||||||
|
TagIndex = serviceTagOrders[t.ServiceId].IndexOf(t.Id) + 1,
|
||||||
TagId = t.Id,
|
TagId = t.Id,
|
||||||
TagName = t.Name,
|
TagName = t.Name,
|
||||||
Description = t.Description,
|
Description = t.Description,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user