feat: 添加abp的后台管理

This commit is contained in:
橙子
2023-12-11 22:14:13 +08:00
parent 27a2849619
commit aa49398c29
20 changed files with 433 additions and 23 deletions

View File

@@ -62,6 +62,11 @@ namespace Yi.Framework.Ddd.Application
{
}
public override Task<PagedResultDto<TGetListOutputDto>> GetListAsync(TGetListInput input)
{
throw new NotImplementedException($"【{typeof(TEntity)}】实体的CrudAppService查询为具体业务通用查询几乎无实际场景请重写实现");
}
/// <summary>
/// 偷梁换柱
/// </summary>
@@ -72,7 +77,7 @@ namespace Yi.Framework.Ddd.Application
{
await Repository.DeleteManyAsync(id);
}
[RemoteService(isEnabled:false)]
[RemoteService(isEnabled: false)]
public override Task DeleteAsync(TKey id)
{
return base.DeleteAsync(id);

View File

@@ -1,8 +1,9 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application.Contracts;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
{
public class ArticleGetListInputVo : PagedAndSortedResultRequestDto
public class ArticleGetListInputVo : PagedAllResultRequestDto
{
public string? Content { get; set; }
public string? Name { get; set; }

View File

@@ -10,5 +10,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
public Guid DiscussId { get; set; }
public List<ArticleGetListOutputDto>? Children { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -8,5 +8,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Article
public string Name { get; set; }
public Guid DiscussId { get; set; }
public Guid ParentId { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -8,5 +8,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Plate
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public string Code { get; set; }
}
}

View File

@@ -1,11 +1,11 @@
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application.Contracts;
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Plate
{
public class PlateGetListInputVo : PagedAndSortedResultRequestDto
public class PlateGetListInputVo : PagedAllResultRequestDto
{
public string? Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public string? Code { get; set; }
}
}

View File

@@ -8,5 +8,9 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Plate
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public string Code { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -7,5 +7,8 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Plate
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public string Code { get; set; }
public DateTime CreationTime { get; set; }
}
}

View File

@@ -5,5 +5,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Plate
public string? Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public string? Code { get; set; }
}
}

View File

@@ -3,8 +3,12 @@ using Mapster;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Article;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Bbs.Domain.Repositories;
@@ -37,6 +41,19 @@ namespace Yi.Framework.Bbs.Application.Services
private IArticleRepository _articleRepository { get; set; }
private ISqlSugarRepository<DiscussEntity> _discussRepository { get; set; }
private IDiscussService _discussService { get; set; }
public override async Task<PagedResultDto<ArticleGetListOutputDto>> GetListAsync(ArticleGetListInputVo input)
{
RefAsync<int> total = 0;
var entities = await _articleRepository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
//.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Name.Contains(input.Code!))
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<ArticleGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
/// <summary>
/// 获取文章全部平铺信息
/// </summary>

View File

@@ -1,8 +1,12 @@
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Yi.Framework.Bbs.Application.Contracts.Dtos.Plate;
using Yi.Framework.Bbs.Application.Contracts.IServices;
using Yi.Framework.Bbs.Domain.Entities;
using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application.Contracts.Dtos.Config;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Bbs.Application.Services
{
@@ -12,8 +16,21 @@ namespace Yi.Framework.Bbs.Application.Services
public class PlateService : YiCrudAppService<PlateEntity, PlateGetOutputDto, PlateGetListOutputDto, Guid, PlateGetListInputVo, PlateCreateInputVo, PlateUpdateInputVo>,
IPlateService
{
public PlateService(IRepository<PlateEntity, Guid> repository) : base(repository)
private ISqlSugarRepository<PlateEntity, Guid> _repository;
public PlateService(ISqlSugarRepository<PlateEntity, Guid> repository) : base(repository)
{
_repository= repository;
}
public override async Task<PagedResultDto<PlateGetListOutputDto>> GetListAsync(PlateGetListInputVo input)
{
RefAsync<int> total = 0;
var entities = await _repository._DbQueryable.WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name!))
.WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Name.Contains(input.Code!))
.WhereIF(input.StartTime is not null && input.EndTime is not null, x => x.CreationTime >= input.StartTime && x.CreationTime <= input.EndTime)
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total);
return new PagedResultDto<PlateGetListOutputDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}

View File

@@ -1,11 +1,12 @@
using SqlSugar;
using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
namespace Yi.Framework.Bbs.Domain.Entities
{
[SugarTable("Article")]
public class ArticleEntity : Entity<Guid>, ISoftDelete
public class ArticleEntity : Entity<Guid>, ISoftDelete,IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
@@ -23,6 +24,15 @@ namespace Yi.Framework.Bbs.Domain.Entities
[SugarColumn(IsIgnore = true)]
public List<ArticleEntity>? Children { get; set; }
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
public Guid? LastModifierId { get; set; }
public DateTime? LastModificationTime { get; set; }
}
public static class ArticleEntityExtensions

View File

@@ -1,18 +1,31 @@
using SqlSugar;
using Volo.Abp.Domain.Entities;
using Volo.Abp;
using Volo.Abp.Auditing;
namespace Yi.Framework.Bbs.Domain.Entities
{
[SugarTable("Plate")]
public class PlateEntity : Entity<Guid>, ISoftDelete
public class PlateEntity : Entity<Guid>, ISoftDelete,IAuditedObject
{
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
public string Code { get; set; }
public string Name { get; set; }
public string? Logo { get; set; }
public string? Introduction { get; set; }
public bool IsDeleted { get; set; }
public DateTime CreationTime { get; set; }
public Guid? CreatorId { get; set; }
public Guid? LastModifierId { get; set; }
public DateTime? LastModificationTime { get; set; }
}
}

View File

@@ -55,7 +55,7 @@ namespace Yi.Abp.Web
//动态Api
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(YiAbpApplicationModule).Assembly,options=>options.RemoteServiceName="default");
options.ConventionalControllers.Create(typeof(YiAbpApplicationModule).Assembly, options => options.RemoteServiceName = "default");
options.ConventionalControllers.Create(typeof(YiFrameworkRbacApplicationModule).Assembly, options => options.RemoteServiceName = "rbac");
options.ConventionalControllers.Create(typeof(YiFrameworkBbsApplicationModule).Assembly, options => options.RemoteServiceName = "bbs");
});
@@ -63,7 +63,6 @@ namespace Yi.Abp.Web
//设置api格式
service.AddControllers().AddNewtonsoftJson(options =>
{
// options.SerializerSettings.Converters.Add(new DateTimeJsonConverter("yyyy-MM-dd HH:mm:ss"));
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
});
Configure<AbpJsonOptions>(options =>
@@ -76,7 +75,10 @@ namespace Yi.Abp.Web
});
//Swagger
context.Services.AddYiSwaggerGen<YiAbpWebModule>();
context.Services.AddYiSwaggerGen<YiAbpWebModule>(options =>
{
options.SwaggerDoc("default", new OpenApiInfo { Title = "Yi.Framework.Abp", Version = "v1",Description="集大成者" });
});
//跨域
context.Services.AddCors(options =>
@@ -145,10 +147,10 @@ namespace Yi.Abp.Web
app.UseRouting();
//跨域
app.UseCors(DefaultCorsPolicyName);
//鉴权
app.UseAuthentication();