郑渤旭[Irelia] 1 year ago
parent
commit
bfcb15c665
  1. 42
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs
  2. 2
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/Faster.Zheng.Winin.Application.csproj
  3. 162
      Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Pages/Index.cshtml

42
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/AppBase/ZbxBase.cs

@ -6,6 +6,7 @@ using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using Faster.Zheng.Winin.AppBase.Filters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
@ -13,7 +14,9 @@ using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EntityFrameworkCore;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
using static OpenIddict.Abstractions.OpenIddictConstants;
namespace Faster.Zheng.Winin.AppBase;
@ -25,6 +28,8 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
where TEntityDto : IEntityDto<TKey>
{
private readonly IRepository<TEntity, TKey> _repository;
private readonly IMapper _mapper;
private Func<TCreateInput, Entity> _mapFunc;
public ZbxBase(IRepository<TEntity, TKey> repository) : base(repository)
{
@ -44,6 +49,8 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
public async Task<PagedResultDto<TEntityDto>> GetPageListByFilterAsync(SfsRequestInputBase sfsRequestInputBase,
bool includeDetails = false, CancellationToken cancellationToken = default)
{
//await TestSqlAsync();
var expression = sfsRequestInputBase.Condition.Filters?.Count > 0
? sfsRequestInputBase.Condition.Filters.ToLambda<TEntity>()
: p => true;
@ -53,8 +60,9 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
sfsRequestInputBase.Sorting, includeDetails, cancellationToken);
var resultDtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(resultEntities);
//获取总数
var totalCount =await GetCountAsync(expression, cancellationToken);
var totalCount = await GetCountAsync(expression, cancellationToken);
return new PagedResultDto<TEntityDto>(totalCount, resultDtos);
}
@ -69,8 +77,8 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
private async Task<long> GetCountAsync(Expression<Func<TEntity, bool>> expression,
CancellationToken cancellationToken = default)
{
var count= await _repository.LongCountAsync(expression, cancellationToken: cancellationToken);
var count = await _repository.LongCountAsync(expression, cancellationToken: cancellationToken);
return count;
}
@ -83,6 +91,20 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
public override async Task<TEntityDto> CreateAsync(TCreateInput input)
{
await CheckCreatePolicyAsync();
var mapperConfig = new MapperConfiguration(cfg =>
{
cfg.CreateMap<TCreateInput, TEntity>();
});
var _mapper = mapperConfig.CreateMapper();
var source = Expression.Parameter(typeof(TCreateInput), "source");
_mapFunc = Expression.Lambda<Func<TCreateInput, TEntity>>(
Expression.Invoke(Expression.Constant(_mapper.Map<TCreateInput, TEntity>)), source)
.Compile();
var tt= _mapper.Map<TCreateInput, TEntity>(input);
var entity = await MapToEntityAsync(input);
//判断id是否是00000-0000 如果是则赋值
@ -246,5 +268,19 @@ public class ZbxBase<TEntity, TEntityDto, TKey, TPagedAndSortedResultRequestDto,
return entities;
}
//private async Task TestSqlAsync()
//{
// var dbContext=await _dbContextProvider.GetDbContextAsync().ConfigureAwait(false);
// var query = dbContext.TestSchools
// .Join(dbContext.TestStudentDetails, TPK => TPK.Id, TFK => TFK.MasterId, (TPK, TFK) => new { TPK, TFK })
// .Where(result => result.TFK.StudentName == "阎致远");
// foreach (var result in query)
// {
// Console.WriteLine($"Customer: {result.TFK.StudentName}, Order ID: {result.TPK.SchoolName}");
// }
//}
#endregion
}

2
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Application/Faster.Zheng.Winin.Application.csproj

@ -16,8 +16,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.1" />
<PackageReference Include="Volo.Abp.Account.Application" Version="7.2.1" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="7.2.1" />
<PackageReference Include="Volo.Abp.Identity.Application" Version="7.2.1" />
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="7.2.1" />
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="7.2.1" />

162
Code/Be/Faster.Zheng.Winin/src/Faster.Zheng.Winin.Web/Pages/Index.cshtml

@ -16,9 +16,9 @@
<div class="d-inline-block bg-success text-white p-1 h5 rounded mb-4 " role="alert">
<h5 class="m-1"> <i class="fas fa-rocket"></i> Congratulations, <strong>Winin</strong> is successfully running!</h5>
</div>
<h1>Welcome to the Application</h1>
<h1>Faster.Zheng.Winin</h1>
<p class="lead px-lg-5 mx-lg-5">@L["LongWelcomeMessage"]</p>
<p class="lead px-lg-5 mx-lg-5">郑渤旭-快速开发Demo</p>
@if (!CurrentUser.IsAuthenticated)
{
@ -26,162 +26,4 @@
}
</div>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-auto text-center">
<img src="https://abp.io/assets/png/mastering-abp-framework.webp" style="max-width: 400px;" class="w-100 mb-5 my-md-3">
</div>
<div class="col-md d-flex align-items-center">
<div class="pe-0 pe-md-4">
<small class="text-uppercase text-muted">THE OFFICIAL GUIDE</small>
<h2 class="mb-4">Mastering ABP Framework</h2>
<p class="mb-4">Written by the creator of the ABP Framework, this book will help you gain a complete understanding of the framework and modern web application development techniques.</p>
<div class="mb-4">
<a href="https://www.amazon.com/gp/product/B097Z2DM8Q/ref=dbs_a_def_rwt_hsch_vapi_tkin_p1_i0" class="btn btn-success mb-1">
Buy on Amazon US
</a>
<a href="https://www.packtpub.com/product/mastering-abp-framework/9781801079242" class="btn btn-primary mb-1">
Buy on PACKT
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="my-3 text-center">
<h3>Let's improve your application!</h3>
<p>Here are some links to help you get started:</p>
</div>
<div class="card mt-4 mb-5">
<div class="card-body">
<div class="row text-center justify-content-md-center">
<div class="col-lg-4">
<div class="p-4">
<h5 class="mb-3"><i class="fas fa-book text-secondary d-block my-3 fa-2x"></i> Learn the ABP Framework</h5>
<p>Explore the compherensive documentation to learn how to build a modern web application.</p>
<a href="https://docs.abp.io/en/abp/latest?ref=tmpl" target="_blank" class="btn btn-link px-1">See Documents <i class="fas fa-chevron-right"></i></a>
</div>
</div>
<div class="col-lg-4 border-start">
<div class="p-4">
<h5 class="mb-3"><i class="fas fa-cubes text-secondary d-block my-3 fa-2x"></i> Samples</h5>
<p>See the example projects built with the ABP Framework.</p>
<a href="https://docs.abp.io/en/abp/latest/Samples/Index?ref=tmpl" target="_blank" class="btn btn-link px-1">All samples <i class="fas fa-chevron-right"></i></a>
</div>
</div>
<div class="col-lg-4 border-start">
<div class="p-4">
<h5 class="mb-3"><i class="fas fa-users text-secondary d-block my-3 fa-2x"></i> ABP Community</h5>
<p>Get involved with a vibrant community and become a contributor.</p>
<a href="https://community.abp.io/" target="_blank" class="btn btn-link px-1">Community <i class="fas fa-chevron-right"></i></a>
<a href="https://docs.abp.io/en/abp/latest/Contribution/Index?ref=tmpl" target="_blank" class="btn btn-link px-1">Contribute <i class="fas fa-chevron-right"></i></a>
</div>
</div>
</div>
<div class="row text-center mt-lg-3 justify-content-md-center">
<div class="col-lg-4">
<div class="p-4">
<h5 class="mb-3"><i class="fas fa-pen-nib text-secondary d-block my-3 fa-2x"></i> ABP Blog</h5>
<p>Take a look at our recently published articles.</p>
<a href="https://blog.abp.io/abp?ref=tmpl" target="_blank" class="btn btn-link px-1">See Blog <i class="fas fa-chevron-right"></i></a>
</div>
</div>
<div class="col-lg-4 border-start">
<div class="p-4">
<h5 class="mb-3"><i class="fab fa-github text-secondary d-block my-3 fa-2x"></i> Github</h5>
<p>Do you love the ABP Framework? Please <strong>give a star</strong> to support it!</p>
<p class="mb-1">
<a class="github-button" href="https://github.com/abpframework/abp" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star abpframework/abp on GitHub">Star</a>
<a class="github-button" href="https://github.com/abpframework/abp/issues" data-icon="octicon-issue-opened" data-size="large" data-show-count="false" aria-label="Issue abpframework/abp on GitHub">Issue</a>
<a class="github-button" href="https://github.com/abpframework/abp/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="false" aria-label="Fork abpframework/abp on GitHub">Fork</a>
</p>
<a href="https://github.com/abpframework/abp/issues/new?template=feature.md" target="_blank" class="btn btn-link px-1">Request a feature <i class="fas fa-chevron-right"></i></a>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</div>
</div>
<div class="col-lg-4 border-start">
<div class="p-4">
<h5 class="mb-3"><i class="fab fa-stack-overflow text-secondary d-block my-3 fa-2x"></i> Stackoverflow</h5>
<p>See answers to previously asked questions or ask a new one.</p>
<a href="https://stackoverflow.com/questions/tagged/abp" target="_blank" class="btn btn-link px-1">Questions <i class="fas fa-chevron-right"></i></a>
<a href="https://stackoverflow.com/questions/ask" target="_blank" class="btn btn-link px-1">Ask a Question <i class="fas fa-chevron-right"></i></a>
</div>
</div>
</div>
</div>
</div>
<div class="mt-5 my-3 text-center">
<h3>Meet the ABP Commercial</h3>
<p>A Complete Web Application Platform Built on the ABP Framework</p>
</div>
<div class="card mt-4 mb-5">
<div class="card-body">
<p class="px-lg-5 mx-lg-5 py-3 text-center">
<a href="https://commercial.abp.io/" target="_blank">ABP Commercial</a> is a platform based on the open source ABP framework. It provides pre-built application modules,
rapid application development tooling, professional UI themes, premium support and more.
</p>
<div class="row text-center justify-content-md-center">
<div class="col-lg-2">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Startup Templates
<a href="https://commercial.abp.io/startup-templates?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
<div class="col-lg-2 border-start">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Application Modules
<a href="https://commercial.abp.io/modules?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
<div class="col-lg-2 border-start">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Developer<br />Tools
<a href="https://commercial.abp.io/tools?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
<div class="col-lg-2 border-start">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> UI<br /> Themes
<a href="https://commercial.abp.io/themes?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
<div class="col-lg-2 border-start">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Premium Support
<a href="https://support.abp.io/QA/Questions?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
<div class="col-lg-2 border-start">
<div class="p-3">
<h6>
<i class="fas fa-plus d-block mb-3 fa- 2x text-secondary"></i> Additional Services
<a href="https://commercial.abp.io/additional-services?ref=tmpl" target="_blank" class="d-block mt-2 btn btn-sm btn-link">Details <i class="fas fa-chevron-right"></i></a>
</h6>
</div>
</div>
</div>
</div>
</div>
<div class="mb-5 text-center">
<p class="align-middle">
<a href="https://twitter.com/abpframework" target="_blank" class="mx-2"><i class="fa fa-twitter"></i><span class="text-secondary"> Abp Framework</span></a>
<a href="https://twitter.com/abpcommercial" target="_blank" class="mx-2"><i class="fa fa-twitter"></i><span class="text-secondary"> Abp Commercial</span></a>
<a href="https://github.com/abpframework/abp" target="_blank" class="mx-2"><i class="fa fa-github"></i><span class="text-secondary"> abpframework</span></a>
</p>
</div>
</div>

Loading…
Cancel
Save