forked from gongxuegit/tiku-backend.net
feat: add tenant content navigation management endpoints
This commit is contained in:
238
Tiku.Application/Content/ContentManagementModels.cs
Normal file
238
Tiku.Application/Content/ContentManagementModels.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using System.Text.Json;
|
||||
using Tiku.Application.Catalog;
|
||||
using Tiku.Domain.Content;
|
||||
|
||||
namespace Tiku.Application.Content;
|
||||
|
||||
public sealed record ContentManagementActor(Guid TenantId, Guid UserId);
|
||||
|
||||
public sealed record ContentManagementFilter(
|
||||
Guid? RegionId = null,
|
||||
Guid? EntryId = null,
|
||||
Guid? NodeId = null,
|
||||
Guid? CollectionId = null,
|
||||
string? ParentId = null,
|
||||
string? EntryType = null,
|
||||
string? CollectionType = null,
|
||||
string? Mode = null,
|
||||
string? MarkerType = null,
|
||||
string? Keyword = null,
|
||||
bool IncludeInactive = false,
|
||||
int? Limit = null);
|
||||
|
||||
public sealed record UpsertContentEntryCommand(
|
||||
Guid? Id,
|
||||
Guid? RegionId,
|
||||
string? LegacyId,
|
||||
string? EntryKey,
|
||||
string Name,
|
||||
string? EntryType,
|
||||
string? Icon,
|
||||
string? Route,
|
||||
string? Description,
|
||||
string? Visibility,
|
||||
JsonElement AccessRules,
|
||||
JsonElement LayoutConfig,
|
||||
int? Order,
|
||||
bool? IsActive);
|
||||
|
||||
public sealed record UpsertContentNodeCommand(
|
||||
Guid? Id,
|
||||
Guid EntryId,
|
||||
Guid? RegionId,
|
||||
Guid? ParentId,
|
||||
string? LegacyId,
|
||||
string? NodeKey,
|
||||
string Name,
|
||||
string? NodeType,
|
||||
string? MarkerType,
|
||||
JsonElement MarkerConfig,
|
||||
int? Order,
|
||||
bool? IsActive,
|
||||
bool? IsSelectable,
|
||||
bool? IsLeaf,
|
||||
JsonElement AccessRules,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record UpsertQuestionCollectionCommand(
|
||||
Guid? Id,
|
||||
Guid? RegionId,
|
||||
Guid? EntryId,
|
||||
Guid? NodeId,
|
||||
Guid? SubjectId,
|
||||
Guid? CategoryId,
|
||||
Guid? QuestionBankId,
|
||||
string? LegacyId,
|
||||
string Name,
|
||||
string? CollectionType,
|
||||
string? SourceType,
|
||||
JsonElement Filters,
|
||||
decimal? TotalScore,
|
||||
int? DurationMinutes,
|
||||
string? Status,
|
||||
int? Order,
|
||||
JsonElement AccessRules,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record ReplaceCollectionItemsCommand(
|
||||
Guid CollectionId,
|
||||
IReadOnlyCollection<CollectionQuestionCommand> Questions);
|
||||
|
||||
public sealed record CollectionQuestionCommand(
|
||||
Guid QuestionId,
|
||||
string? SectionKey,
|
||||
int? Order,
|
||||
decimal? Score,
|
||||
bool? Required,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record UpsertPracticeBlueprintCommand(
|
||||
Guid? Id,
|
||||
Guid? RegionId,
|
||||
Guid? EntryId,
|
||||
Guid? NodeId,
|
||||
Guid? CollectionId,
|
||||
string? LegacyId,
|
||||
string Name,
|
||||
string? Mode,
|
||||
string? AssemblyType,
|
||||
int? QuestionLimit,
|
||||
int? DurationMinutes,
|
||||
decimal? TotalScore,
|
||||
decimal? PassScore,
|
||||
JsonElement Sections,
|
||||
JsonElement Rules,
|
||||
JsonElement AccessRules,
|
||||
string? Status,
|
||||
int? Order);
|
||||
|
||||
public sealed record ContentEntryManagementItem(
|
||||
Guid Id,
|
||||
Guid? RegionId,
|
||||
string? LegacyId,
|
||||
string EntryKey,
|
||||
string Name,
|
||||
ContentEntryType EntryType,
|
||||
string? Icon,
|
||||
string? Route,
|
||||
string? Description,
|
||||
ContentVisibility Visibility,
|
||||
JsonElement AccessRules,
|
||||
JsonElement LayoutConfig,
|
||||
int Order,
|
||||
bool IsActive,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset? UpdatedAt);
|
||||
|
||||
public sealed record ContentNodeManagementItem(
|
||||
Guid Id,
|
||||
Guid EntryId,
|
||||
Guid? RegionId,
|
||||
Guid? ParentId,
|
||||
string? LegacyId,
|
||||
string? NodeKey,
|
||||
string Name,
|
||||
ContentNodeType NodeType,
|
||||
ContentMarkerType? MarkerType,
|
||||
JsonElement MarkerConfig,
|
||||
string? Path,
|
||||
int Depth,
|
||||
int Order,
|
||||
bool IsActive,
|
||||
bool IsSelectable,
|
||||
bool IsLeaf,
|
||||
JsonElement AccessRules,
|
||||
JsonElement Metadata,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset? UpdatedAt);
|
||||
|
||||
public sealed record QuestionCollectionManagementItem(
|
||||
Guid Id,
|
||||
Guid? RegionId,
|
||||
Guid? EntryId,
|
||||
Guid? NodeId,
|
||||
Guid? SubjectId,
|
||||
Guid? CategoryId,
|
||||
Guid? QuestionBankId,
|
||||
string? LegacyId,
|
||||
string Name,
|
||||
QuestionCollectionType CollectionType,
|
||||
QuestionCollectionSourceType SourceType,
|
||||
JsonElement Filters,
|
||||
int QuestionCount,
|
||||
decimal? TotalScore,
|
||||
int? DurationMinutes,
|
||||
ContentStatus Status,
|
||||
int Order,
|
||||
JsonElement AccessRules,
|
||||
JsonElement Metadata,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset? UpdatedAt);
|
||||
|
||||
public sealed record QuestionCollectionItemManagementItem(
|
||||
Guid Id,
|
||||
Guid CollectionId,
|
||||
Guid QuestionId,
|
||||
string? SectionKey,
|
||||
int Order,
|
||||
decimal? Score,
|
||||
bool Required,
|
||||
JsonElement Metadata);
|
||||
|
||||
public sealed record PracticeBlueprintManagementItem(
|
||||
Guid Id,
|
||||
Guid? RegionId,
|
||||
Guid? EntryId,
|
||||
Guid? NodeId,
|
||||
Guid? CollectionId,
|
||||
string? LegacyId,
|
||||
string Name,
|
||||
PracticeMode Mode,
|
||||
PracticeAssemblyType AssemblyType,
|
||||
int? QuestionLimit,
|
||||
int? DurationMinutes,
|
||||
decimal? TotalScore,
|
||||
decimal? PassScore,
|
||||
JsonElement Sections,
|
||||
JsonElement Rules,
|
||||
JsonElement AccessRules,
|
||||
ContentStatus Status,
|
||||
int Order,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset? UpdatedAt);
|
||||
|
||||
public sealed record ContentManagementResult<TItem>(TItem Item);
|
||||
|
||||
public sealed record CollectionItemsReplaceResult(
|
||||
Guid CollectionId,
|
||||
int QuestionCount,
|
||||
IReadOnlyCollection<QuestionCollectionItemManagementItem> Items);
|
||||
|
||||
public sealed record ImportFieldSpec(
|
||||
string Field,
|
||||
string Label,
|
||||
bool Required,
|
||||
IReadOnlyCollection<string> Aliases,
|
||||
string Description,
|
||||
JsonElement Example);
|
||||
|
||||
public sealed record ImportFieldMappingItem(
|
||||
string ImportType,
|
||||
string Title,
|
||||
string Description,
|
||||
IReadOnlyCollection<ImportFieldSpec> Fields,
|
||||
IReadOnlyCollection<string> RequiredFields);
|
||||
|
||||
public sealed record ImportTemplateItem(
|
||||
string ImportType,
|
||||
string Format,
|
||||
string FileName,
|
||||
string MimeType,
|
||||
string ContentBase64,
|
||||
string ContentPreview,
|
||||
IReadOnlyCollection<ImportFieldSpec> Fields);
|
||||
|
||||
public sealed class ContentManagementException(string message, string code) : Exception(message)
|
||||
{
|
||||
public string Code { get; } = code;
|
||||
}
|
||||
55
Tiku.Application/Content/IContentManagementService.cs
Normal file
55
Tiku.Application/Content/IContentManagementService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Tiku.Application.Catalog;
|
||||
|
||||
namespace Tiku.Application.Content;
|
||||
|
||||
public interface IContentManagementService
|
||||
{
|
||||
Task<CatalogList<ContentEntryManagementItem>> GetEntriesAsync(
|
||||
ContentManagementActor actor,
|
||||
ContentManagementFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ContentManagementResult<ContentEntryManagementItem>> UpsertEntryAsync(
|
||||
ContentManagementActor actor,
|
||||
UpsertContentEntryCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CatalogList<ContentNodeManagementItem>> GetNodesAsync(
|
||||
ContentManagementActor actor,
|
||||
ContentManagementFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ContentManagementResult<ContentNodeManagementItem>> UpsertNodeAsync(
|
||||
ContentManagementActor actor,
|
||||
UpsertContentNodeCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CatalogList<QuestionCollectionManagementItem>> GetCollectionsAsync(
|
||||
ContentManagementActor actor,
|
||||
ContentManagementFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ContentManagementResult<QuestionCollectionManagementItem>> UpsertCollectionAsync(
|
||||
ContentManagementActor actor,
|
||||
UpsertQuestionCollectionCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CollectionItemsReplaceResult> ReplaceCollectionItemsAsync(
|
||||
ContentManagementActor actor,
|
||||
ReplaceCollectionItemsCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CatalogList<PracticeBlueprintManagementItem>> GetPracticeBlueprintsAsync(
|
||||
ContentManagementActor actor,
|
||||
ContentManagementFilter filter,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<ContentManagementResult<PracticeBlueprintManagementItem>> UpsertPracticeBlueprintAsync(
|
||||
ContentManagementActor actor,
|
||||
UpsertPracticeBlueprintCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
ImportFieldMappingItem GetImportFieldMapping(string importType);
|
||||
|
||||
ImportTemplateItem GetImportTemplate(string importType, string? format);
|
||||
}
|
||||
Reference in New Issue
Block a user