feat: 文档管理 (#221)

Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
2024-11-27 15:52:23 +08:00
committed by GitHub
parent 71bfdaafa8
commit 7ed30406c9
89 changed files with 2748 additions and 141 deletions

View File

@@ -8,7 +8,7 @@ public static class UnitOfWorkManagerExtensions
/// <summary>
/// 事务操作
/// </summary>
public static async Task AtomicOperateAsync(this UnitOfWorkManager me, Func<Task> handle)
public static async Task AtomicOperateAsync(this UnitOfWorkManager me, Func<Task> handle, Func<Task> onErrorHandle = null)
{
var logger = LogHelper.Get<UnitOfWorkManager>();
using var unitOfWork = me.Begin();
@@ -25,6 +25,11 @@ public static class UnitOfWorkManagerExtensions
logger?.Warn(ex);
unitOfWork.Rollback();
logger?.Warn($"{Ln.事务已回滚}: {hashCode}");
if (onErrorHandle != null) {
await onErrorHandle().ConfigureAwait(false);
}
throw;
}
}

View File

@@ -16,7 +16,7 @@ public record Sys_DicCatalog : VersionEntity
public IEnumerable<Sys_DicCatalog> Children { get; init; }
/// <summary>
/// 字典编码
/// 字典目录编码
/// </summary>
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_63)]
[CsvIgnore]
@@ -32,7 +32,7 @@ public record Sys_DicCatalog : VersionEntity
public ICollection<Sys_DicContent> Contents { get; init; }
/// <summary>
/// 字典名称
/// 字典目录名称
/// </summary>
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_63)]
[CsvIgnore]

View File

@@ -0,0 +1,73 @@
namespace NetAdmin.Domain.DbMaps.Sys;
/// <summary>
/// 文档分类表
/// </summary>
[SqlIndex(Chars.FLG_DB_INDEX_PREFIX + nameof(Code), nameof(Code), true)]
[Table(Name = Chars.FLG_DB_TABLE_NAME_PREFIX + nameof(Sys_DocCatalog))]
public record Sys_DocCatalog : VersionEntity, IFieldOwner
{
/// <summary>
/// 子节点
/// </summary>
[CsvIgnore]
[JsonIgnore]
[Navigate(nameof(ParentId))]
public IEnumerable<Sys_DocCatalog> Children { get; init; }
/// <summary>
/// 文档分类编码
/// </summary>
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_63)]
[CsvIgnore]
[JsonIgnore]
public virtual string Code { get; init; }
/// <summary>
/// 文档内容集合
/// </summary>
[CsvIgnore]
[JsonIgnore]
[Navigate(nameof(Sys_DocContent.CatalogId))]
public ICollection<Sys_DocContent> Contents { get; init; }
/// <summary>
/// 文档分类名称
/// </summary>
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_63)]
[CsvIgnore]
[JsonIgnore]
public virtual string Name { get; init; }
/// <summary>
/// 拥有者
/// </summary>
[CsvIgnore]
[JsonIgnore]
[Navigate(nameof(OwnerId))]
public Sys_User Owner { get; init; }
/// <summary>
/// 拥有者部门编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long? OwnerDeptId { get; init; }
/// <summary>
/// 拥有者用户编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long? OwnerId { get; init; }
/// <summary>
/// 父编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long ParentId { get; init; }
}

View File

@@ -0,0 +1,86 @@
using NetAdmin.Domain.Enums.Sys;
namespace NetAdmin.Domain.DbMaps.Sys;
/// <summary>
/// 文档内容表
/// </summary>
[Table(Name = Chars.FLG_DB_TABLE_NAME_PREFIX + nameof(Sys_DocContent))]
public record Sys_DocContent : VersionEntity, IFieldEnabled, IFieldOwner
{
/// <summary>
/// 文档正文
/// </summary>
#if DBTYPE_SQLSERVER
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_MAX)]
#else
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
#endif
[CsvIgnore]
[JsonIgnore]
public virtual string Body { get; init; }
/// <summary>
/// 文档分类
/// </summary>
[CsvIgnore]
[JsonIgnore]
[Navigate(nameof(CatalogId))]
public Sys_DocCatalog Catalog { get; init; }
/// <summary>
/// 文档分类编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long CatalogId { get; init; }
/// <summary>
/// 是否启用
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual bool Enabled { get; init; }
/// <summary>
/// 拥有者
/// </summary>
[CsvIgnore]
[JsonIgnore]
[Navigate(nameof(OwnerId))]
public Sys_User Owner { get; init; }
/// <summary>
/// 拥有者部门编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long? OwnerDeptId { get; init; }
/// <summary>
/// 拥有者用户编号
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual long? OwnerId { get; init; }
/// <summary>
/// 文档标题
/// </summary>
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_255)]
[CsvIgnore]
[JsonIgnore]
public virtual string Title { get; init; }
/// <summary>
/// 可见性
/// </summary>
[Column]
[CsvIgnore]
[JsonIgnore]
public virtual ArchiveVisibilities Visibility { get; init; }
}

View File

@@ -0,0 +1,23 @@
using NetAdmin.Domain.DbMaps.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Catalog;
/// <summary>
/// 请求:创建文档分类
/// </summary>
public record CreateDocCatalogReq : Sys_DocCatalog
{
/// <inheritdoc cref="Sys_DocCatalog.Code" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.文档分类编码不能为空))]
public override string Code { get; init; }
/// <inheritdoc cref="Sys_DocCatalog.Name" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.文档分类名称不能为空))]
public override string Name { get; init; }
/// <inheritdoc cref="Sys_DocCatalog.ParentId" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long ParentId { get; init; }
}

View File

@@ -0,0 +1,11 @@
namespace NetAdmin.Domain.Dto.Sys.Doc.Catalog;
/// <summary>
/// 请求:编辑文档分类
/// </summary>
public sealed record EditDocCatalogReq : CreateDocCatalogReq
{
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
}

View File

@@ -0,0 +1,8 @@
using NetAdmin.Domain.DbMaps.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Catalog;
/// <summary>
/// 请求:查询文档分类
/// </summary>
public sealed record QueryDocCatalogReq : Sys_DocCatalog;

View File

@@ -0,0 +1,32 @@
using NetAdmin.Domain.DbMaps.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Catalog;
/// <summary>
/// 响应:查询文档分类
/// </summary>
public sealed record QueryDocCatalogRsp : Sys_DocCatalog
{
/// <inheritdoc cref="Sys_DocCatalog.Children" />
public new IEnumerable<QueryDocCatalogRsp> Children { get; init; }
/// <inheritdoc cref="Sys_DocCatalog.Code" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Code { get; init; }
/// <inheritdoc cref="EntityBase{T}.Id" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Id { get; init; }
/// <inheritdoc cref="Sys_DocCatalog.Name" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Name { get; init; }
/// <inheritdoc cref="Sys_DocCatalog.ParentId" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long ParentId { get; init; }
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
}

View File

@@ -0,0 +1,34 @@
using NetAdmin.Domain.DbMaps.Sys;
using NetAdmin.Domain.Enums.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 请求:创建文档内容
/// </summary>
public record CreateDocContentReq : Sys_DocContent
{
/// <inheritdoc cref="Sys_DocContent.Body" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.文档内容不能为空))]
public override string Body { get; init; }
/// <inheritdoc cref="Sys_DocContent.CatalogId" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.文档分类编号不能为空))]
public override long CatalogId { get; init; }
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; } = true;
/// <inheritdoc cref="Sys_DocContent.Title" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.文档标题不能为空))]
public override string Title { get; init; }
/// <inheritdoc cref="Sys_DocContent.Visibility" />
[EnumDataType(typeof(ArchiveVisibilities), ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.档案可见性不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override ArchiveVisibilities Visibility { get; init; }
}

View File

@@ -0,0 +1,11 @@
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 请求:编辑文档内容
/// </summary>
public sealed record EditDocContentReq : CreateDocContentReq
{
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
}

View File

@@ -0,0 +1,31 @@
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 响应:导出文档内容
/// </summary>
public sealed record ExportDocContentRsp : QueryDocContentRsp
{
/// <inheritdoc />
[CsvIndex(1)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.文档内容))]
public override string Body { get; init; }
/// <inheritdoc />
[CsvIndex(2)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.创建时间))]
public override DateTime CreatedTime { get; init; }
/// <inheritdoc />
[CsvIndex(3)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.是否启用))]
public override bool Enabled { get; init; }
/// <inheritdoc />
[CsvIndex(0)]
[CsvIgnore(false)]
[CsvName(nameof(Ln.文档标题))]
public override string Title { get; init; }
}

View File

@@ -0,0 +1,8 @@
using NetAdmin.Domain.DbMaps.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 请求:查询文档内容
/// </summary>
public sealed record QueryDocContentReq : Sys_DocContent;

View File

@@ -0,0 +1,38 @@
using NetAdmin.Domain.DbMaps.Sys;
using NetAdmin.Domain.Enums.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 响应:查询文档内容
/// </summary>
public record QueryDocContentRsp : Sys_DocContent
{
/// <inheritdoc cref="Sys_DocContent.Body" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Body { get; init; }
/// <inheritdoc cref="Sys_DocContent.CatalogId" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long CatalogId { get; init; }
/// <inheritdoc cref="IFieldCreatedTime.CreatedTime" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override DateTime CreatedTime { get; init; }
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; }
/// <inheritdoc cref="Sys_DocContent.Title" />
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Title { get; init; }
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
/// <inheritdoc cref="Sys_DocContent.Visibility" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override ArchiveVisibilities Visibility { get; init; }
}

View File

@@ -0,0 +1,17 @@
using NetAdmin.Domain.DbMaps.Sys;
namespace NetAdmin.Domain.Dto.Sys.Doc.Content;
/// <summary>
/// 请求:设置文档内容启用状态
/// </summary>
public sealed record SetDocContentEnabledReq : Sys_DocContent
{
/// <inheritdoc cref="IFieldEnabled.Enabled" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; }
/// <inheritdoc cref="IFieldVersion.Version" />
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override long Version { get; init; }
}

View File

@@ -0,0 +1,38 @@
namespace NetAdmin.Domain.Enums.Sys;
/// <summary>
/// 档案可见性
/// </summary>
[Export]
public enum ArchiveVisibilities
{
/// <summary>
/// 完全公开
/// </summary>
[ResourceDescription<Ln>(nameof(Ln.完全公开))]
Public = 1
,
/// <summary>
/// 登录用户
/// </summary>
[ResourceDescription<Ln>(nameof(Ln.登录用户))]
LogonUser = 2
,
/// <summary>
/// 部门可见
/// </summary>
[ResourceDescription<Ln>(nameof(Ln.部门可见))]
DeptUser = 3
,
/// <summary>
/// 自己可见
/// </summary>
[ResourceDescription<Ln>(nameof(Ln.自己可见))]
Self = 4
}

View File

@@ -25,7 +25,8 @@ public abstract class ApiResultHandler<T>
{
var naException = context.Exception switch {
NetAdminException ex => ex
, _ => context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT)
, _ => context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT) ||
context.Exception.Message.Contains(Chars.FLG_DB_EXCEPTION_UNIQUE_CONSTRAINT_CONFLICT)
? new NetAdminInvalidOperationException(Ln.)
: null
};

View File

@@ -16,6 +16,7 @@ public static class Chars
public const string FLG_CONTEXT_USER_INFO = nameof(FLG_CONTEXT_USER_INFO);
public const string FLG_CRON_PER_SECS = "* * * * * *";
public const string FLG_DB_EXCEPTION_PRIMARY_KEY_CONFLICT = "PRIMARY KEY";
public const string FLG_DB_EXCEPTION_UNIQUE_CONSTRAINT_CONFLICT = "UNIQUE constraint";
public const string FLG_DB_FIELD_TYPE_NVARCHAR = "nvarchar";
public const string FLG_DB_FIELD_TYPE_NVARCHAR_1022 = "nvarchar(1022)";
public const string FLG_DB_FIELD_TYPE_NVARCHAR_127 = "nvarchar(127)";

View File

@@ -0,0 +1,11 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
namespace NetAdmin.SysComponent.Application.Modules.Sys;
/// <summary>
/// 文档分类模块
/// </summary>
public interface IDocCatalogModule : ICrudModule<CreateDocCatalogReq, QueryDocCatalogRsp // 创建类型
, QueryDocCatalogReq, QueryDocCatalogRsp // 查询类型
, DelReq // 删除类型
>;

View File

@@ -0,0 +1,17 @@
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Application.Modules.Sys;
/// <summary>
/// 文档内容模块
/// </summary>
public interface IDocContentModule : ICrudModule<CreateDocContentReq, QueryDocContentRsp // 创建类型
, QueryDocContentReq, QueryDocContentRsp // 查询类型
, DelReq // 删除类型
>
{
/// <summary>
/// 启用/禁用文档内容
/// </summary>
Task<int> SetEnabledAsync(SetDocContentEnabledReq req);
}

View File

@@ -0,0 +1,95 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Application.Modules.Sys;
/// <summary>
/// 文档模块
/// </summary>
public interface IDocModule
{
/// <summary>
/// 批量删除文档分类
/// </summary>
Task<int> BulkDeleteCatalogAsync(BulkReq<DelReq> req);
/// <summary>
/// 批量删除文档内容
/// </summary>
Task<int> BulkDeleteContentAsync(BulkReq<DelReq> req);
/// <summary>
/// 创建文档分类
/// </summary>
Task<QueryDocCatalogRsp> CreateCatalogAsync(CreateDocCatalogReq req);
/// <summary>
/// 创建文档内容
/// </summary>
Task<QueryDocContentRsp> CreateContentAsync(CreateDocContentReq req);
/// <summary>
/// 删除文档分类
/// </summary>
Task<int> DeleteCatalogAsync(DelReq req);
/// <summary>
/// 删除文档内容
/// </summary>
Task<int> DeleteContentAsync(DelReq req);
/// <summary>
/// 编辑文档分类
/// </summary>
Task<int> EditCatalogAsync(EditDocCatalogReq req);
/// <summary>
/// 编辑文档内容
/// </summary>
Task<QueryDocContentRsp> EditContentAsync(EditDocContentReq req);
/// <summary>
/// 导出文档内容
/// </summary>
Task<IActionResult> ExportContentAsync(QueryReq<QueryDocContentReq> req);
/// <summary>
/// 获取单个文档分类
/// </summary>
Task<QueryDocCatalogRsp> GetCatalogAsync(QueryDocCatalogReq req);
/// <summary>
/// 获取单个文档内容
/// </summary>
Task<QueryDocContentRsp> GetContentAsync(QueryDocContentReq req);
/// <summary>
/// 分页查询文档分类
/// </summary>
Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDocCatalogReq> req);
/// <summary>
/// 分页查询文档内容
/// </summary>
Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryContentAsync(PagedQueryReq<QueryDocContentReq> req);
/// <summary>
/// 查询文档分类
/// </summary>
Task<IEnumerable<QueryDocCatalogRsp>> QueryCatalogAsync(QueryReq<QueryDocCatalogReq> req);
/// <summary>
/// 查询文档内容
/// </summary>
Task<IEnumerable<QueryDocContentRsp>> QueryContentAsync(QueryReq<QueryDocContentReq> req);
/// <summary>
/// 启用/禁用文档内容
/// </summary>
Task<int> SetEnabledAsync(SetDocContentEnabledReq req);
/// <summary>
/// 浏览文档内容
/// </summary>
Task<QueryDocContentRsp> ViewContentAsync(QueryDocContentReq req);
}

View File

@@ -0,0 +1,14 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
namespace NetAdmin.SysComponent.Application.Services.Sys.Dependency;
/// <summary>
/// 文档分类服务
/// </summary>
public interface IDocCatalogService : IService, IDocCatalogModule
{
/// <summary>
/// 编辑文档分类
/// </summary>
Task<int> EditAsync(EditDocCatalogReq req);
}

View File

@@ -0,0 +1,19 @@
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Application.Services.Sys.Dependency;
/// <summary>
/// 文档内容服务
/// </summary>
public interface IDocContentService : IService, IDocContentModule
{
/// <summary>
/// 编辑文档内容
/// </summary>
Task<QueryDocContentRsp> EditAsync(EditDocContentReq req);
/// <summary>
/// 浏览文档内容
/// </summary>
Task<QueryDocContentRsp> ViewAsync(QueryDocContentReq req);
}

View File

@@ -0,0 +1,6 @@
namespace NetAdmin.SysComponent.Application.Services.Sys.Dependency;
/// <summary>
/// 文档服务
/// </summary>
public interface IDocService : IService, IDocModule;

View File

@@ -46,7 +46,14 @@ public sealed class DevService(IApiService apiService) : ServiceBase<DevService>
var appServicesDependencyDir = Path.Combine(appServicesDir, "Dependency");
// 数据契约层目录
var dataDir = GetDir($"{req.Type}.Domain");
string dataDir;
try {
dataDir = GetDir($"{req.Type}.Domain");
}
catch (InvalidOperationException) {
dataDir = tplDataDir;
}
var dtoDir = Path.Combine(dataDir, "Dto", typeAbbr, req.ModuleName);
var entityDir = Path.Combine(dataDir, "DbMaps", typeAbbr);

View File

@@ -26,10 +26,10 @@ public sealed class DicContentService(BasicRepository<Sys_DicContent, long> rpo)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.CountAsync();
#endif
.CountAsync();
}
/// <inheritdoc />
@@ -87,10 +87,10 @@ public sealed class DicContentService(BasicRepository<Sys_DicContent, long> rpo)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync();
#endif
.AnyAsync();
}
/// <inheritdoc />
@@ -162,7 +162,11 @@ public sealed class DicContentService(BasicRepository<Sys_DicContent, long> rpo)
private ISelect<Sys_DicContent> QueryInternal(QueryReq<QueryDicContentReq> req)
{
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter)
.WhereDynamic(req.Filter)
.WhereIf( //
req.Keywords?.Length > 0
, a => a.Key.Contains(req.Keywords) || a.Value.Contains(req.Keywords) || a.Summary.Contains(req.Keywords));
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (req.Order) {

View File

@@ -0,0 +1,150 @@
using NetAdmin.Domain.DbMaps.Sys;
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
namespace NetAdmin.SysComponent.Application.Services.Sys;
/// <inheritdoc cref="IDocCatalogService" />
public sealed class DocCatalogService(BasicRepository<Sys_DocCatalog, long> rpo) //
: RepositoryService<Sys_DocCatalog, long, IDocCatalogService>(rpo), IDocCatalogService
{
/// <inheritdoc />
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
req.ThrowIfInvalid();
var ret = 0;
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var item in req.Items) {
ret += await DeleteAsync(item).ConfigureAwait(false);
}
return ret;
}
/// <inheritdoc />
public Task<long> CountAsync(QueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.CountAsync();
}
/// <inheritdoc />
/// <exception cref="NetAdminInvalidOperationException">The_parent_node_does_not_exist</exception>
public async Task<QueryDocCatalogRsp> CreateAsync(CreateDocCatalogReq req)
{
req.ThrowIfInvalid();
if (req.ParentId != 0 && !await Rpo.Where(a => a.Id == req.ParentId)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync()
.ConfigureAwait(false)) {
throw new NetAdminInvalidOperationException(Ln.);
}
var ret = await Rpo.InsertAsync(req).ConfigureAwait(false);
return ret.Adapt<QueryDocCatalogRsp>();
}
/// <inheritdoc />
public async Task<int> DeleteAsync(DelReq req)
{
req.ThrowIfInvalid();
var ret = await Rpo.DeleteCascadeByDatabaseAsync(a => a.Id == req.Id).ConfigureAwait(false);
return ret.Count;
}
/// <inheritdoc />
/// <exception cref="NetAdminInvalidOperationException">The_parent_node_does_not_exist</exception>
public async Task<int> EditAsync(EditDocCatalogReq req)
{
req.ThrowIfInvalid();
return req.ParentId == 0 || await Rpo.Where(a => a.Id == req.ParentId)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync()
.ConfigureAwait(false)
? await UpdateAsync(req, null).ConfigureAwait(false)
: throw new NetAdminInvalidOperationException(Ln.);
}
/// <inheritdoc />
public Task<bool> ExistAsync(QueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync();
}
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
throw new NotImplementedException();
}
/// <inheritdoc />
public async Task<QueryDocCatalogRsp> GetAsync(QueryDocCatalogReq req)
{
req.ThrowIfInvalid();
var ret = await QueryInternal(new QueryReq<QueryDocCatalogReq> { Filter = req, Order = Orders.None }).ToOneAsync().ConfigureAwait(false);
return ret.Adapt<QueryDocCatalogRsp>();
}
/// <inheritdoc />
public async Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryAsync(PagedQueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
var list = await QueryInternal(req)
.Page(req.Page, req.PageSize)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.Count(out var total)
.ToListAsync()
.ConfigureAwait(false);
return new PagedQueryRsp<QueryDocCatalogRsp>(req.Page, req.PageSize, total, list.Adapt<IEnumerable<QueryDocCatalogRsp>>());
}
/// <inheritdoc />
public async Task<IEnumerable<QueryDocCatalogRsp>> QueryAsync(QueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
var ret = await QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.ToTreeListAsync()
.ConfigureAwait(false);
return ret.Adapt<IEnumerable<QueryDocCatalogRsp>>();
}
private ISelect<Sys_DocCatalog> QueryInternal(QueryReq<QueryDocCatalogReq> req)
{
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter).WhereDynamic(req.Filter);
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (req.Order) {
case Orders.None:
return ret;
case Orders.Random:
return ret.OrderByRandom();
}
ret = ret.OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending);
if (!req.Prop?.Equals(nameof(req.Filter.Id), StringComparison.OrdinalIgnoreCase) ?? true) {
ret = ret.OrderByDescending(a => a.Id);
}
return ret;
}
}

View File

@@ -0,0 +1,202 @@
using NetAdmin.Domain.DbMaps.Dependency.Fields;
using NetAdmin.Domain.DbMaps.Sys;
using NetAdmin.Domain.Dto.Sys.Doc.Content;
using NetAdmin.Domain.Enums.Sys;
namespace NetAdmin.SysComponent.Application.Services.Sys;
/// <inheritdoc cref="IDocContentService" />
public sealed class DocContentService(BasicRepository<Sys_DocContent, long> rpo) //
: RepositoryService<Sys_DocContent, long, IDocContentService>(rpo), IDocContentService
{
/// <inheritdoc />
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
req.ThrowIfInvalid();
var ret = 0;
// ReSharper disable once LoopCanBeConvertedToQuery
foreach (var item in req.Items) {
ret += await DeleteAsync(item).ConfigureAwait(false);
}
return ret;
}
/// <inheritdoc />
public Task<long> CountAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.CountAsync();
}
/// <inheritdoc />
/// <exception cref="NetAdminInvalidOperationException">Doctionary_directory_does_not_exist</exception>
public async Task<QueryDocContentRsp> CreateAsync(CreateDocContentReq req)
{
req.ThrowIfInvalid();
if (!await Rpo.Orm.Select<Sys_DocCatalog>()
.Where(a => a.Id == req.CatalogId)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync()
.ConfigureAwait(false)) {
throw new NetAdminInvalidOperationException(Ln.);
}
var ret = await Rpo.InsertAsync(req).ConfigureAwait(false);
return ret.Adapt<QueryDocContentRsp>();
}
/// <inheritdoc />
public Task<int> DeleteAsync(DelReq req)
{
req.ThrowIfInvalid();
return Rpo.DeleteAsync(a => a.Id == req.Id);
}
/// <inheritdoc />
/// <exception cref="NetAdminInvalidOperationException">Doctionary_directory_does_not_exist</exception>
public async Task<QueryDocContentRsp> EditAsync(EditDocContentReq req)
{
req.ThrowIfInvalid();
if (!await Rpo.Orm.Select<Sys_DocCatalog>()
.Where(a => a.Id == req.CatalogId)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync()
.ConfigureAwait(false)) {
throw new NetAdminInvalidOperationException(Ln.);
}
#if DBTYPE_SQLSERVER
return (await UpdateReturnListAsync(req, null).ConfigureAwait(false)).FirstOrDefault()?.Adapt<QueryDocContentRsp>();
#else
return await UpdateAsync(req, null, [nameof(IFieldOwner.OwnerId), nameof(IFieldOwner.OwnerDeptId)]).ConfigureAwait(false) > 0
? await GetAsync(new QueryDocContentReq { Id = req.Id }).ConfigureAwait(false)
: null;
#endif
}
/// <inheritdoc />
public Task<bool> ExistAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.AnyAsync();
}
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return ExportAsync<QueryDocContentReq, ExportDocContentRsp>(QueryInternal, req, Ln.);
}
/// <inheritdoc />
public async Task<QueryDocContentRsp> GetAsync(QueryDocContentReq req)
{
req.ThrowIfInvalid();
var ret = await QueryInternal(new QueryReq<QueryDocContentReq> { Filter = req, Order = Orders.None }).ToOneAsync().ConfigureAwait(false);
return ret.Adapt<QueryDocContentRsp>();
}
/// <inheritdoc />
public async Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryAsync(PagedQueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
var list = await QueryInternal(req)
.Page(req.Page, req.PageSize)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.Count(out var total)
.ToListAsync()
.ConfigureAwait(false);
return new PagedQueryRsp<QueryDocContentRsp>(req.Page, req.PageSize, total, list.Adapt<IEnumerable<QueryDocContentRsp>>());
}
/// <inheritdoc />
public async Task<IEnumerable<QueryDocContentRsp>> QueryAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
var ret = await QueryInternal(req)
#if DBTYPE_SQLSERVER
.WithLock(SqlServerLock.NoLock | SqlServerLock.NoWait)
#endif
.Take(req.Count)
.ToListAsync()
.ConfigureAwait(false);
return ret.Adapt<IEnumerable<QueryDocContentRsp>>();
}
/// <inheritdoc />
public Task<int> SetEnabledAsync(SetDocContentEnabledReq req)
{
req.ThrowIfInvalid();
return UpdateAsync(req, [nameof(Sys_DocContent.Enabled)]);
}
/// <inheritdoc />
public async Task<QueryDocContentRsp> ViewAsync(QueryDocContentReq req)
{
req.ThrowIfInvalid();
var ret = await QueryInternal(new QueryReq<QueryDocContentReq> { Filter = req, Order = Orders.None }).ToOneAsync().ConfigureAwait(false);
switch (ret?.Visibility) {
case ArchiveVisibilities.LogonUser:
if (UserToken == null) {
return null;
}
break;
case ArchiveVisibilities.DeptUser:
if (UserToken == null || UserToken.DeptId != ret.OwnerDeptId) {
return null;
}
break;
case ArchiveVisibilities.Self:
if (UserToken == null || UserToken.Id != ret.OwnerId) {
return null;
}
break;
}
return ret?.Enabled == false ? null : ret?.Adapt<QueryDocContentRsp>();
}
private ISelect<Sys_DocContent> QueryInternal(QueryReq<QueryDocContentReq> req)
{
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter)
.WhereDynamic(req.Filter)
.WhereIf( //
req.Keywords?.Length > 0, a => a.Title.Contains(req.Keywords));
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
switch (req.Order) {
case Orders.None:
return ret;
case Orders.Random:
return ret.OrderByRandom();
}
ret = ret.OrderByPropertyNameIf(req.Prop?.Length > 0, req.Prop, req.Order == Orders.Ascending);
if (!req.Prop?.Equals(nameof(req.Filter.Id), StringComparison.OrdinalIgnoreCase) ?? true) {
ret = ret.OrderByDescending(a => a.Id);
}
return ret;
}
}

View File

@@ -0,0 +1,128 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Application.Services.Sys;
/// <inheritdoc cref="IDocService" />
public sealed class DocService(IDocCatalogService catalogService, IDocContentService contentService) //
: ServiceBase<IDocService>, IDocService
{
/// <inheritdoc />
public Task<int> BulkDeleteCatalogAsync(BulkReq<DelReq> req)
{
req.ThrowIfInvalid();
return catalogService.BulkDeleteAsync(req);
}
/// <inheritdoc />
public Task<int> BulkDeleteContentAsync(BulkReq<DelReq> req)
{
req.ThrowIfInvalid();
return contentService.BulkDeleteAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> CreateCatalogAsync(CreateDocCatalogReq req)
{
req.ThrowIfInvalid();
return catalogService.CreateAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> CreateContentAsync(CreateDocContentReq req)
{
req.ThrowIfInvalid();
return contentService.CreateAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteCatalogAsync(DelReq req)
{
req.ThrowIfInvalid();
return catalogService.DeleteAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteContentAsync(DelReq req)
{
req.ThrowIfInvalid();
return contentService.DeleteAsync(req);
}
/// <inheritdoc />
public Task<int> EditCatalogAsync(EditDocCatalogReq req)
{
req.ThrowIfInvalid();
return catalogService.EditAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> EditContentAsync(EditDocContentReq req)
{
req.ThrowIfInvalid();
return contentService.EditAsync(req);
}
/// <inheritdoc />
public Task<IActionResult> ExportContentAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return contentService.ExportAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> GetCatalogAsync(QueryDocCatalogReq req)
{
req.ThrowIfInvalid();
return catalogService.GetAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> GetContentAsync(QueryDocContentReq req)
{
req.ThrowIfInvalid();
return contentService.GetAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
return catalogService.PagedQueryAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryContentAsync(PagedQueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return contentService.PagedQueryAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocCatalogRsp>> QueryCatalogAsync(QueryReq<QueryDocCatalogReq> req)
{
req.ThrowIfInvalid();
return catalogService.QueryAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocContentRsp>> QueryContentAsync(QueryReq<QueryDocContentReq> req)
{
req.ThrowIfInvalid();
return contentService.QueryAsync(req);
}
/// <inheritdoc />
public Task<int> SetEnabledAsync(SetDocContentEnabledReq req)
{
req.ThrowIfInvalid();
return contentService.SetEnabledAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> ViewContentAsync(QueryDocContentReq req)
{
req.ThrowIfInvalid();
return contentService.ViewAsync(req);
}
}

View File

@@ -0,0 +1,6 @@
namespace NetAdmin.SysComponent.Cache.Sys.Dependency;
/// <summary>
/// 文档缓存
/// </summary>
public interface IDocCache : ICache<IDistributedCache, IDocService>, IDocModule;

View File

@@ -0,0 +1,6 @@
namespace NetAdmin.SysComponent.Cache.Sys.Dependency;
/// <summary>
/// 文档分类缓存
/// </summary>
public interface IDocCatalogCache : ICache<IDistributedCache, IDocCatalogService>, IDocCatalogModule;

View File

@@ -0,0 +1,6 @@
namespace NetAdmin.SysComponent.Cache.Sys.Dependency;
/// <summary>
/// 文档内容缓存
/// </summary>
public interface IDocContentCache : ICache<IDistributedCache, IDocContentService>, IDocContentModule;

View File

@@ -0,0 +1,111 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Cache.Sys;
/// <inheritdoc cref="IDocCache" />
public sealed class DocCache(IDistributedCache cache, IDocService service) //
: DistributedCache<IDocService>(cache, service), IScoped, IDocCache
{
/// <inheritdoc />
public Task<int> BulkDeleteCatalogAsync(BulkReq<DelReq> req)
{
return Service.BulkDeleteCatalogAsync(req);
}
/// <inheritdoc />
public Task<int> BulkDeleteContentAsync(BulkReq<DelReq> req)
{
return Service.BulkDeleteContentAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> CreateCatalogAsync(CreateDocCatalogReq req)
{
return Service.CreateCatalogAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> CreateContentAsync(CreateDocContentReq req)
{
return Service.CreateContentAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteCatalogAsync(DelReq req)
{
return Service.DeleteCatalogAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteContentAsync(DelReq req)
{
return Service.DeleteContentAsync(req);
}
/// <inheritdoc />
public Task<int> EditCatalogAsync(EditDocCatalogReq req)
{
return Service.EditCatalogAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> EditContentAsync(EditDocContentReq req)
{
return Service.EditContentAsync(req);
}
/// <inheritdoc />
public Task<IActionResult> ExportContentAsync(QueryReq<QueryDocContentReq> req)
{
return Service.ExportContentAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> GetCatalogAsync(QueryDocCatalogReq req)
{
return Service.GetCatalogAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> GetContentAsync(QueryDocContentReq req)
{
return Service.GetContentAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDocCatalogReq> req)
{
return Service.PagedQueryCatalogAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryContentAsync(PagedQueryReq<QueryDocContentReq> req)
{
return Service.PagedQueryContentAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocCatalogRsp>> QueryCatalogAsync(QueryReq<QueryDocCatalogReq> req)
{
return Service.QueryCatalogAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocContentRsp>> QueryContentAsync(QueryReq<QueryDocContentReq> req)
{
return Service.QueryContentAsync(req);
}
/// <inheritdoc />
public Task<int> SetEnabledAsync(SetDocContentEnabledReq req)
{
return Service.SetEnabledAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> ViewContentAsync(QueryDocContentReq req)
{
return Service.ViewContentAsync(req);
}
}

View File

@@ -0,0 +1,62 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
namespace NetAdmin.SysComponent.Cache.Sys;
/// <inheritdoc cref="IDocCatalogCache" />
public sealed class DocCatalogCache(IDistributedCache cache, IDocCatalogService service)
: DistributedCache<IDocCatalogService>(cache, service), IScoped, IDocCatalogCache
{
/// <inheritdoc />
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
return Service.BulkDeleteAsync(req);
}
/// <inheritdoc />
public Task<long> CountAsync(QueryReq<QueryDocCatalogReq> req)
{
return Service.CountAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> CreateAsync(CreateDocCatalogReq req)
{
return Service.CreateAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteAsync(DelReq req)
{
return Service.DeleteAsync(req);
}
/// <inheritdoc />
public Task<bool> ExistAsync(QueryReq<QueryDocCatalogReq> req)
{
return Service.ExistAsync(req);
}
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryDocCatalogReq> req)
{
return Service.ExportAsync(req);
}
/// <inheritdoc />
public Task<QueryDocCatalogRsp> GetAsync(QueryDocCatalogReq req)
{
return Service.GetAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryAsync(PagedQueryReq<QueryDocCatalogReq> req)
{
return Service.PagedQueryAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocCatalogRsp>> QueryAsync(QueryReq<QueryDocCatalogReq> req)
{
return Service.QueryAsync(req);
}
}

View File

@@ -0,0 +1,68 @@
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Cache.Sys;
/// <inheritdoc cref="IDocContentCache" />
public sealed class DocContentCache(IDistributedCache cache, IDocContentService service)
: DistributedCache<IDocContentService>(cache, service), IScoped, IDocContentCache
{
/// <inheritdoc />
public Task<int> BulkDeleteAsync(BulkReq<DelReq> req)
{
return Service.BulkDeleteAsync(req);
}
/// <inheritdoc />
public Task<long> CountAsync(QueryReq<QueryDocContentReq> req)
{
return Service.CountAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> CreateAsync(CreateDocContentReq req)
{
return Service.CreateAsync(req);
}
/// <inheritdoc />
public Task<int> DeleteAsync(DelReq req)
{
return Service.DeleteAsync(req);
}
/// <inheritdoc />
public Task<bool> ExistAsync(QueryReq<QueryDocContentReq> req)
{
return Service.ExistAsync(req);
}
/// <inheritdoc />
public Task<IActionResult> ExportAsync(QueryReq<QueryDocContentReq> req)
{
return Service.ExportAsync(req);
}
/// <inheritdoc />
public Task<QueryDocContentRsp> GetAsync(QueryDocContentReq req)
{
return Service.GetAsync(req);
}
/// <inheritdoc />
public Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryAsync(PagedQueryReq<QueryDocContentReq> req)
{
return Service.PagedQueryAsync(req);
}
/// <inheritdoc />
public Task<IEnumerable<QueryDocContentRsp>> QueryAsync(QueryReq<QueryDocContentReq> req)
{
return Service.QueryAsync(req);
}
/// <inheritdoc />
public Task<int> SetEnabledAsync(SetDocContentEnabledReq req)
{
return Service.SetEnabledAsync(req);
}
}

View File

@@ -0,0 +1,157 @@
using NetAdmin.Domain.Dto.Sys.Doc.Catalog;
using NetAdmin.Domain.Dto.Sys.Doc.Content;
namespace NetAdmin.SysComponent.Host.Controllers.Sys;
/// <summary>
/// 文档服务
/// </summary>
[ApiDescriptionSettings(nameof(Sys), Module = nameof(Sys))]
[Produces(Chars.FLG_HTTP_HEADER_VALUE_APPLICATION_JSON)]
public sealed class DocController(IDocCache cache) : ControllerBase<IDocCache, IDocService>(cache), IDocModule
{
/// <summary>
/// 批量删除文档分类
/// </summary>
[Transaction]
public Task<int> BulkDeleteCatalogAsync(BulkReq<DelReq> req)
{
return Cache.BulkDeleteCatalogAsync(req);
}
/// <summary>
/// 批量删除文档内容
/// </summary>
[Transaction]
public Task<int> BulkDeleteContentAsync(BulkReq<DelReq> req)
{
return Cache.BulkDeleteContentAsync(req);
}
/// <summary>
/// 创建文档分类
/// </summary>
[Transaction]
public Task<QueryDocCatalogRsp> CreateCatalogAsync(CreateDocCatalogReq req)
{
return Cache.CreateCatalogAsync(req);
}
/// <summary>
/// 创建文档内容
/// </summary>
[Transaction]
public Task<QueryDocContentRsp> CreateContentAsync(CreateDocContentReq req)
{
return Cache.CreateContentAsync(req);
}
/// <summary>
/// 删除文档分类
/// </summary>
[Transaction]
public Task<int> DeleteCatalogAsync(DelReq req)
{
return Cache.DeleteCatalogAsync(req);
}
/// <summary>
/// 删除文档内容
/// </summary>
[Transaction]
public Task<int> DeleteContentAsync(DelReq req)
{
return Cache.DeleteContentAsync(req);
}
/// <summary>
/// 编辑文档分类
/// </summary>
[Transaction]
public Task<int> EditCatalogAsync(EditDocCatalogReq req)
{
return Cache.EditCatalogAsync(req);
}
/// <summary>
/// 编辑文档内容
/// </summary>
[Transaction]
public Task<QueryDocContentRsp> EditContentAsync(EditDocContentReq req)
{
return Cache.EditContentAsync(req);
}
/// <summary>
/// 导出文档内容
/// </summary>
public Task<IActionResult> ExportContentAsync(QueryReq<QueryDocContentReq> req)
{
return Cache.ExportContentAsync(req);
}
/// <summary>
/// 获取单个文档分类
/// </summary>
public Task<QueryDocCatalogRsp> GetCatalogAsync(QueryDocCatalogReq req)
{
return Cache.GetCatalogAsync(req);
}
/// <summary>
/// 获取单个文档内容
/// </summary>
public Task<QueryDocContentRsp> GetContentAsync(QueryDocContentReq req)
{
return Cache.GetContentAsync(req);
}
/// <summary>
/// 分页查询文档分类
/// </summary>
public Task<PagedQueryRsp<QueryDocCatalogRsp>> PagedQueryCatalogAsync(PagedQueryReq<QueryDocCatalogReq> req)
{
return Cache.PagedQueryCatalogAsync(req);
}
/// <summary>
/// 分页查询文档内容
/// </summary>
public Task<PagedQueryRsp<QueryDocContentRsp>> PagedQueryContentAsync(PagedQueryReq<QueryDocContentReq> req)
{
return Cache.PagedQueryContentAsync(req);
}
/// <summary>
/// 查询文档分类
/// </summary>
public Task<IEnumerable<QueryDocCatalogRsp>> QueryCatalogAsync(QueryReq<QueryDocCatalogReq> req)
{
return Cache.QueryCatalogAsync(req);
}
/// <summary>
/// 查询文档内容
/// </summary>
public Task<IEnumerable<QueryDocContentRsp>> QueryContentAsync(QueryReq<QueryDocContentReq> req)
{
return Cache.QueryContentAsync(req);
}
/// <summary>
/// 启用/禁用文档内容
/// </summary>
public Task<int> SetEnabledAsync(SetDocContentEnabledReq req)
{
return Cache.SetEnabledAsync(req);
}
/// <summary>
/// 浏览文档内容
/// </summary>
[AllowAnonymous]
public Task<QueryDocContentRsp> ViewContentAsync(QueryDocContentReq req)
{
return Cache.ViewContentAsync(req);
}
}