feat: 实现租户列表查询接口
- 获取租户列表:GET /api/admin/v1/tenants - 用于填充租户下拉选择器 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,4 +34,23 @@ public sealed class EfTenantRepository(TakeoutAdminDbContext context) : ITenantR
|
||||
.Where(x => tenantIds.Contains(x.Id))
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IReadOnlyList<Tenant>> GetAllAsync(string? keyword, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// 1. 构建基础查询
|
||||
var query = context.Tenants
|
||||
.AsNoTracking()
|
||||
.Where(x => x.DeletedAt == null);
|
||||
|
||||
// 2. 应用关键字过滤
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
var normalized = keyword.Trim();
|
||||
query = query.Where(x => x.Name.Contains(normalized) || x.Code.Contains(normalized));
|
||||
}
|
||||
|
||||
// 3. 返回列表
|
||||
return await query.OrderBy(x => x.Code).ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user