当前位置: 首页 > news >正文

江苏省建设工人考勤网站成都最好玩的地方排名

江苏省建设工人考勤网站,成都最好玩的地方排名,网页设计与制作教程第二版刘瑞新,以前做视频的网站吗框架搭建2聚合服务这里我们将聚合服务命名为Domain.Core和基础服务层一致#xff0c;我们先通过命令创建单层模板项目Domain.Core#xff0c;这里我们删除wwwroot、Data、Entities、Localization、ObjectMapping文件夹及其所有子文件#xff0c;并删除package.json文件和Ser…框架搭建2聚合服务这里我们将聚合服务命名为Domain.Core和基础服务层一致我们先通过命令创建单层模板项目Domain.Core这里我们删除wwwroot、Data、Entities、Localization、ObjectMapping文件夹及其所有子文件并删除package.json文件和Services文件夹下的Dtos文件夹在同级目录添加类库Domain.Core.Constracts并删除其中的Class1.cs文件这里我们在聚合服务中暂时不需要提供动态客户端代理暂时不创建.Client项目如果需要创建方式和基础服务层相同。修改Demo.Core.csproj文件如下Project SdkMicrosoft.NET.Sdk.WebPropertyGroupTargetFrameworknet6.0/TargetFrameworkImplicitUsingsenable/ImplicitUsingsGenerateEmbeddedFilesManifesttrue/GenerateEmbeddedFilesManifest/PropertyGroupItemGroupPackageReference IncludeSerilog.AspNetCore Version5.0.0 /PackageReference IncludeSerilog.Sinks.Async Version1.5.0 //ItemGroupItemGroupPackageReference IncludeVolo.Abp.AspNetCore.Mvc Version5.3.4 /PackageReference IncludeVolo.Abp.Autofac Version5.3.4 /PackageReference IncludeVolo.Abp.Swashbuckle Version5.3.4 /PackageReference IncludeVolo.Abp.AspNetCore.Serilog Version5.3.4 //ItemGroupItemGroupPackageReference IncludeMicrosoft.Extensions.FileProviders.Embedded Version6.0.5 //ItemGroupItemGroupContent RemoveLocalization\Core\*.json /EmbeddedResource IncludeLocalization\Core\*.json /EmbeddedResource Removewwwroot\** /Content Removewwwroot\** /Content Removepackage.json //ItemGroupItemGroupCompile RemoveLogs\** /Content RemoveLogs\** /EmbeddedResource RemoveLogs\** /None RemoveLogs\** /Compile Removewwwroot\** /None Removewwwroot\** //ItemGroupItemGroupProjectReference Include..\..\..\service\notificationmanager\Demo.NotificationManager.Client\Demo.NotificationManager.Client.csproj /ProjectReference Include..\Demo.Core.Contracts\Demo.Core.Contracts.csproj //ItemGroup /Project修改CoreModule.cs类代码如下using Demo.Core.Contracts; using Demo.NotificationManager.Client; using Microsoft.OpenApi.Models; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.Modularity; using Volo.Abp.Swashbuckle;namespace Demo.Core;[DependsOn(// ABP Framework packagestypeof(AbpAspNetCoreMvcModule),typeof(AbpAutofacModule),typeof(AbpSwashbuckleModule),typeof(AbpAspNetCoreSerilogModule),typeof(CoreContractsModule),typeof(NotificationManagerClientModule) )] public class CoreModule : AbpModule {#region 私有方法#region 配置动态WebApiprivate void ConfigureAutoApiControllers(){ConfigureAbpAspNetCoreMvcOptions(options {options.ConventionalControllers.Create(typeof(CoreModule).Assembly);});}#endregion#region 配置swaggerprivate void ConfigureSwagger(IServiceCollection services){services.AddAbpSwaggerGen(options {options.SwaggerDoc(v1, new OpenApiInfo { Title Core API, Version v1 });options.DocInclusionPredicate((docName, description) true);options.CustomSchemaIds(type type.FullName);});}#endregion#endregionpublic override void ConfigureServices(ServiceConfigurationContext context){ConfigureSwagger(context.Services);ConfigureAutoApiControllers();}public override void OnApplicationInitialization(ApplicationInitializationContext context){var app context.GetApplicationBuilder();app.UseRouting();app.UseUnitOfWork();app.UseSwagger();app.UseSwaggerUI(options {options.SwaggerEndpoint(/swagger/v1/swagger.json, Core API);});app.UseAbpSerilogEnrichers();app.UseConfiguredEndpoints();} }修改Program.cs文件内容如下using Demo.Core; using Serilog; using Serilog.Events;Log.Logger new LoggerConfiguration() #if DEBUG.MinimumLevel.Debug() #else.MinimumLevel.Information() #endif.MinimumLevel.Override(Microsoft, LogEventLevel.Information).Enrich.FromLogContext().WriteTo.Async(c c.File(Logs/logs.txt)) #if DEBUG.WriteTo.Async(c c.Console()) #endif.CreateLogger();var builder WebApplication.CreateBuilder(args);builder.Host.UseAutofac().UseSerilog(); builder.Services.ReplaceConfiguration(builder.Configuration); builder.Services.AddApplicationCoreModule();var app  builder.Build(); app.InitializeApplication(); app.Run();修改appsettings.json文件如下{urls: http://*:6003,RemoteServices: {NitificationManager: {BaseUrl: http://localhost:5003/}} }修改Demo.Core.Contracts.csproj文件Project SdkMicrosoft.NET.SdkPropertyGroupTargetFrameworknet6.0/TargetFrameworkImplicitUsingsenable/ImplicitUsingsNullableenable/Nullable/PropertyGroupItemGroupPackageReference IncludeVolo.Abp.Ddd.Application.Contracts Version5.3.4 //ItemGroup /Project在Demo.Core.Contracts项目中创建CoreContractsModule.cs文件内容如下using Volo.Abp.Application; using Volo.Abp.Modularity;namespace Demo.Core.Contracts;[DependsOn(typeof(AbpDddApplicationContractsModule) )] public class CoreContractsModule : AbpModule {}启动Demo.Core项目可正常运行并显示swagger页面则聚合服务创建成功。业务代码1基础服务在Demo.NotificationManager项目Entities文件夹中按领域划分子文件夹这里创建Notifications领域文件夹并添加实体类Notification如下using System.ComponentModel.DataAnnotations; using Volo.Abp.Domain.Entities.Auditing;namespace Demo.NotificationManager.Entities.Notifications;/// summary /// 通知 /// /summary public class Notification : CreationAuditedEntityGuid {/// summary/// 接受着用户ID/// /summarypublic Guid ReceiverId { get; set; }/// summary/// 标题/// /summary[StringLength(128)]public string Title { get; set; }/// summary/// 内容/// /summarypublic string Content { get; set; }/// summary/// 是否已读/// /summarypublic bool IsRead { get; set; } }在Demo.NotificationManager项目Data文件夹下的NotificationManagerDbContext类中添加如下属性并引入相应依赖public DbSetNotification Notifications { get; set; }通过 dotnet-ef 的 migrations add 命令和 database update 命令创建数据库结构。这里我们未用到领域服务如果需要可在Demo.NotificationManager项目中添加Managers文件夹并按领域存放对应代码。在Demo.NotificationManager.Contracts项目中添加Services文件夹DTO和应用服务接口的定义。这里添加子文件夹Notifications并在其中添加Dtos文件夹用于存放DTO。我们添加以下两个DTO分别用于添加和查询通知using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos;namespace Demo.NotificationManager.Contracts.Services.Notifications.Dtos;public class NotificationCreateDto:EntityDtoGuid {/// summary/// 接受着用户ID/// /summarypublic Guid ReceiverId { get; set; }/// summary/// 标题/// /summary[StringLength(128)]public string Title { get; set; }/// summary/// 内容/// /summarypublic string Content { get; set; }/// summary/// 是否已读/// /summarypublic bool IsRead { get; set; } }using System.ComponentModel.DataAnnotations; using Volo.Abp.Application.Dtos; using Volo.Abp.Auditing;namespace Demo.NotificationManager.Contracts.Services.Notifications.Dtos;public class NotificationDto:NotificationCreateDto,ICreationAuditedObject {/// summary/// 创建时间/// /summarypublic DateTime CreationTime { get; set; }/// summary/// 创建者/// /summarypublic Guid? CreatorId { get; set; } }添加INotificationAppService应用服务接口内容如下using Demo.NotificationManager.Contracts.Services.Notifications.Dtos; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services;namespace Demo.NotificationManager.Contracts.Services.Notifications;public interfaceINotificationAppService : ICrudAppServiceNotificationDto, Guid, PagedResultRequestDto, NotificationCreateDto {}在Demo.NotificationManger中Services文件夹中添加应用服务实现类这里添加Notifications子文件夹并创建NotificationAppService类如下using Demo.Abp.Extension; using Demo.NotificationManager.Contracts.Services.Notifications; using Demo.NotificationManager.Contracts.Services.Notifications.Dtos; using Demo.NotificationManager.Entities.Notifications; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Repositories;namespace Demo.NotificationManager.Services.Notifications;public class NotificationAppService : CustomCrudAppServiceNotification, NotificationDto, Guid,PagedResultRequestDto,NotificationCreateDto, INotificationAppService {public NotificationAppService(IRepositoryNotification, Guid repository) : base(repository){} }此处我引入了Mapster框架替代原来的AutoMapper框架所以我们看到CustomCrudAppService类替代了默认增删改查类CrudAppService。CrudAppService类被存放在Demo.Abp.Extension类库中作为通用基类使用代码如下using Mapster; using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories;namespace Demo.Abp.Extension;#region 重载 public abstract class CustomCrudAppServiceTEntity, TEntityDto, TKey: CustomCrudAppServiceTEntity, TEntityDto, TKey, PagedAndSortedResultRequestDtowhere TEntity : class, IEntityTKeywhere TEntityDto : IEntityDtoTKey {protected CustomCrudAppService(IRepositoryTEntity, TKey repository): base(repository){} }public abstract class CustomCrudAppServiceTEntity, TEntityDto, TKey, TGetListInput: CustomCrudAppServiceTEntity, TEntityDto, TKey, TGetListInput, TEntityDtowhere TEntity : class, IEntityTKeywhere TEntityDto : IEntityDtoTKey {protected CustomCrudAppService(IRepositoryTEntity, TKey repository): base(repository){} }public abstract class CustomCrudAppServiceTEntity, TEntityDto, TKey, TGetListInput, TCreateInput: CustomCrudAppServiceTEntity, TEntityDto, TKey, TGetListInput, TCreateInput, TCreateInputwhere TEntity : class, IEntityTKeywhere TEntityDto : IEntityDtoTKey {protected CustomCrudAppService(IRepositoryTEntity, TKey repository): base(repository){} }public abstract class CustomCrudAppServiceTEntity, TEntityDto, TKey, TGetListInput, TCreateInput, TUpdateInput: CustomCrudAppServiceTEntity, TEntityDto, TEntityDto, TKey, TGetListInput, TCreateInput, TUpdateInputwhere TEntity : class, IEntityTKeywhere TEntityDto : IEntityDtoTKey {protected CustomCrudAppService(IRepositoryTEntity, TKey repository): base(repository){}protected override TaskTEntityDto MapToGetListOutputDtoAsync(TEntity entity){return MapToGetOutputDtoAsync(entity);}protected override TEntityDto MapToGetListOutputDto(TEntity entity){return MapToGetOutputDto(entity);} } #endregionpublic class CustomCrudAppServiceTEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput,TUpdateInput: CrudAppServiceTEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInputwhere TEntity : class, IEntityTKeywhere TGetOutputDto : IEntityDtoTKeywhere TGetListOutputDto : IEntityDtoTKey {public CustomCrudAppService(IRepositoryTEntity, TKey repository) : base(repository){}#region Mapsterprotected override TEntity MapToEntity(TCreateInput createInput){var entity createInput.AdaptTEntity();SetIdForGuids(entity);return entity;}protected override void MapToEntity(TUpdateInput updateInput, TEntity entity){if (updateInput is IEntityDtoTKey entityDto){entityDto.Id entity.Id;}entity updateInput.Adapt(entity);}protected override TGetOutputDto MapToGetOutputDto(TEntity entity){return entity.AdaptTGetOutputDto(); //ObjectMapper.MapTEntity, TGetOutputDto(entity);}protected override TGetListOutputDto MapToGetListOutputDto(TEntity entity){return entity.AdaptTGetListOutputDto(); //ObjectMapper.MapTEntity, TGetListOutputDto(entity);}#endregion }此类我继承自原有的CrudAppService类并重写了对象转换方法。使用Mapster比AutoMapper效率更高而且不需要提前声明默认的对象映射关系如果需要额外定义映射关系或操作可通过添加MapConfig类实现。具体用法参考其官方文档https://github.com/rivenfx/Mapster-docs如果我们需要定义领域通用配置、枚举等原属于Domain.Share项目中的内容可创建并存放在Demo.NotificationManager.Contracts项目下Share文件夹中。完成以上步骤并可成功运行Demo.NotificationManager项目则基础服务代码运行成功。未完待续关注我获得更多精彩
http://www.zqtcl.cn/news/375929/

相关文章:

  • 东莞市营销网站建设哪个推广网站好
  • 上海青浦房地产网站建设广西建设人才网
  • 做网站的网络公司税收优惠推广优化关键词
  • 找能做网站的怎么查看网站备案号
  • 石嘴山北京网站建设h5网站建设
  • 滨州区建设局网站中国建行官网首页
  • 网站建设服务网站网站建设销售实习
  • 网站注册都需要什么给装修公司做推广的网站
  • me域名的网站wordpress 扩展字段
  • 新开三端互通传奇网站企业推广方式有哪些
  • 怎么制作网站页面做理论的网站
  • 哪家公司做跳转网站wordpress 网页缩放
  • 小说网站建设的支柱深圳建设发展集团有限公司
  • 陕西高速公路建设网站做网站不用编程
  • wordpress网站秒开网站建设设计理念
  • html5 网站模板永久免费的仓库管理软件
  • 贵州网站seo厦门网站设计多少钱
  • 哈市哪里网站做的好合作网站seo
  • 找苏州网站建设网站维护提醒php文件
  • 哪些网站做推广效果好与市场营销有关的网站
  • 有什么网站可以做设计赚钱吗专业vi设计公司哪家强
  • 一般的网站是由什么语言做的网站建设怎么问问题
  • 开源系统 网站阿里云虚拟主机网站
  • 摄影师作品网站网站怎么做搜素引擎
  • 做网站定金是多少钱开网站建设公司心得
  • 网站不备案怎么做网页淘宝客电子商务的网站建设的可用性
  • 傻瓜自助建站软件怎样进网站空间服务器
  • 黑龙江网站建站建设wordpress 邮件
  • 免费发布信息网站有哪些豆芽网站建设
  • 无锡做网站优化公司互动营销用在哪些推广上面