fix(xhs): task/report 与 task/cancel 返回 JSON 响应
避免 Agent 客户端解析空 body 报「非 JSON 响应」导致任务上报失败。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
607e09433b
commit
f7be966adc
@ -136,6 +136,11 @@ public class XhsTaskReportInput
|
|||||||
public string? ErrorMessage { get; set; }
|
public string? ErrorMessage { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class XhsTaskReportOutput
|
||||||
|
{
|
||||||
|
public bool Ok { get; set; } = true;
|
||||||
|
}
|
||||||
|
|
||||||
public class XhsTaskListInput : XhsPageInput
|
public class XhsTaskListInput : XhsPageInput
|
||||||
{
|
{
|
||||||
public string? Status { get; set; }
|
public string? Status { get; set; }
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class XhsTaskService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/xhs/task/report")]
|
[HttpPost("/xhs/task/report")]
|
||||||
public async Task ReportAsync(XhsTaskReportInput input)
|
public async Task<XhsTaskReportOutput> ReportAsync(XhsTaskReportInput input)
|
||||||
{
|
{
|
||||||
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
||||||
var task = await TaskRepository.FirstOrDefaultAsync(x => x.Id == input.TaskId);
|
var task = await TaskRepository.FirstOrDefaultAsync(x => x.Id == input.TaskId);
|
||||||
@ -80,6 +80,7 @@ public class XhsTaskService : ApplicationService
|
|||||||
await TaskRepository.UpdateAsync(task);
|
await TaskRepository.UpdateAsync(task);
|
||||||
await SyncPublishRecordAsync(task, status, input);
|
await SyncPublishRecordAsync(task, status, input);
|
||||||
await SyncAnalysisSessionAsync(task, status, input);
|
await SyncAnalysisSessionAsync(task, status, input);
|
||||||
|
return new XhsTaskReportOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/xhs/task/list")]
|
[HttpPost("/xhs/task/list")]
|
||||||
@ -104,7 +105,7 @@ public class XhsTaskService : ApplicationService
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("/xhs/task/cancel")]
|
[HttpPost("/xhs/task/cancel")]
|
||||||
public async Task CancelAsync(XhsTaskCancelInput input)
|
public async Task<XhsTaskReportOutput> CancelAsync(XhsTaskCancelInput input)
|
||||||
{
|
{
|
||||||
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
var customerId = await OmsSessionHelper.ResolveXhsCustomerIdAsync(CustomerRepository, CurrentUser);
|
||||||
var task = await TaskRepository.FirstOrDefaultAsync(x => x.Id == input.TaskId);
|
var task = await TaskRepository.FirstOrDefaultAsync(x => x.Id == input.TaskId);
|
||||||
@ -121,6 +122,7 @@ public class XhsTaskService : ApplicationService
|
|||||||
task.Status = XhsTaskStatusCodes.Cancelled;
|
task.Status = XhsTaskStatusCodes.Cancelled;
|
||||||
task.FinishedAt = DateTime.Now;
|
task.FinishedAt = DateTime.Now;
|
||||||
await TaskRepository.UpdateAsync(task);
|
await TaskRepository.UpdateAsync(task);
|
||||||
|
return new XhsTaskReportOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SyncAnalysisSessionAsync(XhsTask task, string status, XhsTaskReportInput input)
|
private async Task SyncAnalysisSessionAsync(XhsTask task, string status, XhsTaskReportInput input)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user