improvement: 관리자 기기 목록 API 확장 (#237) #238
|
|
@ -21,4 +21,10 @@ public class DeviceListRequestDto
|
||||||
|
|
||||||
[JsonPropertyName("is_active")]
|
[JsonPropertyName("is_active")]
|
||||||
public bool? IsActive { get; set; }
|
public bool? IsActive { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("keyword")]
|
||||||
|
public string? Keyword { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("marketing_agreed")]
|
||||||
|
public bool? MarketingAgreed { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,28 @@ public class DeviceSummaryDto
|
||||||
|
|
||||||
[JsonPropertyName("last_active_at")]
|
[JsonPropertyName("last_active_at")]
|
||||||
public DateTime? LastActiveAt { get; set; }
|
public DateTime? LastActiveAt { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("device_token")]
|
||||||
|
public string DeviceToken { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonPropertyName("service_name")]
|
||||||
|
public string ServiceName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonPropertyName("service_code")]
|
||||||
|
public string ServiceCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[JsonPropertyName("os_version")]
|
||||||
|
public string? OsVersion { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("app_version")]
|
||||||
|
public string? AppVersion { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("marketing_agreed")]
|
||||||
|
public bool MarketingAgreed { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("is_active")]
|
||||||
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("created_at")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,8 @@ public class DeviceService : IDeviceService
|
||||||
|
|
||||||
var (items, totalCount) = await _deviceRepository.GetPagedAsync(
|
var (items, totalCount) = await _deviceRepository.GetPagedAsync(
|
||||||
serviceId, request.Page, request.Size,
|
serviceId, request.Page, request.Size,
|
||||||
platform, request.PushAgreed, request.IsActive, request.Tags);
|
platform, request.PushAgreed, request.IsActive, request.Tags,
|
||||||
|
request.Keyword, request.MarketingAgreed);
|
||||||
|
|
||||||
var totalPages = (int)Math.Ceiling((double)totalCount / request.Size);
|
var totalPages = (int)Math.Ceiling((double)totalCount / request.Size);
|
||||||
|
|
||||||
|
|
@ -140,7 +141,15 @@ public class DeviceService : IDeviceService
|
||||||
Model = d.DeviceModel,
|
Model = d.DeviceModel,
|
||||||
PushAgreed = d.PushAgreed,
|
PushAgreed = d.PushAgreed,
|
||||||
Tags = ParseTags(d.Tags),
|
Tags = ParseTags(d.Tags),
|
||||||
LastActiveAt = d.UpdatedAt
|
LastActiveAt = d.UpdatedAt,
|
||||||
|
DeviceToken = d.DeviceToken,
|
||||||
|
ServiceName = d.Service?.ServiceName ?? string.Empty,
|
||||||
|
ServiceCode = d.Service?.ServiceCode ?? string.Empty,
|
||||||
|
OsVersion = d.OsVersion,
|
||||||
|
AppVersion = d.AppVersion,
|
||||||
|
MarketingAgreed = d.MarketingAgreed,
|
||||||
|
IsActive = d.IsActive,
|
||||||
|
CreatedAt = d.CreatedAt
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
Pagination = new DTOs.Notice.PaginationDto
|
Pagination = new DTOs.Notice.PaginationDto
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,6 @@ public interface IDeviceRepository : IRepository<Device>
|
||||||
Task<(IReadOnlyList<Device> Items, int TotalCount)> GetPagedAsync(
|
Task<(IReadOnlyList<Device> Items, int TotalCount)> GetPagedAsync(
|
||||||
long? serviceId, int page, int size,
|
long? serviceId, int page, int size,
|
||||||
Platform? platform = null, bool? pushAgreed = null,
|
Platform? platform = null, bool? pushAgreed = null,
|
||||||
bool? isActive = null, List<int>? tags = null);
|
bool? isActive = null, List<int>? tags = null,
|
||||||
|
string? keyword = null, bool? marketingAgreed = null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ public class DeviceRepository : Repository<Device>, IDeviceRepository
|
||||||
public async Task<(IReadOnlyList<Device> Items, int TotalCount)> GetPagedAsync(
|
public async Task<(IReadOnlyList<Device> Items, int TotalCount)> GetPagedAsync(
|
||||||
long? serviceId, int page, int size,
|
long? serviceId, int page, int size,
|
||||||
Platform? platform = null, bool? pushAgreed = null,
|
Platform? platform = null, bool? pushAgreed = null,
|
||||||
bool? isActive = null, List<int>? tags = null)
|
bool? isActive = null, List<int>? tags = null,
|
||||||
|
string? keyword = null, bool? marketingAgreed = null)
|
||||||
{
|
{
|
||||||
IQueryable<Device> query = _dbSet;
|
IQueryable<Device> query = _dbSet.Include(d => d.Service);
|
||||||
|
|
||||||
if (serviceId.HasValue)
|
if (serviceId.HasValue)
|
||||||
query = query.Where(d => d.ServiceId == serviceId.Value);
|
query = query.Where(d => d.ServiceId == serviceId.Value);
|
||||||
|
|
||||||
|
|
@ -49,6 +51,18 @@ public class DeviceRepository : Repository<Device>, IDeviceRepository
|
||||||
if (isActive.HasValue)
|
if (isActive.HasValue)
|
||||||
query = query.Where(d => d.IsActive == isActive.Value);
|
query = query.Where(d => d.IsActive == isActive.Value);
|
||||||
|
|
||||||
|
if (marketingAgreed.HasValue)
|
||||||
|
query = query.Where(d => d.MarketingAgreed == marketingAgreed.Value);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
|
{
|
||||||
|
var trimmed = keyword.Trim();
|
||||||
|
if (long.TryParse(trimmed, out var deviceId))
|
||||||
|
query = query.Where(d => d.Id == deviceId || d.DeviceToken.Contains(trimmed));
|
||||||
|
else
|
||||||
|
query = query.Where(d => d.DeviceToken.Contains(trimmed));
|
||||||
|
}
|
||||||
|
|
||||||
if (tags != null && tags.Count > 0)
|
if (tags != null && tags.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var tag in tags)
|
foreach (var tag in tags)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user