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

dw怎么做网站地图临安规划建设局网站

dw怎么做网站地图,临安规划建设局网站,桂林网站制作报价,做软件与做网站建设有什么区别简介在之前的《ABP vNext微服务架构详细教程》系列中#xff0c;我们已经构建了完整的微服务架构实例#xff0c;但是在开发过程中#xff0c;我们会发现每个基础服务都包含10个类库#xff0c;这是给予DDD四层架构下ABP的实现方案#xff0c;但是实际使用中我们会发现我们已经构建了完整的微服务架构实例但是在开发过程中我们会发现每个基础服务都包含10个类库这是给予DDD四层架构下ABP的实现方案但是实际使用中我们会发现随着微服务的增多类库数量的确太过庞大了。而当时受到ABP vNext版本的限制并没有一个快速生成精简应用框架的方式。到了ABP vNext 5.3版本之后官方添加了新的模板——单层应用模板用于解决微服务架构单个项目类库过多的问题也给了我们可以快速构建精简的微服务项目的入口。这一篇我就基于单层应用模板对《ABP vNext微服务架构详细教程》系列原有微服务框架基础上进行简化在ABP vNext单层模板上进一步精简的同时提出一套在微服务架构下单层应用的最佳实践方案。此篇内容较长我会分多节呈现请一定阅读到最后。架构介绍在之前的文章编写时ABP vNext版本为5.1.1只有5.3.0之后版本才支持单页应用目前最新正式版版本为5.3.4这里我们单层模板以5.3.4版本为例。通过ABP CLI命令我们可以创建一个简单的单层应用模板项目。这里的单层是针对类库来说的也就是只有一层类库但是类库内部依旧包含着DDD下所有的元素只是按文件夹划分并且没有明确的分层界限。到当前版本为止ABP通过官方CLI命令创建的项目是必须包含用户角色权限信息管理和身份认证服务的项目。可以理解为过去应用模板的单层形式但实际在微服务架构下我们需要进行进一步的调整。对于整个微服务项目的总体架构和服务分层我们依旧沿用之前《ABP vNext微服务架构详细教程》中的设计详见https://mp.weixin.qq.com/s/uDGwxbEhBv15RdMlflb7LA在聚合服务层和基础服务层业务服务中我们使用单层模板为基础构建我们的服务。包含以下内容主服务WebAPI启动项也是ABP单层模板下生成的项目包含过去Domain、Application、EntityFramworkCore、HttpApi、HttpApi.Host项目的内容契约层当我们在聚合服务层依赖基础服务层时我们肯定只是希望依赖基础服务中接口声明而非实现所以将过去项目中的Application.Contracts和Domain.Shared两个类库中的内容从单层模板主项目抽离出来就是一个必须的工作。在这里我们将其放在契约层中动态客户端代理在之前的基础服务中包含一个特殊的类库HttpApi.Client。它是对基础服务层动态客户端代理的封装和配置它依赖于Application.Contracts项目在当前服务中我们依旧希望把它单独保留下来以便于聚合服务实现HTTP调用。这里基础服务层需要包含以上三个项目而聚合服务层目前没有提供动态客户端代理的需求所以可以只包含主服务和契约层。虽然从技术角度聚合服务中契约层也不是必须单独拿出来但是从架构一致性和扩展性角度我依旧推荐将契约单独存放。聚合服务层和基础服务层业务服务依赖关系如下图在整个微服务架构中身份管理基础服务比较特殊由于我们的授权中心依赖身份管理服务的EntityFrameworkCore如果采用单层架构则发现EntityFrameworkCore项目必须独立出来而EntityFrameworkCore依赖于Domain层则Domain层也需要独立此时我们发现这个项目已经违背了单层应用的初衷。所以身份管理的基础服务我们依旧采用之前的方式来构建。另外身份认证服务和网关本身就是单类库项目也不需要做调整。框架搭建1基础服务层基础服务我们命名为NotificationManager通过以下ABP CLI命令我们可以构建基础服务的主服务这里我们选择无UI模板MySQL数据库abp new Demo.NotificationManager -t app-nolayers -u none -dbms mysql将该服务添加至主解决方案service/notificationmanger解决方案文件夹下并在同目录下分别创建契约层类库 Demo.NotificationManager.Contracts 和动态客户端代理类库 Demo.NotificationManager.Client 。创建后结果如下图由于我们没有使用多语言所以直接将主项目中Localization文件夹所有内容删除。这里我打算使用另一种对象映射框架所以删除主项目中的ObjectMapping文件夹如果准备继续使用AutoMapper框架则保留该文件夹。移除主项目中Services文件夹中的Dtos子文件夹DTO不存放在该项目中而是在契约层。由于我们这边不涉及前端所以删除wwwroot文件夹和package.json文件。删除主服务Data文件夹下的IdentityServerDataSeedContributor.cs文件。删除后主服务项目结构如下编辑主项目的Demo.NotificationManager.csproj文件删除从  ItemGroup PackageReference IncludeVolo.Abp.Account.Application Version5.3.4 /  到  PackageReference IncludeMicrosoft.Extensions.FileProviders.Embedded Version6.0.5 / /ItemGroup 的所有引用及AutoMapper引用保留如下内容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.Authentication.JwtBearer Version5.3.4 /PackageReference IncludeVolo.Abp.AspNetCore.Serilog Version5.3.4 /PackageReference IncludeVolo.Abp.EntityFrameworkCore.MySQL Version5.3.4 //ItemGroupItemGroupPackageReference IncludeMicrosoft.Extensions.FileProviders.Embedded Version6.0.5 //ItemGroupItemGroupPackageReference IncludeMicrosoft.EntityFrameworkCore.Tools Version6.0.5IncludeAssetsruntime; build; native; contentfiles; analyzers/IncludeAssetsPrivateAssetscompile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native/PrivateAssets/PackageReference/ItemGroupItemGroupCompile RemoveLogs\** /Content RemoveLogs\** /EmbeddedResource RemoveLogs\** /None RemoveLogs\** //ItemGroupItemGroupProjectReference Include..\..\..\common\Demo.Abp.Extension\Demo.Abp.Extension.csproj /ProjectReference Include..\Demo.NotificationManager.Contracts\Demo.NotificationManager.Contracts.csproj //ItemGroup /Project删除主服务Data文件夹下NotificationManagerDbContext类中所有报错的行保留如下内容using Demo.NotificationManager.Entities.Notifications; using Microsoft.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;namespace Demo.NotificationManager.Data;public class NotificationManagerDbContext : AbpDbContextNotificationManagerDbContext { public NotificationManagerDbContext(DbContextOptionsNotificationManagerDbContext options): base(options){}protected override void OnModelCreating(ModelBuilder builder){base.OnModelCreating(builder);} }修改Data文件夹下NotificationManagerDbMigrationService类改为以下代码这里因为我们没使用多租户和初始化数据所以我移除了相关内容using System.Diagnostics; using System.Runtime.InteropServices; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy;namespace Demo.NotificationManager.Data;public class NotificationManagerDbMigrationService : ITransientDependency {public ILoggerNotificationManagerDbMigrationService Logger { get; set; }private readonly IDataSeeder _dataSeeder;private readonly NotificationManagerEFCoreDbSchemaMigrator _dbSchemaMigrator;private readonly ICurrentTenant _currentTenant;public NotificationManagerDbMigrationService(IDataSeeder dataSeeder,NotificationManagerEFCoreDbSchemaMigrator dbSchemaMigrator,ICurrentTenant currentTenant){_dataSeeder dataSeeder;_dbSchemaMigrator dbSchemaMigrator;_currentTenant currentTenant;Logger NullLoggerNotificationManagerDbMigrationService.Instance;}public async Task MigrateAsync(){var initialMigrationAdded AddInitialMigrationIfNotExist();if (initialMigrationAdded){return;}Logger.LogInformation(Started database migrations...);await MigrateDatabaseSchemaAsync();Logger.LogInformation(Successfully completed all database migrations.);Logger.LogInformation(You can safely end this process...);}private async Task MigrateDatabaseSchemaAsync(){await _dbSchemaMigrator.MigrateAsync();}private bool AddInitialMigrationIfNotExist(){try{if (!DbMigrationsProjectExists()){return false;}}catch (Exception){return false;}try{if (!MigrationsFolderExists()){AddInitialMigration();return true;}else{return false;}}catch (Exception e){Logger.LogWarning(Couldnt determinate if any migrations exist : e.Message);return false;}}private bool DbMigrationsProjectExists(){return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath());}private bool MigrationsFolderExists(){var dbMigrationsProjectFolder GetEntityFrameworkCoreProjectFolderPath();return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, Migrations));}private void AddInitialMigration(){Logger.LogInformation(Creating initial migration...);string argumentPrefix;string fileName;if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)){argumentPrefix -c;fileName /bin/bash;}else{argumentPrefix /C;fileName cmd.exe;}var procStartInfo new ProcessStartInfo(fileName,${argumentPrefix} \abp create-migration-and-run-migrator \{GetEntityFrameworkCoreProjectFolderPath()}\ --nolayers\);try{Process.Start(procStartInfo);}catch (Exception){throw new Exception(Couldnt run ABP CLI...);}}private string GetEntityFrameworkCoreProjectFolderPath(){var slnDirectoryPath GetSolutionDirectoryPath();if (slnDirectoryPath null){throw new Exception(Solution folder not found!);}return Path.Combine(slnDirectoryPath, Demo.NotificationManager);}private string GetSolutionDirectoryPath(){var currentDirectory new DirectoryInfo(Directory.GetCurrentDirectory());while (Directory.GetParent(currentDirectory.FullName) ! null){currentDirectory Directory.GetParent(currentDirectory.FullName);if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f f.EndsWith(.sln)) ! null){return currentDirectory.FullName;}}return null;} }将主服务模块类修改为以下内容using Demo.NotificationManager.Contracts; using Microsoft.OpenApi.Models; using Demo.NotificationManager.Data; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.Autofac; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.MySQL; using Volo.Abp.Modularity; using Volo.Abp.Swashbuckle;namespace Demo.NotificationManager;[DependsOn(// ABP Framework packagestypeof(AbpAspNetCoreMvcModule),typeof(AbpAutofacModule),typeof(AbpEntityFrameworkCoreMySQLModule),typeof(AbpSwashbuckleModule),typeof(AbpAspNetCoreSerilogModule),typeof(NotificationManagerContractsModule) )] public class NotificationManagerModule : AbpModule {#region 私有方法#region 配置动态webapiprivate void ConfigureAutoApiControllers(){ConfigureAbpAspNetCoreMvcOptions(options {options.ConventionalControllers.Create(typeof(NotificationManagerModule).Assembly);});}#endregion#region 配置swaggerprivate void ConfigureSwagger(IServiceCollection services){services.AddAbpSwaggerGen(options {options.SwaggerDoc(v1, new OpenApiInfo { Title NotificationManager API, Version v1 });options.DocInclusionPredicate((_, _) true);options.CustomSchemaIds(type type.FullName);});}#endregion#region 设置EFprivate void ConfigureEfCore(ServiceConfigurationContext context){context.Services.AddAbpDbContextNotificationManagerDbContext(options {/* You can remove includeAllEntities: true to create* default repositories only for aggregate roots* Documentation: https://docs.abp.io/en/abp/latest/Entity-Framework-Core#add-default-repositories*/options.AddDefaultRepositories(includeAllEntities: true);});ConfigureAbpDbContextOptions(options {options.Configure(configurationContext {configurationContext.UseMySQL();});});}#endregion#endregionpublic override void ConfigureServices(ServiceConfigurationContext context){ConfigureSwagger(context.Services);ConfigureAutoApiControllers();ConfigureEfCore(context);}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, NotificationManager API);});app.UseAbpSerilogEnrichers();app.UseConfiguredEndpoints();} } 在主服务中的appsettings.json中删除额外配置项保留如下内容{ConnectionStrings: {Default: Serverlocalhost;Port3306;DatabaseNotificationManager;Uidroot;Pwd123456;},urls: http://*:5003 }删除契约层中的Class1.cs,并添加模块类NotificationManagerContractsModule如下using Volo.Abp.Application; using Volo.Abp.Modularity;namespace Demo.NotificationManager.Contracts;[DependsOn(typeof(AbpDddApplicationContractsModule) )] public class NotificationManagerContractsModule : AbpModule {}在契约层添加NotificationManagerRemoteServiceConsts类如下namespace Demo.NotificationManager.Contracts;public class NotificationManagerRemoteServiceConsts {public const string RemoteServiceName NitificationManager;public const string ModuleName nitificationManager; }删除动态客户端代理层的Class1.cs文件添加模块类NotificationManagerClientModule如下using Demo.Abp.Extension; using Demo.NotificationManager.Contracts; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Http.Client; using Volo.Abp.Modularity; using Volo.Abp.Timing; using Volo.Abp.VirtualFileSystem;namespace Demo.NotificationManager.Client;[DependsOn(typeof(NotificationManagerContractsModule), typeof(AbpHttpClientModule))]public class NotificationManagerClientModule : AbpModule {public override void ConfigureServices(ServiceConfigurationContext context){context.Services.AddTransientAddHeaderHandler();context.Services.AddHttpClient(NotificationManagerRemoteServiceConsts.RemoteServiceName).AddHttpMessageHandlerAddHeaderHandler();context.Services.AddHttpClientProxies(typeof(NotificationManagerContractsModule).Assembly,NotificationManagerRemoteServiceConsts.RemoteServiceName);ConfigureAbpVirtualFileSystemOptions(options {options.FileSets.AddEmbeddedNotificationManagerClientModule();});ConfigureAbpClockOptions(options { options.Kind DateTimeKind.Local; });} }完成以上修改后运行项目并用浏览器访问http://localhost:5003可出现Swagger页面则基础服务配置成功。未完待续关注我获得更多精彩
http://www.zqtcl.cn/news/172241/

相关文章:

  • 徐州有办网站的地方吗企业做网站多少钱
  • 地铁公司招聘信息网站通江县网站建设
  • 家具网站 模板上海虹口建设局官方网站
  • 网站建站建设哪家好wordpress全站静态
  • 旅游网站建设策划seo顾问多少钱
  • 个人网站注册平台要多少钱彩票网站开发 违法
  • 贵州城乡住房和建设厅网站易企秀网站开发语言
  • 返利网站做鹊桥推广免费的舆情网站入口在哪
  • 网站商城怎么做wordpress图片采集插件
  • 做美团网站代码swoole+wordpress
  • 百度免费资源网站搭建发卡网站要多少钱
  • ip网站怎么做酷家乐手机版
  • cnzz统计代码如何添加到网站上去照片网站源码
  • 我的世界电影怎么做的视频网站网页布局实训心得体会
  • 网站建设公司内部情况凡客诚品陈年
  • 浙江建设职业技术学院迎新网站商务网站建设体会
  • 做网站的目的与意义做家教去什么网站
  • 相城网站建设为什么网站建设价格不一
  • 网站icp备案手续我做的网站平台百度搜不到
  • 本溪网站设计公司ps转页面wordpress插件
  • 怎么做短链接网站搜索引擎优化的各种方法
  • 自己做网站怎么挣钱微网站建站系统源码
  • 湖北省网站备案最快几天网站建设存在的具体问题
  • 网站建设算固定资产吗做网站都需要什么软件
  • ui设计培训是什么seo外链网站源码
  • 网站开发浙里建系统平台
  • 建设电影网站的关键国内新闻最新消息2022
  • wordpress 卢晓松玉林做网站优化推广
  • 做户外运动的网站seo内部优化方案
  • 哪个行业必须做网站软件工程最好的出路