体检系统架构设计

yjfy
SummmerLost 3 years ago
commit 32cacd58d7
  1. 3
      .gitignore
  2. BIN
      .vs/PEIS/DesignTimeBuild/.dtbcache.v2
  3. BIN
      .vs/PEIS/FileContentIndex/18f8b207-681a-46c7-b102-0d555eaac6c9.vsidx
  4. BIN
      .vs/PEIS/FileContentIndex/45cfb924-1f5b-4699-9ce3-01639a41461c.vsidx
  5. BIN
      .vs/PEIS/FileContentIndex/546d0b0f-54c2-4958-87c9-6686f02224b4.vsidx
  6. BIN
      .vs/PEIS/FileContentIndex/ff0fe4f2-e687-4bef-be6b-2d8ed79a8e63.vsidx
  7. 0
      .vs/PEIS/FileContentIndex/read.lock
  8. BIN
      .vs/PEIS/v17/.suo
  9. 1
      PEIS.Common
  10. 12
      PEIS.EF/IService/ISampleService.cs
  11. 19
      PEIS.EF/Service/SampleService.cs
  12. 27
      PEIS.Interface/Program.cs
  13. 30
      PEIS.Interface/Properties/launchSettings.json
  14. 167
      PEIS.Interface/Startup.cs
  15. 9
      PEIS.Interface/appsettings.Development.json
  16. 18
      PEIS.Interface/appsettings.json
  17. 18
      PEIS.Repositories/IRepository.cs
  18. 10
      PEIS.Repositories/Models/Sample.cs
  19. 53
      PEIS.Repositories/Repository.cs
  20. 43
      PEIS.sln

3
.gitignore vendored

@ -0,0 +1,3 @@
*.csproj
bin/
obj/

Binary file not shown.

@ -0,0 +1 @@
Subproject commit d276266da5d8f4b9bb4b5dc9e88ddd2e21c62f94

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PEIS.Service.IService
{
interface ISampleService
{
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
using PEIS.Repositories;
using PEIS.Repositories.Models;
using PEIS.Service.IService;
namespace PEIS.Service.Service
{
public class SampleService:Repository<Sample>,ISampleService
{
public SampleService(DbContext context) : base(context)
{
}
}
}

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PEIS.Interface
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).UseNLog().Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57770",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"PEIS.Interface": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,167 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using PEIS.Common.Helper.Encryption;
using PEIS.Common.Middleware;
namespace PEIS.Interface
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
private readonly bool _swagger = AppSettingJsonHelper.GetSection("Swagger", "Using") == "true";
public IConfiguration Configuration { get; }
/// <summary>
/// 这个方法被运行时调用。 使用此方法向容器添加服务
/// </summary>
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddControllersWithViews()
.AddNewtonsoftJson(options =>
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
);
// swagger 配置
if (_swagger)
{
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "OutCollect", Version = "v1" });
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath, true);
//添加Authorization
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme.",
Name = "Authorization",
In = ParameterLocation.Header,
Scheme = "bearer",
Type = SecuritySchemeType.Http,
BearerFormat = "JWT"
});
//把所有方法配置为增加bearer头部信息;
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "bearerAuth"
}
},
new string[] {}
}
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }
},
new List<string>()
}
});
});
}
// jwt 配置
services.AddAuthentication(options =>
{
// 设置默认使用jwt验证方式
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{
var confSection = Configuration.GetSection("Authentication");
options.TokenValidationParameters = new TokenValidationParameters()
{
// 验证接收者
ValidateAudience = true,
// 验证发布者 //是否验证发行人,就是验证载荷中的Iss是否对应ValidIssuer参数
ValidateIssuer = true,
// 验证过期时间//是否验证过期时间,过期了就拒绝访问
ValidateLifetime = true,
// 验证秘钥 //是否验证签名,不验证的画可以篡改数据,不安全
ValidateIssuerSigningKey = true,
// 读配置Issuer//发行人
ValidIssuer = confSection["IsSure"],
// 读配置Audience//订阅人
ValidAudience = confSection["Audience"],
// 设置生成token的秘钥 //解密的密钥
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(confSection["SecurityKey"]))
};
});
}
/// <summary>
/// 此方法由运行时调用。 使用此方法配置 HTTP 请求管道
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/error");
}
if (_swagger)
{
app.UseSwagger();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger(c =>
{
c.SerializeAsV2 = true;
});
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "debug NetFL v1");
});
}
app.UseHttpsRedirection();
app.UseRouting();
// custom jwt auth middleware
app.UseMiddleware<JwtMiddleware>();
// jwt
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

@ -0,0 +1,18 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Authentication": {
"IsSure": "OutCollect",
"Audience": "OutCollectColoud",
"SecurityKey": "4C6A8A8B-1B9F-12E7-60C4-123BC0BB5D25"
},
"Swagger": {
"Using": "true"
}
}

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace PEIS.Repositories
{
public interface IRepository<TEntity> where TEntity :class
{
TEntity Get(int id);
IEnumerable<TEntity> GetAll();
IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> predicate);
void Add(TEntity entity);
void AddRange(IEnumerable<TEntity> entities);
void Remove(TEntity entity);
void RemoveRange(IEnumerable<TEntity> entities);
}
}

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace PEIS.Repositories.Models
{
public class Sample
{
}
}

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore;
namespace PEIS.Repositories
{
public class Repository<TEntity> :IRepository<TEntity> where TEntity:class
{
public readonly DbContext Context;
public Repository(DbContext context)
{
Context = context;
}
public TEntity Get(int id)
{
return Context.Set<TEntity>().Find(id);
}
public IEnumerable<TEntity> GetAll()
{
return Context.Set<TEntity>().ToList();
}
public IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> predicate)
{
return Context.Set<TEntity>().Where(predicate);
}
public void Add(TEntity entity)
{
Context.Set<TEntity>().Add(entity);
}
public void AddRange(IEnumerable<TEntity> entities)
{
Context.Set<TEntity>().AddRange(entities);
}
public void Remove(TEntity entity)
{
Context.Set<TEntity>().Remove(entity);
}
public void RemoveRange(IEnumerable<TEntity> entities)
{
Context.Set<TEntity>().RemoveRange(entities);
}
}
}

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PEIS.Cloud", "PEIS.Interface\PEIS.Cloud.csproj", "{4154E9CB-D701-49D0-92B5-EC2F8E055CD2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PEIS.Common", "PEIS.Common\PEIS.Common.csproj", "{13B248F1-75F7-4358-9579-CF51BCA6E75B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PEIS.Repositories", "PEIS.Repositories\PEIS.Repositories.csproj", "{84CA4853-1143-4DE3-8477-14BD7811EF90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PEIS.Service", "PEIS.EF\PEIS.Service.csproj", "{70A000EA-EDB6-4719-8195-06E06384B336}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4154E9CB-D701-49D0-92B5-EC2F8E055CD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4154E9CB-D701-49D0-92B5-EC2F8E055CD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4154E9CB-D701-49D0-92B5-EC2F8E055CD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4154E9CB-D701-49D0-92B5-EC2F8E055CD2}.Release|Any CPU.Build.0 = Release|Any CPU
{13B248F1-75F7-4358-9579-CF51BCA6E75B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13B248F1-75F7-4358-9579-CF51BCA6E75B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13B248F1-75F7-4358-9579-CF51BCA6E75B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13B248F1-75F7-4358-9579-CF51BCA6E75B}.Release|Any CPU.Build.0 = Release|Any CPU
{84CA4853-1143-4DE3-8477-14BD7811EF90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84CA4853-1143-4DE3-8477-14BD7811EF90}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84CA4853-1143-4DE3-8477-14BD7811EF90}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84CA4853-1143-4DE3-8477-14BD7811EF90}.Release|Any CPU.Build.0 = Release|Any CPU
{70A000EA-EDB6-4719-8195-06E06384B336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70A000EA-EDB6-4719-8195-06E06384B336}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70A000EA-EDB6-4719-8195-06E06384B336}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70A000EA-EDB6-4719-8195-06E06384B336}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3615424A-8F6D-4912-B462-23042E651E6E}
EndGlobalSection
EndGlobal
Loading…
Cancel
Save