feat: 添加sample示例

This commit is contained in:
陈淳
2024-01-10 17:26:40 +08:00
parent a3f7c1e867
commit 2c8d579668
43 changed files with 907 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd.Application\Yi.Framework.Ddd.Application.csproj" />
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Application\Yi.Framework.Bbs.Application.csproj" />
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Application\Yi.Framework.Rbac.Application.csproj" />
<ProjectReference Include="..\Acme.BookStore.Application.Contracts\Acme.BookStore.Application.Contracts.csproj" />
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Jobs\" />
<Folder Include="EventHandlers\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,36 @@
using Quartz;
using SqlSugar;
using Volo.Abp.BackgroundWorkers.Quartz;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
using Yi.Framework.Rbac.Domain.Entities;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.Rbac.Application.Jobs
{
/// <summary>
/// 定时任务
/// </summary>
public class TestJob : QuartzBackgroundWorkerBase
{
private ISqlSugarRepository<UserEntity> _repository;
public TestJob(ISqlSugarRepository<UserEntity> repository)
{
_repository = repository;
JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build();
Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(1000 * 60)
.RepeatForever())
.Build();
}
public override async Task Execute(IJobExecutionContext context)
{
//定时任务,非常简单
Console.WriteLine("你好,世界");
// var eneities= await _repository.GetListAsync();
//var entities= await _sqlSugarClient.Queryable<UserEntity>().ToListAsync();
//await Console.Out.WriteLineAsync(entities.Count().ToString());
}
}
}

View File

@@ -0,0 +1,42 @@
using Acme.BookStore.Application.Contracts.Dtos.Book;
using Acme.BookStore.Application.Contracts.IServices;
using Acme.BookStore.Domain.Entities;
using SqlSugar;
using Volo.Abp.Application.Dtos;
using Yi.Framework.Ddd.Application;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Acme.BookStore.Application.Services
{
public class BookAppService :
YiCrudAppService<
BookAggregateRoot, //The Book entity
BookDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting
BookCreateUpdateDto>, //Used to create/update a book
IBookAppService //implement the IBookAppService
{
private ISqlSugarRepository<BookAggregateRoot, Guid> _repository;
public BookAppService(ISqlSugarRepository<BookAggregateRoot, Guid> repository)
: base(repository)
{
_repository = repository;
}
public override async Task<PagedResultDto<BookDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
{
RefAsync<int> total = 0;
//由于直接查询接口基本上都是有包含查询条件的,默认内置的查询接口将无法满足业务的需求,所以基本上多查询都是有进行重写的
var entities = await _repository._DbQueryable
//.WhereIF(!string.IsNullOrEmpty(input.ConfigKey), x => x.ConfigKey.Contains(input.ConfigKey!))
// .WhereIF(!string.IsNullOrEmpty(input.ConfigName), x => x.ConfigName!.Contains(input.ConfigName!))
// .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<BookDto>(total, await MapToGetListOutputDtosAsync(entities));
}
}
}
}

View File

@@ -0,0 +1,18 @@
using Volo.Abp.Application.Services;
using Volo.Abp.DependencyInjection;
namespace Acme.BookStore.Application.Services
{
public class TestService : ApplicationService
{
/// <summary>
/// 你好世界
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public string GetHelloWorld(string? name)
{
return name ?? "HelloWord";
}
}
}

View File

@@ -0,0 +1,23 @@
using Volo.Abp.Modularity;
using Acme.BookStore.Application.Contracts;
using Acme.BookStore.Domain;
using Yi.Framework.Bbs.Application;
using Yi.Framework.Ddd.Application;
using Yi.Framework.Rbac.Application;
namespace Acme.BookStore.Application
{
[DependsOn(
typeof(YiAbpApplicationContractsModule),
typeof(YiAbpDomainModule),
typeof(YiFrameworkRbacApplicationModule),
typeof(YiFrameworkBbsApplicationModule),
typeof(YiFrameworkDddApplicationModule)
)]
public class YiAbpApplicationModule : AbpModule
{
}
}