All checks were successful
Build and Deploy / deploy (push) Successful in 58s
下单/导入在 9610Summary 时校验并落库 ExportQualificationId(可回落默认备案),写入 9610 申报企业信息;专线小包模板长宽高改必填并增加资质备案列。 Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Fake.DependencyInjection;
|
|
using Oms.Domain.CustomersAggregate.Entities;
|
|
using Oms.Domain.CustomersAggregate.Repositories;
|
|
using Oms.SqlSugarCore.Repositories;
|
|
|
|
namespace Oms.SqlSugarCore.Customers;
|
|
|
|
public class CustomerExportQualificationRepository
|
|
: OmsSqlSugarRepository<CustomerExportQualification>,
|
|
ICustomerExportQualificationRepository,
|
|
IScopedDependency
|
|
{
|
|
public Task<CustomerExportQualification?> GetOwnedAsync(
|
|
int id,
|
|
int customerId,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
return FirstOrDefaultAsync(x => x.Id == id && x.CustomerId == customerId, cancellationToken);
|
|
}
|
|
|
|
public Task<CustomerExportQualification?> GetDefaultAsync(
|
|
int customerId,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
return FirstOrDefaultAsync(x => x.CustomerId == customerId && x.IsDefault == 1, cancellationToken);
|
|
}
|
|
|
|
public async Task ClearDefaultAsync(
|
|
int customerId,
|
|
int? excludeId = null,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
var hasExcludeId = excludeId.HasValue;
|
|
var excludeIdValue = excludeId.GetValueOrDefault();
|
|
var list = await GetListAsync(
|
|
x => x.CustomerId == customerId
|
|
&& x.IsDefault == 1
|
|
&& (!hasExcludeId || x.Id != excludeIdValue),
|
|
cancellationToken: cancellationToken);
|
|
if (list.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
foreach (var item in list)
|
|
{
|
|
item.IsDefault = 0;
|
|
await UpdateAsync(item);
|
|
}
|
|
}
|
|
}
|