feat: include inquiry status changer in alerts
This commit is contained in:
@@ -62,7 +62,7 @@ public class InquiryServiceTests
|
||||
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default)
|
||||
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ namespace TaxBaik.Application.Services;
|
||||
public interface IInquiryNotificationService
|
||||
{
|
||||
Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default);
|
||||
Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default);
|
||||
Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
|
||||
int page, int pageSize, string? status = null, CancellationToken ct = default) =>
|
||||
await repository.GetPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), NormalizeOptionalStatus(status), ct);
|
||||
|
||||
public async Task UpdateStatusAsync(int id, string status, CancellationToken ct = default)
|
||||
public async Task UpdateStatusAsync(int id, string status, string? changedBy = null, CancellationToken ct = default)
|
||||
{
|
||||
if (!InquiryStatusMapper.TryParse(status, out var parsed))
|
||||
throw new ValidationException("지원하지 않는 문의 상태입니다.");
|
||||
@@ -59,7 +59,7 @@ public class InquiryService(IInquiryRepository repository, IInquiryNotificationS
|
||||
var newStatus = InquiryStatusMapper.ToStorageValue(parsed);
|
||||
|
||||
await repository.UpdateStatusAsync(id, newStatus, ct);
|
||||
await notificationService.NotifyStatusChangedAsync(id, inquiry.Name, inquiry.Phone, inquiry.ServiceType, previousStatus, newStatus, ct);
|
||||
await notificationService.NotifyStatusChangedAsync(id, inquiry.Name, inquiry.Phone, inquiry.ServiceType, previousStatus, newStatus, changedBy, ct);
|
||||
}
|
||||
|
||||
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||
|
||||
@@ -5,6 +5,6 @@ public sealed class NoopInquiryNotificationService : IInquiryNotificationService
|
||||
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default)
|
||||
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ else
|
||||
|
||||
try
|
||||
{
|
||||
await InquiryService.UpdateStatusAsync(inquiry.Id, status);
|
||||
await InquiryService.UpdateStatusAsync(inquiry.Id, status, "관리자");
|
||||
inquiry.Status = status;
|
||||
Snackbar.Add("상태가 변경되었습니다.", Severity.Success);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Security.Claims;
|
||||
using TaxBaik.Application.Services;
|
||||
|
||||
namespace TaxBaik.Web.Controllers;
|
||||
@@ -66,7 +67,8 @@ public class InquiryController : ControllerBase
|
||||
|
||||
try
|
||||
{
|
||||
await _inquiryService.UpdateStatusAsync(id, request.Status);
|
||||
var changedBy = User.FindFirstValue(ClaimTypes.Name) ?? User.Identity?.Name;
|
||||
await _inquiryService.UpdateStatusAsync(id, request.Status, changedBy);
|
||||
return Ok(new { message = "상태가 변경되었습니다." });
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
|
||||
}
|
||||
}
|
||||
|
||||
public async Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, CancellationToken ct = default)
|
||||
public async Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default)
|
||||
{
|
||||
var botToken = _configuration["Telegram:BotToken"];
|
||||
var chatId = _configuration["Telegram:ChatId"];
|
||||
@@ -82,6 +82,7 @@ public class TelegramInquiryNotificationService : IInquiryNotificationService
|
||||
.AppendLine($"이름: {name}")
|
||||
.AppendLine($"연락처: {phone}")
|
||||
.AppendLine($"상태: {FormatStatus(previousStatus)} -> {FormatStatus(newStatus)}")
|
||||
.AppendLine($"변경자: {(string.IsNullOrWhiteSpace(changedBy) ? "-" : changedBy)}")
|
||||
.AppendLine()
|
||||
.AppendLine($"답변 목록 링크: {adminLink}")
|
||||
.ToString();
|
||||
|
||||
Reference in New Issue
Block a user