feat: 去除sample
@@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.Ddd.Application.Contracts\Yi.Framework.Ddd.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Application.Contracts\Yi.Framework.Bbs.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Application.Contracts\Yi.Framework.Rbac.Application.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Acme.BookStore.Domain.Shared\Acme.BookStore.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,24 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Acme.BookStore.Domain.Shared.Enums;
|
||||
using Volo.Abp.Application.Dtos;
|
||||
|
||||
namespace Acme.BookStore.Application.Contracts.Dtos.Book
|
||||
{
|
||||
public class BookDto : AuditedEntityDto<Guid>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public BookTypeEnum Type { get; set; }
|
||||
|
||||
public DateTime PublishDate { get; set; }
|
||||
|
||||
public float Price { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
|
||||
|
||||
<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\" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
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 Acme.BookStore.Application.Jobs
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时任务
|
||||
/// </summary>
|
||||
public class TestJob : QuartzBackgroundWorkerBase
|
||||
{
|
||||
private ISqlSugarRepository<UserAggregateRoot> _repository;
|
||||
public TestJob(ISqlSugarRepository<UserAggregateRoot> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Domain.Shared" Version="$(AbpVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Domain.Shared\Yi.Framework.Bbs.Domain.Shared.csproj" />
|
||||
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Domain.Shared\Yi.Framework.Rbac.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Consts\" />
|
||||
<Folder Include="Dtos\" />
|
||||
<Folder Include="Etos\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,21 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
|
||||
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.SqlSugarCore.Abstractions\Yi.Framework.SqlSugarCore.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.Domain\Yi.Framework.Bbs.Domain.csproj" />
|
||||
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.Domain\Yi.Framework.Rbac.Domain.csproj" />
|
||||
<ProjectReference Include="..\Acme.BookStore.Domain.Shared\Acme.BookStore.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Managers\" />
|
||||
<Folder Include="Repositories\" />
|
||||
<Folder Include="EventHandlers\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,24 +0,0 @@
|
||||
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<Guid>
|
||||
{
|
||||
[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; }
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.Mapster\Yi.Framework.Mapster.csproj" />
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.SqlSugarCore\Yi.Framework.SqlSugarCore.csproj" />
|
||||
<ProjectReference Include="..\..\module\bbs\Yi.Framework.Bbs.SqlSugarCore\Yi.Framework.Bbs.SqlSugarCore.csproj" />
|
||||
<ProjectReference Include="..\..\module\rbac\Yi.Framework.Rbac.SqlSugarCore\Yi.Framework.Rbac.SqlSugarCore.csproj" />
|
||||
<ProjectReference Include="..\Acme.BookStore.Domain\Acme.BookStore.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Repositories\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,50 +0,0 @@
|
||||
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<BookAggregateRoot> _bookRepository;
|
||||
private IGuidGenerator _guidGenerator;
|
||||
public BookStoreDataSeed(ISqlSugarRepository<BookAggregateRoot> 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
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<YiDbContext>();
|
||||
//默认不开放,可根据项目需要是否Db直接对外开放
|
||||
//context.Services.AddTransient(x => x.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.3" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="$(AbpVersion)" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(AbpVersion)" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="$(AbpVersion)" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.AspNetCore.Authentication.OAuth\Yi.Framework.AspNetCore.Authentication.OAuth.csproj" />
|
||||
<ProjectReference Include="..\..\framework\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj" />
|
||||
<ProjectReference Include="..\Acme.BookStore.Application\Acme.BookStore.Application.csproj" />
|
||||
<ProjectReference Include="..\Acme.BookStore.SqlSugarCore\Acme.BookStore.SqlSugarCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Update="wwwroot\icon\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ip2region.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="database_backup\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,37 +0,0 @@
|
||||
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<YiAbpWebModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Yi框架-Abp.vNext,爆炸!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"$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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
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<AbpAuditingOptions>(optios =>
|
||||
{
|
||||
optios.IsEnabled = true;
|
||||
optios.AlwaysLogSelectors.Add(x => Task.FromResult(true));
|
||||
});
|
||||
|
||||
//动态Api
|
||||
Configure<AbpAspNetCoreMvcOptions>(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<AbpAntiForgeryOptions>(options =>
|
||||
{
|
||||
options.AutoValidate = false;
|
||||
});
|
||||
|
||||
//Swagger
|
||||
context.Services.AddYiSwaggerGen<YiAbpWebModule>(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<JwtOptions>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
{
|
||||
"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", "PostgreSQL" ],
|
||||
|
||||
"DbConnOptions": {
|
||||
"Url": "DataSource=yi-abp-dev.db",
|
||||
"DbType": "Sqlite",
|
||||
"EnabledReadWrite": false,
|
||||
"EnabledCodeFirst": true,
|
||||
"EnabledSqlLog": true,
|
||||
"EnabledDbSeed": true,
|
||||
"EnableUnderLine": false // 启用驼峰转下划线
|
||||
//读写分离地址
|
||||
//"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
|
||||
// "HOST=[xxxx];PORT=5432;DATABASE=[xxxx];USERID=[xxxx];PASSWORD=[xxxx]" //PostgreSQL
|
||||
//]
|
||||
},
|
||||
|
||||
//鉴权
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 119 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 9.9 KiB |
@@ -15,18 +15,21 @@ namespace Yi.Abp.Tool.Domain
|
||||
{
|
||||
private readonly ToolOptions _toolOptions;
|
||||
private readonly GiteeManager _giteeManager;
|
||||
|
||||
public TemplateGenManager(IOptionsMonitor<ToolOptions> toolOptions, GiteeManager giteeManager)
|
||||
{
|
||||
_giteeManager = giteeManager;
|
||||
_toolOptions = toolOptions.CurrentValue;
|
||||
}
|
||||
|
||||
public async Task<string> CreateTemplateAsync(TemplateGenCreateDto input)
|
||||
{
|
||||
//这里判断gitee上是否有这个分支
|
||||
if (await _giteeManager.IsExsitBranchAsync(input.GiteeRef))
|
||||
if (!await _giteeManager.IsExsitBranchAsync(input.GiteeRef))
|
||||
{
|
||||
throw new UserFriendlyException($"Gitee分支未找到{input.GiteeRef},请检查,[{input.GiteeRef}]分支是否存在");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(_toolOptions.TempDirPath))
|
||||
{
|
||||
throw new UserFriendlyException($"临时目录路径无法找到,请检查,[{_toolOptions.TempDirPath}]路径");
|
||||
@@ -39,35 +42,50 @@ namespace Yi.Abp.Tool.Domain
|
||||
Directory.CreateDirectory(tempFileDirPath);
|
||||
}
|
||||
|
||||
|
||||
//下载的模板存放文件路径
|
||||
var downloadFilePath = Path.Combine(_toolOptions.TempDirPath,"download" ,$"{id}.zip");
|
||||
var gitSteam= await _giteeManager.DownLoadFileAsync(input.GiteeRef);
|
||||
using (FileStream fileStream = new FileStream(downloadFilePath, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
await gitSteam.CopyToAsync(fileStream);
|
||||
}
|
||||
var downloadPath = Path.Combine(_toolOptions.TempDirPath, "download");
|
||||
if (!Directory.Exists(downloadPath))
|
||||
{
|
||||
Directory.CreateDirectory(downloadPath);
|
||||
}
|
||||
|
||||
var downloadFilePath = Path.Combine(downloadPath, $"{id}.zip");
|
||||
var gitSteam = await _giteeManager.DownLoadFileAsync(input.GiteeRef);
|
||||
using (FileStream fileStream = new FileStream(downloadFilePath, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
await gitSteam.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
//文件解压覆盖,将刚刚下载的模板,解压即可
|
||||
ZipFile.ExtractToDirectory(downloadFilePath, tempFileDirPath, true);
|
||||
|
||||
await ReplaceContentAsync(tempFileDirPath, input.ReplaceStrData);
|
||||
var tempFilePath = Path.Combine(_toolOptions.TempDirPath, $"{id}.zip");
|
||||
|
||||
ZipFile.CreateFromDirectory(tempFileDirPath, tempFilePath);
|
||||
//注意,这里下载的zip包,其实多了一层,我们进行操作的时候,要将操作目录进一步
|
||||
var operPath = Directory.GetDirectories(tempFileDirPath)[0];
|
||||
await ReplaceContentAsync(operPath, input.ReplaceStrData);
|
||||
var tempFilePath = Path.Combine(_toolOptions.TempDirPath, $"{id}.zip");
|
||||
ZipFile.CreateFromDirectory(operPath, tempFilePath);
|
||||
|
||||
//创建压缩包后删除临时目录
|
||||
Directory.Delete(tempFileDirPath, true);
|
||||
return tempFilePath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部模板列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> GetAllTemplatesAsync()
|
||||
{
|
||||
return await _giteeManager.GetAllBranchAsync();
|
||||
var refs = await _giteeManager.GetAllBranchAsync();
|
||||
|
||||
//移除主分支
|
||||
refs.Remove("master");
|
||||
return refs;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 替换内容,key为要替换的内容,value为替换成的内容
|
||||
/// </summary>
|
||||
@@ -132,6 +150,5 @@ namespace Yi.Abp.Tool.Domain
|
||||
return directoryPath;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\" />
|
||||
<Folder Include="wwwroot\temp\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -33,4 +34,8 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="wwwroot\temp\download\d5bb6f4c5ca24da29ebe1b67e1e4595d.zip" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Yi.Abp.Tool.Commands
|
||||
var pathOption = application.Option("-p|--path", "创建路径", CommandOptionType.SingleValue);
|
||||
var csfOption = application.Option("-csf", "是否创建解决方案文件夹", CommandOptionType.NoValue);
|
||||
|
||||
var soureOption = application.Option("-s|--soure", "模板来源,gitee模板库分支名称: 默认值`defualt`",
|
||||
var soureOption = application.Option("-s|--soure", "模板来源,gitee模板库分支名称: 默认值`default`",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
var moduleNameArgument = application.Argument("moduleName", "模块名", (_) => { });
|
||||
@@ -56,13 +56,27 @@ namespace Yi.Abp.Tool.Commands
|
||||
|
||||
application.OnExecute(() =>
|
||||
{
|
||||
var path = string.Empty;
|
||||
if (pathOption.HasValue())
|
||||
{
|
||||
path = pathOption.Value();
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 处理生成类型
|
||||
|
||||
var id = Guid.NewGuid().ToString("N");
|
||||
var zipPath = string.Empty;
|
||||
byte[] fileByteArray;
|
||||
|
||||
var soure= soureOption.HasValue() ? soureOption.Value() : "defualt";
|
||||
var soure= soureOption.HasValue() ? soureOption.Value() : "default";
|
||||
|
||||
var templateType = templateTypeOption.HasValue() ? templateTypeOption.Value() : "module";
|
||||
if (templateType == "module")
|
||||
@@ -83,11 +97,7 @@ namespace Yi.Abp.Tool.Commands
|
||||
}).Result;
|
||||
}
|
||||
|
||||
var path = string.Empty;
|
||||
if (pathOption.HasValue())
|
||||
{
|
||||
path = pathOption.Value();
|
||||
}
|
||||
|
||||
|
||||
zipPath = Path.Combine(path, $"{id}.zip");
|
||||
File.WriteAllBytes(zipPath, fileByteArray);
|
||||
|
||||
@@ -19,9 +19,9 @@ class Program
|
||||
// args = ["clear"];
|
||||
|
||||
//创建模块
|
||||
//args = ["new","oooo", "-t","module","-p","D:\\temp","-csf"];
|
||||
args = ["new","oooo", "-t","module","-p","D:\\temp","-csf"];
|
||||
//查看模板列表
|
||||
args = ["new","list"];
|
||||
//args = ["new","list"];
|
||||
|
||||
//添加模块
|
||||
//args = ["add-module", "kkk"];
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Yi.Abp.Tool
|
||||
Configure<AbpRemoteServiceOptions>(options =>
|
||||
{
|
||||
options.RemoteServices.Default =
|
||||
// new RemoteServiceConfiguration("https://ccnetcore.com:19009");
|
||||
new RemoteServiceConfiguration("http://localhost:19002");
|
||||
new RemoteServiceConfiguration("https://ccnetcore.com:19009");
|
||||
// new RemoteServiceConfiguration("http://localhost:19002");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||