9 changed files with 111 additions and 1 deletions
@ -0,0 +1,8 @@ |
|||
namespace LINGYUN.Abp.AIManagement.Tools; |
|||
public static class AIToolDefinitionRecordConsts |
|||
{ |
|||
public static int MaxNameLength { get; set; } = 64; |
|||
public static int MaxProviderLength { get; set; } = 20; |
|||
public static int MaxDescriptionLength { get; set; } = 128; |
|||
public static int MaxStateCheckersLength { get; set; } = 256; |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using JetBrains.Annotations; |
|||
using System; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities.Auditing; |
|||
|
|||
namespace LINGYUN.Abp.AIManagement.Tools; |
|||
public class AIToolDefinitionRecord : AuditedAggregateRoot<Guid> |
|||
{ |
|||
public string Name { get; private set; } |
|||
|
|||
public string Provider { get; private set; } |
|||
|
|||
public string? Description { get; set; } |
|||
|
|||
public bool IsEnabled { get; set; } |
|||
|
|||
public bool IsSystem { get; set; } |
|||
|
|||
public string? StateCheckers { get; set; } |
|||
protected AIToolDefinitionRecord() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public AIToolDefinitionRecord( |
|||
[NotNull] string name, |
|||
[NotNull] string provider, |
|||
[CanBeNull] string? description = null) |
|||
{ |
|||
Name = Check.NotNullOrWhiteSpace(name, nameof(name), AIToolDefinitionRecordConsts.MaxNameLength); |
|||
Provider = Check.NotNullOrWhiteSpace(provider, nameof(provider), AIToolDefinitionRecordConsts.MaxProviderLength); |
|||
Description = Check.Length(description, nameof(description), AIToolDefinitionRecordConsts.MaxDescriptionLength); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories; |
|||
|
|||
namespace LINGYUN.Abp.AIManagement.Tools; |
|||
public interface IAIToolDefinitionRecordRepository : IBasicRepository<AIToolDefinitionRecord, Guid> |
|||
{ |
|||
Task<AIToolDefinitionRecord?> FindByNameAsync( |
|||
string name, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using LINGYUN.Abp.AIManagement.Tools; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace LINGYUN.Abp.AIManagement.EntityFrameworkCore; |
|||
public class EfCoreAIToolDefinitionRecordRepository : |
|||
EfCoreRepository<IAIManagementDbContext, AIToolDefinitionRecord, Guid>, |
|||
IAIToolDefinitionRecordRepository |
|||
{ |
|||
public EfCoreAIToolDefinitionRecordRepository( |
|||
IDbContextProvider<IAIManagementDbContext> dbContextProvider) |
|||
: base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public async virtual Task<AIToolDefinitionRecord?> FindByNameAsync(string name, CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetQueryableAsync()) |
|||
.Where(x => x.Name == name) |
|||
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue