feat: 完成子文章的操作

This commit is contained in:
陈淳
2023-03-12 19:49:08 +08:00
parent 1eac218910
commit 8e56667760
40 changed files with 569 additions and 337 deletions

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// 常量定义
/// </summary>
public class DictionaryConst
{
}
}

View File

@@ -0,0 +1,50 @@
using Cike.AutoWebApi.Setting;
using Yi.Framework.Ddd.Services;
using Microsoft.AspNetCore.Mvc;
using Yi.Framework.Ddd.Dtos;
using Yi.Framework.DictionaryManager.Entities;
using Yi.Framework.DictionaryManager.Dtos.Dictionary;
using Yi.Framework.Core.Attributes;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// Dictionary服务实现
/// </summary>
[AppService]
public class DictionaryService : CrudAppService<DictionaryEntity, DictionaryGetOutputDto, DictionaryGetListOutputDto, long, DictionaryGetListInputVo, DictionaryCreateInputVo, DictionaryUpdateInputVo>,
IDictionaryService, IAutoApiService
{
/// <summary>
/// 查询
/// </summary>
public override async Task<PagedResultDto<DictionaryGetListOutputDto>> GetListAsync(DictionaryGetListInputVo input)
{
int total = 0;
var entities = await _DbQueryable.WhereIF(input.DictType is not null, x => x.DictType == input.DictType)
.WhereIF(input.DictLabel is not null, x => x.DictLabel!.Contains(input.DictLabel!))
.WhereIF(input.State is not null, x => x.State == input.State)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<DictionaryGetListOutputDto>
{
Total = total,
Items = await MapToGetListOutputDtosAsync(entities)
};
}
/// <summary>
/// 根据字典类型获取字典列表
/// </summary>
/// <param name="dicType"></param>
/// <returns></returns>
[Route("/api/dictionary/dic-type/{dicType}")]
public async Task<List<DictionaryGetListOutputDto>> GetDicType([FromRoute] string dicType)
{
var entities = await _repository.GetListAsync(u => u.DictType == dicType && u.State == true);
var result = await MapToGetListOutputDtosAsync(entities);
return result;
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// 常量定义
/// </summary>
public class DictionaryTypeConst
{
}
}

View File

@@ -0,0 +1,38 @@
using Cike.AutoWebApi.Setting;
using Yi.Framework.Ddd.Services;
using Yi.Framework.Ddd.Dtos;
using SqlSugar;
using Yi.Framework.DictionaryManager.Dtos.DictionaryType;
using Yi.Framework.DictionaryManager.Entities;
using Yi.Framework.Core.Attributes;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// DictionaryType服务实现
/// </summary>
[AppService]
public class DictionaryTypeService : CrudAppService<DictionaryTypeEntity, DictionaryTypeGetOutputDto, DictionaryTypeGetListOutputDto, long, DictionaryTypeGetListInputVo, DictionaryTypeCreateInputVo, DictionaryTypeUpdateInputVo>,
IDictionaryTypeService, IAutoApiService
{
public async override Task<PagedResultDto<DictionaryTypeGetListOutputDto>> GetListAsync(DictionaryTypeGetListInputVo input)
{
int total = 0;
var entities = await _DbQueryable.WhereIF(input.DictName is not null, x => x.DictName.Contains(input.DictName!))
.WhereIF(input.DictType is not null, x => x.DictType!.Contains(input.DictType!))
.WhereIF(input.State is not null, x => x.State == input.State)
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.ToPageListAsync(input.PageNum, input.PageSize, total);
return new PagedResultDto<DictionaryTypeGetListOutputDto>
{
Total = total,
Items = await MapToGetListOutputDtosAsync(entities)
};
}
}
}

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager.Dtos.Dictionary
{
/// <summary>
/// Dictionary输入创建对象
/// </summary>
public class DictionaryCreateInputVo
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string? Remark { get; set; }
public string? ListClass { get; set; }
public string? CssClass { get; set; }
public string DictType { get; set; } = string.Empty;
public string? DictLabel { get; set; }
public string DictValue { get; set; } = string.Empty;
public bool IsDefault { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.Dictionary
{
public class DictionaryGetListInputVo : PagedAndSortedResultRequestDto
{
public string? DictType { get; set; }
public string? DictLabel { get; set; }
public bool? State { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.Dictionary
{
public class DictionaryGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string? Remark { get; set; }
public string? ListClass { get; set; }
public string? CssClass { get; set; }
public string DictType { get; set; } = string.Empty;
public string? DictLabel { get; set; }
public string DictValue { get; set; } = string.Empty;
public bool IsDefault { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.Dictionary
{
public class DictionaryGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string? Remark { get; set; }
public string? ListClass { get; set; }
public string? CssClass { get; set; }
public string DictType { get; set; } = string.Empty;
public string? DictLabel { get; set; }
public string DictValue { get; set; } = string.Empty;
public bool IsDefault { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager.Dtos.Dictionary
{
public class DictionaryUpdateInputVo
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string? Remark { get; set; }
public string? ListClass { get; set; }
public string? CssClass { get; set; }
public string DictType { get; set; } = string.Empty;
public string? DictLabel { get; set; }
public string DictValue { get; set; } = string.Empty;
public bool IsDefault { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager.Dtos.DictionaryType
{
/// <summary>
/// DictionaryType输入创建对象
/// </summary>
public class DictionaryTypeCreateInputVo
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string DictName { get; set; } = string.Empty;
public string DictType { get; set; } = string.Empty;
public string? Remark { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.DictionaryType
{
public class DictionaryTypeGetListInputVo : PagedAllResultRequestDto
{
public string? DictName { get; set; }
public string? DictType { get; set; }
public string? Remark { get; set; }
public bool? State { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.DictionaryType
{
public class DictionaryTypeGetListOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string DictName { get; set; } = string.Empty;
public string DictType { get; set; } = string.Empty;
public string? Remark { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Dtos;
namespace Yi.Framework.DictionaryManager.Dtos.DictionaryType
{
public class DictionaryTypeGetOutputDto : IEntityDto<long>
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string DictName { get; set; } = string.Empty;
public string DictType { get; set; } = string.Empty;
public string? Remark { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.DictionaryManager.Dtos.DictionaryType
{
public class DictionaryTypeUpdateInputVo
{
public long Id { get; set; }
public DateTime CreationTime { get; set; } = DateTime.Now;
public long? CreatorId { get; set; }
public string DictName { get; set; } = string.Empty;
public string DictType { get; set; } = string.Empty;
public string? Remark { get; set; }
public bool State { get; set; }
}
}

View File

@@ -0,0 +1,76 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Auditing;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.Framework.DictionaryManager.Entities
{
[SugarTable("Dictionary")]
public class DictionaryEntity : AuditedObject, IEntity<long>, ISoftDelete, IOrderNum, IState
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 逻辑删除
/// </summary>
public bool IsDeleted { get; set; }
/// <summary>
/// 排序
/// </summary>
public int OrderNum { get; set; } = 0;
/// <summary>
/// 状态
/// </summary>
public bool State { get; set; } = true;
/// <summary>
/// 描述
///</summary>
[SugarColumn(ColumnName = "Remark")]
public string? Remark { get; set; }
/// <summary>
/// tag类型
///</summary>
[SugarColumn(ColumnName = "ListClass")]
public string? ListClass { get; set; }
/// <summary>
/// tagClass
///</summary>
[SugarColumn(ColumnName = "CssClass")]
public string? CssClass { get; set; }
/// <summary>
/// 字典类型
///</summary>
[SugarColumn(ColumnName = "DictType")]
public string DictType { get; set; } = string.Empty;
/// <summary>
/// 字典标签
///</summary>
[SugarColumn(ColumnName = "DictLabel")]
public string? DictLabel { get; set; }
/// <summary>
/// 字典值
///</summary>
[SugarColumn(ColumnName = "DictValue")]
public string DictValue { get; set; } = string.Empty;
/// <summary>
/// 是否为该类型的默认值
///</summary>
[SugarColumn(ColumnName = "IsDefault")]
public bool IsDefault { get; set; }
}
}

View File

@@ -0,0 +1,55 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Data.Auditing;
using Yi.Framework.Data.Entities;
using Yi.Framework.Ddd.Entities;
namespace Yi.Framework.DictionaryManager.Entities
{
[SugarTable("DictionaryType")]
public class DictionaryTypeEntity : AuditedObject, IEntity<long>, ISoftDelete, IOrderNum
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 逻辑删除
/// </summary>
public bool IsDeleted { get; set; }
/// <summary>
/// 排序
/// </summary>
public int OrderNum { get; set; } = 0;
/// <summary>
/// 状态
/// </summary>
public bool? State { get; set; } = true;
/// <summary>
/// 字典名称
///</summary>
[SugarColumn(ColumnName = "DictName")]
public string DictName { get; set; } = string.Empty;
/// <summary>
/// 字典类型
///</summary>
[SugarColumn(ColumnName = "DictType")]
public string DictType { get; set; } = string.Empty;
/// <summary>
/// 描述
///</summary>
[SugarColumn(ColumnName = "Remark")]
public string? Remark { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Services.Abstract;
using Yi.Framework.DictionaryManager.Dtos.Dictionary;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// Dictionary服务抽象
/// </summary>
public interface IDictionaryService : ICrudAppService<DictionaryGetOutputDto, DictionaryGetListOutputDto, long, DictionaryGetListInputVo, DictionaryCreateInputVo, DictionaryUpdateInputVo>
{
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Ddd.Services.Abstract;
using Yi.Framework.DictionaryManager.Dtos.DictionaryType;
namespace Yi.Framework.DictionaryManager
{
/// <summary>
/// DictionaryType服务抽象
/// </summary>
public interface IDictionaryTypeService : ICrudAppService<DictionaryTypeGetOutputDto, DictionaryTypeGetListOutputDto, long, DictionaryTypeGetListInputVo, DictionaryTypeCreateInputVo, DictionaryTypeUpdateInputVo>
{
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\framework\Yi.Framework.Data\Yi.Framework.Data.csproj" />
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd\Yi.Framework.Ddd.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using StartupModules;
namespace Yi.Framework.DictionaryManager
{
public class YiFrameworkDictionaryManagerModule : IStartupModule
{
public void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context)
{
}
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
}
}
}