diff --git a/Yi.Abp.Net8/Yi.Abp.sln b/Yi.Abp.Net8/Yi.Abp.sln index 673840f8..e063605c 100644 --- a/Yi.Abp.Net8/Yi.Abp.sln +++ b/Yi.Abp.Net8/Yi.Abp.sln @@ -72,7 +72,21 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "audit-logging", "audit-logg EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.AuditLogging.SqlSugarCore", "module\audit-logging\Yi.AuditLogging.SqlSugarCore\Yi.AuditLogging.SqlSugarCore.csproj", "{48806510-8E18-4E1E-9BAF-5B97E88C5FC3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yi.Framework.AspNetCore.Authentication.OAuth", "framework\Yi.Framework.AspNetCore.Authentication.OAuth\Yi.Framework.AspNetCore.Authentication.OAuth.csproj", "{791AC2FA-50D3-4408-8D68-31DA72F608BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yi.Framework.AspNetCore.Authentication.OAuth", "framework\Yi.Framework.AspNetCore.Authentication.OAuth\Yi.Framework.AspNetCore.Authentication.OAuth.csproj", "{791AC2FA-50D3-4408-8D68-31DA72F608BE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{01300F0F-686E-47B3-821D-12424177867B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Web", "sample\Acme.BookStore.Web\Acme.BookStore.Web.csproj", "{576DBC97-4E5D-4444-B65C-F41649A5F8E0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Domain.Shared", "sample\Acme.BookStore.Domain.Shared\Acme.BookStore.Domain.Shared.csproj", "{D7F8BD42-F6A2-4F0A-9212-391B5185A99D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Domain", "sample\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj", "{B615847F-8568-41D1-8B7E-63D61AE69F3D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Application.Contracts", "sample\Acme.BookStore.Application.Contracts\Acme.BookStore.Application.Contracts.csproj", "{20827DB5-5CDE-491A-82E8-3CAB82618C1E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.Application", "sample\Acme.BookStore.Application\Acme.BookStore.Application.csproj", "{320273B6-7AE3-42DA-9675-D9AD4928A289}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Acme.BookStore.SqlSugarCore", "sample\Acme.BookStore.SqlSugarCore\Acme.BookStore.SqlSugarCore.csproj", "{70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -180,6 +194,30 @@ Global {791AC2FA-50D3-4408-8D68-31DA72F608BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {791AC2FA-50D3-4408-8D68-31DA72F608BE}.Release|Any CPU.ActiveCfg = Release|Any CPU {791AC2FA-50D3-4408-8D68-31DA72F608BE}.Release|Any CPU.Build.0 = Release|Any CPU + {576DBC97-4E5D-4444-B65C-F41649A5F8E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {576DBC97-4E5D-4444-B65C-F41649A5F8E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {576DBC97-4E5D-4444-B65C-F41649A5F8E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {576DBC97-4E5D-4444-B65C-F41649A5F8E0}.Release|Any CPU.Build.0 = Release|Any CPU + {D7F8BD42-F6A2-4F0A-9212-391B5185A99D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7F8BD42-F6A2-4F0A-9212-391B5185A99D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7F8BD42-F6A2-4F0A-9212-391B5185A99D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7F8BD42-F6A2-4F0A-9212-391B5185A99D}.Release|Any CPU.Build.0 = Release|Any CPU + {B615847F-8568-41D1-8B7E-63D61AE69F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B615847F-8568-41D1-8B7E-63D61AE69F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B615847F-8568-41D1-8B7E-63D61AE69F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B615847F-8568-41D1-8B7E-63D61AE69F3D}.Release|Any CPU.Build.0 = Release|Any CPU + {20827DB5-5CDE-491A-82E8-3CAB82618C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20827DB5-5CDE-491A-82E8-3CAB82618C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20827DB5-5CDE-491A-82E8-3CAB82618C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20827DB5-5CDE-491A-82E8-3CAB82618C1E}.Release|Any CPU.Build.0 = Release|Any CPU + {320273B6-7AE3-42DA-9675-D9AD4928A289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {320273B6-7AE3-42DA-9675-D9AD4928A289}.Debug|Any CPU.Build.0 = Debug|Any CPU + {320273B6-7AE3-42DA-9675-D9AD4928A289}.Release|Any CPU.ActiveCfg = Release|Any CPU + {320273B6-7AE3-42DA-9675-D9AD4928A289}.Release|Any CPU.Build.0 = Release|Any CPU + {70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -213,6 +251,12 @@ Global {73CCF2C4-B9FD-44AB-8D4B-0A421805B094} = {2317227D-7796-4E7B-BEDB-7CD1CAE7B853} {48806510-8E18-4E1E-9BAF-5B97E88C5FC3} = {73CCF2C4-B9FD-44AB-8D4B-0A421805B094} {791AC2FA-50D3-4408-8D68-31DA72F608BE} = {77B949E9-530E-45A5-9657-20F7D5C6875C} + {576DBC97-4E5D-4444-B65C-F41649A5F8E0} = {01300F0F-686E-47B3-821D-12424177867B} + {D7F8BD42-F6A2-4F0A-9212-391B5185A99D} = {01300F0F-686E-47B3-821D-12424177867B} + {B615847F-8568-41D1-8B7E-63D61AE69F3D} = {01300F0F-686E-47B3-821D-12424177867B} + {20827DB5-5CDE-491A-82E8-3CAB82618C1E} = {01300F0F-686E-47B3-821D-12424177867B} + {320273B6-7AE3-42DA-9675-D9AD4928A289} = {01300F0F-686E-47B3-821D-12424177867B} + {70CCBD89-C0A1-4AC8-9AFA-C86C356DFDD7} = {01300F0F-686E-47B3-821D-12424177867B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {23D6FBC9-C970-4641-BC1E-2AEA59F51C18} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Acme.BookStore.Application.Contracts.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Acme.BookStore.Application.Contracts.csproj new file mode 100644 index 00000000..bd4430bb --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Acme.BookStore.Application.Contracts.csproj @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookCreateUpdateDto.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookCreateUpdateDto.cs new file mode 100644 index 00000000..a49714fc --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookCreateUpdateDto.cs @@ -0,0 +1,24 @@ +using System.ComponentModel.DataAnnotations; +using Acme.BookStore.Domain.Shared.Enums; + +namespace Acme.BookStore.Application.Contracts.Dtos.Book +{ + + public class BookCreateUpdateDto + { + [Required] + [StringLength(128)] + public string Name { get; set; } + + [Required] + public BookTypeEnum Type { get; set; } = BookTypeEnum.Undefined; + + [Required] + [DataType(DataType.Date)] + public DateTime PublishDate { get; set; } = DateTime.Now; + + [Required] + public float Price { get; set; } + } + +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookDto.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookDto.cs new file mode 100644 index 00000000..38d95044 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/Dtos/Book/BookDto.cs @@ -0,0 +1,16 @@ +using Acme.BookStore.Domain.Shared.Enums; +using Volo.Abp.Application.Dtos; + +namespace Acme.BookStore.Application.Contracts.Dtos.Book +{ + public class BookDto : AuditedEntityDto + { + public string Name { get; set; } + + public BookTypeEnum Type { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/IServices/IBookAppService.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/IServices/IBookAppService.cs new file mode 100644 index 00000000..df7f533c --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/IServices/IBookAppService.cs @@ -0,0 +1,16 @@ +using Acme.BookStore.Application.Contracts.Dtos.Book; +using Volo.Abp.Application.Dtos; +using Yi.Framework.Ddd.Application.Contracts; + +namespace Acme.BookStore.Application.Contracts.IServices +{ + public interface IBookAppService : + IYiCrudAppService< //Defines CRUD methods + BookDto, //Used to show books + Guid, //Primary key of the book entity + PagedAndSortedResultRequestDto, //Used for paging/sorting + BookCreateUpdateDto> //Used to create/update a book + { + + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/YiAbpApplicationContractsModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/YiAbpApplicationContractsModule.cs new file mode 100644 index 00000000..d2a85915 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application.Contracts/YiAbpApplicationContractsModule.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Modularity; +using Acme.BookStore.Domain.Shared; +using Yi.Framework.Bbs.Application.Contracts; +using Yi.Framework.Ddd.Application.Contracts; +using Yi.Framework.Rbac.Application.Contracts; + +namespace Acme.BookStore.Application.Contracts +{ + [DependsOn( + typeof(YiAbpDomainSharedModule), + + typeof(YiFrameworkRbacApplicationContractsModule), + typeof(YiFrameworkBbsApplicationContractsModule), + + typeof(YiFrameworkDddApplicationContractsModule))] + public class YiAbpApplicationContractsModule:AbpModule + { + + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application/Acme.BookStore.Application.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Acme.BookStore.Application.csproj new file mode 100644 index 00000000..22d147c8 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Acme.BookStore.Application.csproj @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application/Jobs/TestJob.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Jobs/TestJob.cs new file mode 100644 index 00000000..f02f823b --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Jobs/TestJob.cs @@ -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 +{ + /// + /// 定时任务 + /// + public class TestJob : QuartzBackgroundWorkerBase + { + private ISqlSugarRepository _repository; + public TestJob(ISqlSugarRepository repository) + { + _repository = repository; + JobDetail = JobBuilder.Create().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().ToListAsync(); + //await Console.Out.WriteLineAsync(entities.Count().ToString()); + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/BookAppService .cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/BookAppService .cs new file mode 100644 index 00000000..24049ecb --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/BookAppService .cs @@ -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 _repository; + public BookAppService(ISqlSugarRepository repository) + : base(repository) + { + _repository = repository; + } + + public override async Task> GetListAsync(PagedAndSortedResultRequestDto input) + { + { + RefAsync 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(total, await MapToGetListOutputDtosAsync(entities)); + } + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/TestService.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/TestService.cs new file mode 100644 index 00000000..0538ddb5 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application/Services/TestService.cs @@ -0,0 +1,18 @@ +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; + +namespace Acme.BookStore.Application.Services +{ + public class TestService : ApplicationService + { + /// + /// 你好世界 + /// + /// + /// + public string GetHelloWorld(string? name) + { + return name ?? "HelloWord"; + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Application/YiAbpApplicationModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Application/YiAbpApplicationModule.cs new file mode 100644 index 00000000..e5960e04 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Application/YiAbpApplicationModule.cs @@ -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 + { + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Acme.BookStore.Domain.Shared.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Acme.BookStore.Domain.Shared.csproj new file mode 100644 index 00000000..70cfebd4 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Acme.BookStore.Domain.Shared.csproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Enums/BookTypeEnum.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Enums/BookTypeEnum.cs new file mode 100644 index 00000000..cd4fa1ed --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/Enums/BookTypeEnum.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Acme.BookStore.Domain.Shared.Enums +{ + public enum BookTypeEnum + { + Undefined, + Adventure, + Biography, + Dystopia, + Fantastic, + Horror, + Science, + ScienceFiction, + Poetry + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/YiAbpDomainSharedModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/YiAbpDomainSharedModule.cs new file mode 100644 index 00000000..9651e280 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain.Shared/YiAbpDomainSharedModule.cs @@ -0,0 +1,17 @@ +using Volo.Abp.Domain; +using Volo.Abp.Modularity; +using Yi.Framework.Bbs.Domain.Shared; +using Yi.Framework.Rbac.Domain.Shared; + +namespace Acme.BookStore.Domain.Shared +{ + [DependsOn( + typeof(YiFrameworkRbacDomainSharedModule), + typeof(YiFrameworkBbsDomainSharedModule), + + typeof(AbpDddDomainSharedModule))] + public class YiAbpDomainSharedModule : AbpModule + { + + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj new file mode 100644 index 00000000..74053ef1 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Acme.BookStore.Domain.csproj @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Entities/BookAggregateRoot.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Entities/BookAggregateRoot.cs new file mode 100644 index 00000000..f8fdc55f --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/Entities/BookAggregateRoot.cs @@ -0,0 +1,24 @@ +using Acme.BookStore.Domain.Shared.Enums; +using SqlSugar; +using Volo.Abp.Data; +using Volo.Abp.Domain.Entities.Auditing; + +namespace Acme.BookStore.Domain.Entities +{ + [SugarTable("Book")] + public class BookAggregateRoot : AuditedAggregateRoot + { + [SugarColumn(IsPrimaryKey = true)] + public override Guid Id { get; protected set; } + public string Name { get; set; } + + public BookTypeEnum Type { get; set; } + + public DateTime PublishDate { get; set; } + + public float Price { get; set; } + + [SugarColumn(IsIgnore = true)] + public override ExtraPropertyDictionary ExtraProperties { get; protected set; } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Domain/YiAbpDomainModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/YiAbpDomainModule.cs new file mode 100644 index 00000000..64a8422b --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Domain/YiAbpDomainModule.cs @@ -0,0 +1,26 @@ +using Volo.Abp.Caching; +using Volo.Abp.Domain; +using Volo.Abp.Modularity; +using Acme.BookStore.Domain.Shared; +using Yi.Framework.Bbs.Domain; +using Yi.Framework.Mapster; +using Yi.Framework.Rbac.Domain; + +namespace Acme.BookStore.Domain +{ + [DependsOn( + typeof(YiAbpDomainSharedModule), + + + typeof(YiFrameworkRbacDomainModule), + typeof(YiFrameworkBbsDomainModule), + + typeof(YiFrameworkMapsterModule), + typeof(AbpDddDomainModule), + typeof(AbpCachingModule) + )] + public class YiAbpDomainModule : AbpModule + { + + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/Acme.BookStore.SqlSugarCore.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/Acme.BookStore.SqlSugarCore.csproj new file mode 100644 index 00000000..7e06f4c3 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/Acme.BookStore.SqlSugarCore.csproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/DataSeeds/BookStoreDataSeed.cs b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/DataSeeds/BookStoreDataSeed.cs new file mode 100644 index 00000000..219a975e --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/DataSeeds/BookStoreDataSeed.cs @@ -0,0 +1,50 @@ +using Acme.BookStore.Domain.Entities; +using Acme.BookStore.Domain.Shared.Enums; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Acme.BookStore.SqlSugarCore.DataSeeds +{ + public class BookStoreDataSeed : IDataSeedContributor, ITransientDependency + { + private ISqlSugarRepository _bookRepository; + private IGuidGenerator _guidGenerator; + public BookStoreDataSeed(ISqlSugarRepository repository, IGuidGenerator guidGenerator) + { + _bookRepository = repository; + _guidGenerator = guidGenerator; + } + + public async Task SeedAsync(DataSeedContext context) + { + if (!await _bookRepository.IsAnyAsync(x => true)) + { + await _bookRepository.InsertAsync( + new BookAggregateRoot + { + Name = "1984", + Type = BookTypeEnum.Dystopia, + PublishDate = new DateTime(1949, 6, 8), + Price = 19.84f + }, + autoSave: true + ); + + await _bookRepository.InsertAsync( + new BookAggregateRoot + { + Name = "The Hitchhiker's Guide to the Galaxy", + Type = BookTypeEnum.ScienceFiction, + PublishDate = new DateTime(1995, 9, 27), + Price = 42.0f + }, + autoSave: true + ); + } + } + + + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiAbpSqlSugarCoreModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiAbpSqlSugarCoreModule.cs new file mode 100644 index 00000000..aad1e224 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiAbpSqlSugarCoreModule.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Acme.BookStore.Domain; +using Acme.BookStore.SqlSugarCore; +using Yi.Framework.Bbs.SqlSugarCore; +using Yi.Framework.Mapster; +using Yi.Framework.Rbac.SqlSugarCore; +using Yi.Framework.SqlSugarCore; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Acme.BookStore.SqlsugarCore +{ + [DependsOn( + typeof(YiAbpDomainModule), + + typeof(YiFrameworkRbacSqlSugarCoreModule), + typeof(YiFrameworkBbsSqlSugarCoreModule), + + typeof(YiFrameworkMapsterModule), + typeof(YiFrameworkSqlSugarCoreModule) + )] + public class YiAbpSqlSugarCoreModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddYiDbContext(); + //默认不开放,可根据项目需要是否Db直接对外开放 + //context.Services.AddTransient(x => x.GetRequiredService().SqlSugarClient); + } + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiDbContext.cs b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiDbContext.cs new file mode 100644 index 00000000..10c9265d --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.SqlSugarCore/YiDbContext.cs @@ -0,0 +1,45 @@ +using Microsoft.Extensions.Logging; +using SqlSugar; +using Volo.Abp.DependencyInjection; +using Yi.Framework.Rbac.SqlSugarCore; + +namespace Acme.BookStore.SqlSugarCore +{ + public class YiDbContext : YiRbacDbContext + { + public YiDbContext(IAbpLazyServiceProvider lazyServiceProvider) : base(lazyServiceProvider) + { + } + + protected override void CustomDataFilter() + { + base.CustomDataFilter(); + } + + + protected override void DataExecuted(object oldValue, DataAfterModel entityInfo) + { + base.DataExecuted(oldValue, entityInfo); + } + + protected override void DataExecuting(object oldValue, DataFilterModel entityInfo) + { + base.DataExecuting(oldValue, entityInfo); + } + + protected override void OnLogExecuting(string sql, SugarParameter[] pars) + { + base.OnLogExecuting(sql, pars); + } + + protected override void OnLogExecuted(string sql, SugarParameter[] pars) + { + base.OnLogExecuted(sql, pars); + } + + protected override void OnSqlSugarClientConfig(ISqlSugarClient sqlSugarClient) + { + base.OnSqlSugarClientConfig(sqlSugarClient); + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/Acme.BookStore.Web.csproj b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Acme.BookStore.Web.csproj new file mode 100644 index 00000000..24aadf59 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Acme.BookStore.Web.csproj @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + Always + + + + + + Always + + + + + + + + diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/Program.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Program.cs new file mode 100644 index 00000000..47c11001 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Program.cs @@ -0,0 +1,37 @@ +using Serilog; +using Serilog.Events; +using Acme.BookStore.Web; + +//创建日志,可使用{SourceContext}记录 +Log.Logger = new LoggerConfiguration() +.MinimumLevel.Debug() +.MinimumLevel.Override("Microsoft", LogEventLevel.Information) +.MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics", LogEventLevel.Error) +.MinimumLevel.Override("Quartz", LogEventLevel.Warning) +.Enrich.FromLogContext() +.WriteTo.Async(c => c.File("logs/all/log-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Debug)) +.WriteTo.Async(c => c.File("logs/error/errorlog-.txt", rollingInterval: RollingInterval.Day, restrictedToMinimumLevel: LogEventLevel.Error)) +.WriteTo.Async(c => c.Console(restrictedToMinimumLevel: LogEventLevel.Information)) +.CreateLogger(); + +try +{ + Log.Information("Yi框架-Abp.vNext,启动!"); + + var builder = WebApplication.CreateBuilder(args); + builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]); + builder.Host.UseAutofac(); + builder.Host.UseSerilog(); + await builder.Services.AddApplicationAsync(); + var app = builder.Build(); + await app.InitializeApplicationAsync(); + await app.RunAsync(); +} +catch (Exception ex) +{ + Log.Fatal(ex, "Yi框架-Abp.vNext,爆炸!"); +} +finally +{ + Log.CloseAndFlush(); +} \ No newline at end of file diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/Properties/launchSettings.json b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Properties/launchSettings.json new file mode 100644 index 00000000..e414500f --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Web/Properties/launchSettings.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "Acme.BookStore.Web": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:19001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/sample/Acme.BookStore.Web/YiAbpWebModule.cs new file mode 100644 index 00000000..e669375f --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Web/YiAbpWebModule.cs @@ -0,0 +1,198 @@ +using System.Text; +using System.Text.Json.Serialization; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Cors; +using Microsoft.IdentityModel.Tokens; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Volo.Abp; +using Volo.Abp.AspNetCore.Authentication.JwtBearer; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc.AntiForgery; +using Volo.Abp.AspNetCore.Serilog; +using Volo.Abp.Auditing; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; +using Volo.Abp.Swashbuckle; +using Acme.BookStore.Application; +using Acme.BookStore.SqlsugarCore; +using Yi.Framework.AspNetCore; +using Yi.Framework.AspNetCore.Authentication.OAuth; +using Yi.Framework.AspNetCore.Authentication.OAuth.Gitee; +using Yi.Framework.AspNetCore.Authentication.OAuth.QQ; +using Yi.Framework.AspNetCore.Microsoft.AspNetCore.Builder; +using Yi.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection; +using Yi.Framework.Bbs.Application; +using Yi.Framework.Rbac.Application; +using Yi.Framework.Rbac.Domain.Shared.Options; + +namespace Acme.BookStore.Web +{ + [DependsOn( + typeof(YiAbpSqlSugarCoreModule), + typeof(YiAbpApplicationModule), + + + typeof(AbpAspNetCoreMvcModule), + typeof(AbpAutofacModule), + typeof(AbpSwashbuckleModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAuditingModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(YiFrameworkAspNetCoreModule), + typeof(YiFrameworkAspNetCoreAuthenticationOAuthModule) + + )] + public class YiAbpWebModule : AbpModule + { + private const string DefaultCorsPolicyName = "Default"; + public override Task ConfigureServicesAsync(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + var host = context.Services.GetHostingEnvironment(); + var service = context.Services; + + //请求日志 + Configure(optios => + { + optios.IsEnabled = true; + optios.AlwaysLogSelectors.Add(x => Task.FromResult(true)); + }); + + //动态Api + Configure(options => + { + 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"); + }); + + //设置api格式 + service.AddControllers().AddNewtonsoftJson(options => + { + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + options.SerializerSettings.Converters.Add(new StringEnumConverter()); + }); + + Configure(options => + { + options.AutoValidate = false; + }); + + //Swagger + context.Services.AddYiSwaggerGen(options => + { + options.SwaggerDoc("default", new OpenApiInfo { Title = "Yi.Framework.Abp", Version = "v1", Description = "集大成者" }); + }); + + //跨域 + context.Services.AddCors(options => + { + options.AddPolicy(DefaultCorsPolicyName, builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"]! + .Split(";", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + + + //jwt鉴权 + var jwtOptions = configuration.GetSection(nameof(JwtOptions)).Get(); + context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.TokenValidationParameters = new TokenValidationParameters + { + ClockSkew = TimeSpan.Zero, + ValidateIssuer = true, + ValidateAudience = true, + ValidateLifetime = true, + ValidateIssuerSigningKey = true, + ValidIssuer = jwtOptions.Issuer, + ValidAudience = jwtOptions.Audience, + RequireExpirationTime = true, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtOptions.SecurityKey)) + }; + options.Events = new JwtBearerEvents + { + OnMessageReceived = context => + { + var accessToken = context.Request.Query["access_token"]; + if (!string.IsNullOrEmpty(accessToken)) + { + context.Token = accessToken; + } + return Task.CompletedTask; + } + }; + }) + .AddQQ(options => + { + configuration.GetSection("OAuth:QQ").Bind(options); + }) + .AddGitee(options => + { + configuration.GetSection("OAuth:Gitee").Bind(options); + }); + + //授权 + context.Services.AddAuthorization(); + return Task.CompletedTask; + } + + + public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) + { + var service = context.ServiceProvider; + + var env = context.GetEnvironment(); + var app = context.GetApplicationBuilder(); + + app.UseRouting(); + + //跨域 + app.UseCors(DefaultCorsPolicyName); + + //鉴权 + app.UseAuthentication(); + + //swagger + app.UseYiSwagger(); + + //请求处理 + app.UseYiApiHandlinge(); + + //静态资源 + app.UseStaticFiles("/api/app/wwwroot"); + app.UseDefaultFiles(); + app.UseDirectoryBrowser("/api/app/wwwroot"); + + //工作单元 + app.UseUnitOfWork(); + + //授权 + app.UseAuthorization(); + + //审计日志 + app.UseAuditing(); + + //日志记录 + app.UseAbpSerilogEnrichers(); + + //终节点 + app.UseConfiguredEndpoints(); + + return Task.CompletedTask; + } + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/appsettings.json b/Yi.Abp.Net8/sample/Acme.BookStore.Web/appsettings.json new file mode 100644 index 00000000..5ee98247 --- /dev/null +++ b/Yi.Abp.Net8/sample/Acme.BookStore.Web/appsettings.json @@ -0,0 +1,71 @@ +{ + "Logging": { + "LogLevel": { + //"Default": "Information", + "Default": "Debug", + "Microsoft.AspNetCore": "Warning" + } + }, + //应用启动 + "App": { + "SelfUrl": "http://*:19001", + "CorsOrigins": "http://localhost:19001;http://localhost:18000" + }, + + //数据库类型列表 + "DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ], + + "DbConnOptions": { + "Url": "DataSource=yi-abp-dev.db", + "DbType": "Sqlite", + "EnabledReadWrite": false, + "EnabledCodeFirst": true, + "EnabledSqlLog": true, + "EnabledDbSeed": true + //读写分离地址 + //"ReadUrl": [ + // "DataSource=[xxxx]", //Sqlite + // "server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]", //Mysql + // "Data Source=[xxxx];Initial Catalog=[xxxx];User ID=[xxxx];password=[xxxx]" //Sqlserver + //] + }, + + //鉴权 + "JwtOptions": { + "Issuer": "https://ccnetcore.com", + "Audience": "https://ccnetcore.com", + "SecurityKey": "zqxwcevrbtnymu312412ihe9rfwhe78rh23djoi32hrui3ryf9e8wfh34iuj54y0934uti4h97fgw7hf97wyh8yy69520", + "ExpiresMinuteTime": 86400 + }, + + //第三方登录 + "OAuth": { + //QQ + "QQ": { + "ClientId": "", + "ClientSecret": "", + "RedirectUri": "" + }, + //码云 + "Gitee": { + "ClientId": "", + "ClientSecret": "", + "RedirectUri": "" + } + }, + + //Rbac模块 + "RbacOptions": { + //超级管理员种子数据默认密码 + "AdminPassword": "123456", + + //是否开启验证码验证 + "EnableCaptcha": true, + + //是否开启注册功能 + "EnableRegister": false, + + //开启定时数据库备份 + "EnableDataBaseBackup": false + } +} diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/ip2region.db b/Yi.Abp.Net8/sample/Acme.BookStore.Web/ip2region.db new file mode 100644 index 00000000..0fc60e6c Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/ip2region.db differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/0.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/0.png new file mode 100644 index 00000000..652bdf37 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/0.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/1.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/1.png new file mode 100644 index 00000000..1431fa2f Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/1.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/10.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/10.png new file mode 100644 index 00000000..11bd6ddb Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/10.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/11.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/11.png new file mode 100644 index 00000000..b32859e8 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/11.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/12.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/12.png new file mode 100644 index 00000000..7f08f26f Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/12.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/13.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/13.png new file mode 100644 index 00000000..f7406b6e Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/13.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/14.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/14.png new file mode 100644 index 00000000..b9e70ef6 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/14.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/2.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/2.png new file mode 100644 index 00000000..302112b9 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/2.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/3.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/3.png new file mode 100644 index 00000000..b06ceb01 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/3.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/4.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/4.png new file mode 100644 index 00000000..bd47b1fe Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/4.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/5.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/5.png new file mode 100644 index 00000000..0d1a1d2a Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/5.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/6.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/6.png new file mode 100644 index 00000000..c116c298 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/6.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/8.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/8.png new file mode 100644 index 00000000..c3f6dc07 Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/8.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/9.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/9.png new file mode 100644 index 00000000..b7c8410f Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/icon/9.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/logo.png b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/logo.png new file mode 100644 index 00000000..226b005a Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/wwwroot/logo.png differ diff --git a/Yi.Abp.Net8/sample/Acme.BookStore.Web/yi-abp-dev.db b/Yi.Abp.Net8/sample/Acme.BookStore.Web/yi-abp-dev.db new file mode 100644 index 00000000..0dd9bece Binary files /dev/null and b/Yi.Abp.Net8/sample/Acme.BookStore.Web/yi-abp-dev.db differ