Persist generated/printed/downstream labels in t_order_file, drop Order.LabelUrl generate-status fields, and expose file list/upload/delete APIs with customer read-only systemLabel access. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using Fake.Application;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Oms.Application.Dtos.Orders;
|
|
using Oms.Application.Shared;
|
|
|
|
namespace Oms.Application.Services.Orders;
|
|
|
|
public partial class OrderService
|
|
{
|
|
private OrderFileManager OrderFileManager =>
|
|
LazyServiceProvider.GetRequiredService<OrderFileManager>();
|
|
|
|
/// <summary>
|
|
/// 查询订单附件(按类型分组)。客户登录仅返回系统面单。
|
|
/// </summary>
|
|
[HttpGet("/order/files")]
|
|
public async Task<OrderFileGroupedOutput> GetOrderFilesAsync([FromQuery] int orderId)
|
|
{
|
|
await GetOrderOrThrowAsync(orderId);
|
|
var customerView = OmsSessionHelper.IsCustomerLogin(CurrentUser);
|
|
return await OrderFileManager.GetGroupedAsync(orderId, customerView);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上传订单附件。客户账号禁止上传。
|
|
/// </summary>
|
|
[HttpPost("/order/files/upload")]
|
|
[Consumes("multipart/form-data")]
|
|
public async Task<List<OrderFileItemOutput>> UploadOrderFilesAsync(
|
|
[FromForm] int orderId,
|
|
[FromForm] string fileType,
|
|
[FromForm] List<IFormFile> files)
|
|
{
|
|
await GetOrderOrThrowAsync(orderId);
|
|
var collection = new FormFileCollection();
|
|
foreach (var file in files ?? [])
|
|
{
|
|
collection.Add(file);
|
|
}
|
|
|
|
return await OrderFileManager.UploadAsync(
|
|
orderId,
|
|
fileType,
|
|
collection,
|
|
CurrentUser.GetId<int>(),
|
|
OmsSessionHelper.IsCustomerLogin(CurrentUser));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除订单附件。客户账号禁止删除。
|
|
/// </summary>
|
|
[HttpPost("/order/files/delete")]
|
|
public async Task DeleteOrderFileAsync([FromBody] OrderFileDeleteInput input)
|
|
{
|
|
if (input == null || input.Id <= 0)
|
|
{
|
|
throw new BusinessException("附件 Id 无效");
|
|
}
|
|
|
|
var entity = await LazyServiceProvider
|
|
.GetRequiredService<Domain.OrdersAggregate.Repositories.IOrderFileRepository>()
|
|
.FirstOrDefaultAsync(x => x.Id == input.Id)
|
|
?? throw new BusinessException("附件不存在");
|
|
|
|
await GetOrderOrThrowAsync(entity.OrderId);
|
|
await OrderFileManager.DeleteAsync(
|
|
input.Id,
|
|
OmsSessionHelper.IsCustomerLogin(CurrentUser));
|
|
}
|
|
}
|