Explorar o código

修改ServiceOptions包结构

黄贺彬 %!s(int64=6) %!d(string=hai) anos
pai
achega
a9d316eff3
Modificáronse 25 ficheiros con 483 adicións e 39 borrados
  1. 1 1
      HaBookCms.Admin/Controllers/Sys/SysUsersController.cs
  2. 110 0
      HaBookCms.AzureBlobStorageTest/Controllers/ValuesController.cs
  3. 14 0
      HaBookCms.AzureBlobStorageTest/HaBookCms.AzureBlobStorageTest.csproj
  4. 16 0
      HaBookCms.AzureBlobStorageTest/Models/Picture.cs
  5. 24 0
      HaBookCms.AzureBlobStorageTest/Program.cs
  6. 30 0
      HaBookCms.AzureBlobStorageTest/Properties/launchSettings.json
  7. 53 0
      HaBookCms.AzureBlobStorageTest/Startup.cs
  8. 9 0
      HaBookCms.AzureBlobStorageTest/appsettings.Development.json
  9. 9 0
      HaBookCms.AzureBlobStorageTest/appsettings.json
  10. 56 0
      HaBookCms.AzureStorage/AzureBlob/Implement/AzureBlobDBRepository.cs
  11. 10 0
      HaBookCms.AzureStorage/AzureBlob/Interface/IAzureBlobDBRepository.cs
  12. 9 13
      HaBookCms.AzureStorage/AzureTable/Implements/AzureTableDBRepository.cs
  13. 42 0
      HaBookCms.AzureStorage/AzureTable/TableClientSingleton.cs
  14. 3 2
      HaBookCms.AzureStorage/HaBookCms.AzureStorage.csproj
  15. 23 0
      HaBookCms.Contest/Controllers/CmsUsersController.cs
  16. 1 0
      HaBookCms.Contest/HaBookCms.Contest.csproj
  17. 10 1
      HaBookCms.Contest/Startup.cs
  18. 3 2
      HaBookCms.Core/Models/System/SysUser.cs
  19. 3 3
      HaBookCms.AzureStorage/Extensions/AzureStorageBuilder.cs
  20. 5 4
      HaBookCms.AzureStorage/Extensions/AzureStorageBuilderExtensions.cs
  21. 6 10
      HaBookCms.AzureStorage/Extensions/AzureStorageServiceCollectionExtensions.cs
  22. 15 0
      HaBookCms.ServiceExtension/HaBookCms.ServiceExtension.csproj
  23. 7 0
      HaBookCms.ServiceOptions/HaBookCms.ServiceOptions.csproj
  24. 1 1
      HaBookCms.AzureStorage/Extensions/DatabaseOptions.cs
  25. 23 2
      HaBookCms.sln

+ 1 - 1
HaBookCms.Admin/Controllers/Sys/SysUsersController.cs

@@ -54,7 +54,7 @@ namespace HaBookCms.Admin.Controllers.Sys
                 var identity = new ClaimsIdentity(JwtBearerDefaults.AuthenticationScheme);
                 identity.AddClaims(claims);
 
-                var token = JwtToken.BuildJwtToken(claims.ToArray(), _requirement);
+                var token = JwtToken.BuildJwtToken(claims.ToArray());
                 return new JsonResult(token);
             }
             else

+ 110 - 0
HaBookCms.AzureBlobStorageTest/Controllers/ValuesController.cs

@@ -0,0 +1,110 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+using HaBookCms.AzureBlobStorageTest.Models;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
+
+namespace HaBookCms.AzureBlobStorageTest.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class ValuesController : ControllerBase
+    {
+        // GET api/values
+        [HttpGet]
+        public ActionResult<IEnumerable<string>> Get()
+        {
+            return new string[] { "value1", "value2" };
+        }
+
+        // GET api/values/5
+        [HttpGet("{id}")]
+        public ActionResult<string> Get(int id)
+        {
+            return "value";
+        }
+
+        // POST api/values
+        [HttpPost]
+        public void Post([FromBody] string value)
+        {
+        }
+
+        // PUT api/values/5
+        [HttpPut("{id}")]
+        public void Put(int id, [FromBody] string value)
+        {
+        }
+
+        // DELETE api/values/5
+        [HttpDelete("{id}")]
+        public void Delete(int id)
+        {
+        }
+        [HttpPost("urls")]
+        public async Task<IActionResult> Index()
+        {
+            var urls = new List<string>();
+            var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn");
+            var blobClient = storageAccount.CreateCloudBlobClient();
+            var container = blobClient.GetContainerReference("staticcontent");
+            var data = await container.ListBlobsSegmentedAsync
+                ("", true, BlobListingDetails.All, 200, null, null, null);
+            foreach (IListBlobItem item in data.Results)
+            {
+                urls.Add(item.StorageUri.PrimaryUri.ToString());
+            }
+            return Ok(urls);
+        }
+        [HttpPost("Upload")]
+        //[Produces("application/json")]
+        //[Consumes("application/json", "multipart/form-data")]//此处为新增
+        public async Task<IActionResult> Upload(IFormFile[] file  )
+        {
+            var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn");
+            var blobClient = storageAccount.CreateCloudBlobClient();
+            var container = blobClient.GetContainerReference("staticcontent");
+            //var file = picture.File;
+            foreach (IFormFile f in file) {
+                var parsedContentDisposition =
+                ContentDispositionHeaderValue.Parse(f.ContentDisposition);
+                var filename = Path.Combine(parsedContentDisposition.FileName.Trim('"'));
+                var blockBlob = container.GetBlockBlobReference(filename+Guid.NewGuid());
+                await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
+            }
+            return Ok();
+        }
+        [HttpGet("Download")]
+        //[Produces("application/json")]
+        //[Consumes("application/json", "multipart/form-data")]//此处为新增
+        public async Task<IActionResult> Download()
+        {
+            var storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn");
+            var blobClient = storageAccount.CreateCloudBlobClient();
+            var container = blobClient.GetContainerReference("staticcontent");
+            string url = "https://teammodelstorage.blob.core.chinacloudapi.cn/staticcontent/234fa2a1-7309-4241-886f-c58ae195f9da.pdf";
+            CloudBlockBlob blockBlob = container.GetBlockBlobReference("234fa2a1-7309-4241-886f-c58ae195f9da.pdf");
+            using (var fileStream = System.IO.File.OpenWrite(@"F:\234fa2a1-7309-4241-886f-c58ae195f9da.pdf"))
+            {
+                await blockBlob.DownloadToStreamAsync(fileStream);
+            }
+            //var file = picture.File;
+            //foreach (IFormFile f in file)
+            //{
+            //    var parsedContentDisposition =
+            //    ContentDispositionHeaderValue.Parse(f.ContentDisposition);
+            //    var filename = Path.Combine(parsedContentDisposition.FileName.Trim('"'));
+            //    var blockBlob = container.GetBlockBlobReference(filename + Guid.NewGuid());
+            //    await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
+            //}
+            return Ok();
+        }
+        
+    }
+}

+ 14 - 0
HaBookCms.AzureBlobStorageTest/HaBookCms.AzureBlobStorageTest.csproj

@@ -0,0 +1,14 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.App" />
+    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
+    <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
+  </ItemGroup>
+
+</Project>

+ 16 - 0
HaBookCms.AzureBlobStorageTest/Models/Picture.cs

@@ -0,0 +1,16 @@
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace HaBookCms.AzureBlobStorageTest.Models
+{
+    public class Picture
+    {
+        [Required(ErrorMessage = "File is required")]
+        [FileExtensions(ErrorMessage = "Please select a valid format")]
+        public IFormFile File { get; set; }
+    }
+}

+ 24 - 0
HaBookCms.AzureBlobStorageTest/Program.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+
+namespace HaBookCms.AzureBlobStorageTest
+{
+    public class Program
+    {
+        public static void Main(string[] args)
+        {
+            CreateWebHostBuilder(args).Build().Run();
+        }
+
+        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
+            WebHost.CreateDefaultBuilder(args)
+                .UseStartup<Startup>();
+    }
+}

+ 30 - 0
HaBookCms.AzureBlobStorageTest/Properties/launchSettings.json

@@ -0,0 +1,30 @@
+{
+  "$schema": "http://json.schemastore.org/launchsettings.json",
+  "iisSettings": {
+    "windowsAuthentication": false, 
+    "anonymousAuthentication": true, 
+    "iisExpress": {
+      "applicationUrl": "http://localhost:49612",
+      "sslPort": 44370
+    }
+  },
+  "profiles": {
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": false,
+      "launchUrl": "api/values",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "HaBookCms.AzureBlobStorageTest": {
+      "commandName": "Project",
+      "launchBrowser": true,
+      "launchUrl": "api/values",
+      "applicationUrl": "https://localhost:5001;http://localhost:5000",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 53 - 0
HaBookCms.AzureBlobStorageTest/Startup.cs

@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace HaBookCms.AzureBlobStorageTest
+{
+    public class Startup
+    {
+        public Startup(IConfiguration configuration, IHostingEnvironment env)
+        {
+            var builder = new ConfigurationBuilder()
+                   .SetBasePath(env.ContentRootPath)
+                   .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
+                   .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
+                   .AddEnvironmentVariables();
+            Configuration = builder.Build();
+        }
+
+        public IConfiguration Configuration { get; }
+
+        // This method gets called by the runtime. Use this method to add services to the container.
+        public void ConfigureServices(IServiceCollection services)
+        {
+            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+        }
+
+        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
+        {
+            if (env.IsDevelopment())
+            {
+                app.UseDeveloperExceptionPage();
+            }
+            else
+            {
+                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
+                app.UseHsts();
+            }
+            app.UseStaticFiles();
+            app.UseHttpsRedirection();
+            app.UseMvc();
+        }
+    }
+}

+ 9 - 0
HaBookCms.AzureBlobStorageTest/appsettings.Development.json

@@ -0,0 +1,9 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Debug",
+      "System": "Information",
+      "Microsoft": "Information"
+    }
+  }
+}

+ 9 - 0
HaBookCms.AzureBlobStorageTest/appsettings.json

@@ -0,0 +1,9 @@
+{
+  "StorageKey": "",
+  "Logging": {
+    "LogLevel": {
+      "Default": "Warning"
+    }
+  },
+  "AllowedHosts": "*"
+}

+ 56 - 0
HaBookCms.AzureStorage/AzureBlob/Implement/AzureBlobDBRepository.cs

@@ -0,0 +1,56 @@
+using HaBookCms.AzureStorage.AzureBlob.Interface;
+using HaBookCms.ServiceOptions.Options;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Options;
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Blob;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HaBookCms.AzureStorage.AzureBlob.Implement
+{
+    public  class AzureBlobDBRepository : IAzureBlobDBRepository
+    {
+        public string _connectionString { get; set; }
+        public CloudBlobContainer blobContainer;
+        public AzureBlobDBRepository(IOptions<DatabaseOptions> optionsAccessor)
+        {
+            _connectionString = optionsAccessor.Value.ConnectionString;
+        }
+
+        public AzureBlobDBRepository()
+        {
+            // _connectionString = BaseConfigModel.Configuration["AppSettings:Azure:TableStorageConnection"];
+
+        }
+        private async Task InitializeBlob(string container)
+        {
+            if (blobContainer == null)
+            {
+               // Type t = typeof(T);
+                string StorageConnectionString = _connectionString;
+                var storageAccount = CloudStorageAccount.Parse(StorageConnectionString);
+                CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
+                blobContainer = blobClient.GetContainerReference(container);
+                await blobContainer.CreateIfNotExistsAsync();
+            }
+        }
+        public async Task<IEnumerable<string>> UploadFiles(IFormFile[] file,string container) {
+            await InitializeBlob(container);
+            foreach (IFormFile f in file)
+            {
+                var parsedContentDisposition =
+                ContentDispositionHeaderValue.Parse(f.ContentDisposition);
+                var filename = Path.Combine(parsedContentDisposition.FileName.Trim('"'));
+                var blockBlob = blobContainer.GetBlockBlobReference(f.FileName + Guid.NewGuid());
+                await blockBlob.UploadFromStreamAsync(f.OpenReadStream());
+            }
+            return null;
+        }
+
+    }
+}

+ 10 - 0
HaBookCms.AzureStorage/AzureBlob/Interface/IAzureBlobDBRepository.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HaBookCms.AzureStorage.AzureBlob.Interface
+{
+    public interface  IAzureBlobDBRepository
+    {
+    }
+}

+ 9 - 13
HaBookCms.AzureStorage/AzureTable/Implements/AzureTableDBRepository.cs

@@ -1,24 +1,23 @@
 using HaBookCms.AzureStorage.AzureTable.Interfaces;
-using HaBookCms.AzureStorage.Extensions;
-using Microsoft.Extensions.Options;
-using Microsoft.WindowsAzure.Storage;
+using HaBookCms.ServiceOptions.Options;
 using Microsoft.WindowsAzure.Storage.Table;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
 
 namespace HaBookCms.AzureStorage.AzureTable.Implements
 {
    public class AzureTableDBRepository : IAzureTableDBRepository
     {
-        public string _connectionString { get; set; }
-        public CloudTable table;
-        public AzureTableDBRepository(IOptions<DatabaseOptions> optionsAccessor)
+        //  public string _connectionString { get; set; }
+        private CloudTableClient tableClient { get; set; }
+        private CloudTable table { get; set; }
+        public AzureTableDBRepository(DatabaseOptions options)
         {
-            _connectionString = optionsAccessor.Value.ConnectionString;
+            tableClient = TableClientSingleton.getInstance(options.ConnectionString).GetTableClient();
+           // _connectionString = options.ConnectionString;
         }
 
         public AzureTableDBRepository()
@@ -28,12 +27,9 @@ namespace HaBookCms.AzureStorage.AzureTable.Implements
         }
         private async Task InitializeTable<T>()
         {
-            if (table == null)
+            Type t = typeof(T);
+            if (table == null || !table.Name.Equals(t.Name))
             {
-                Type t = typeof(T);
-                string StorageConnectionString = _connectionString;
-                var storageAccount = CloudStorageAccount.Parse(StorageConnectionString);
-                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
                 table = tableClient.GetTableReference(t.Name);
                 await table.CreateIfNotExistsAsync();
             }

+ 42 - 0
HaBookCms.AzureStorage/AzureTable/TableClientSingleton.cs

@@ -0,0 +1,42 @@
+using Microsoft.WindowsAzure.Storage;
+using Microsoft.WindowsAzure.Storage.Table;
+
+namespace HaBookCms.AzureStorage.AzureTable
+{
+    public sealed class TableClientSingleton
+    {
+        private static string _connectionString;
+        private CloudTableClient TableClient;
+
+        private TableClientSingleton() { }
+
+      
+
+        public CloudTableClient GetTableClient()
+        {
+            if (TableClient != null)
+            {
+                return TableClient;
+            }
+            else
+            {
+                getInstance(_connectionString);
+                return TableClient;
+            }
+        }
+
+        public static TableClientSingleton getInstance(string  connectionString)
+        {
+            _connectionString = connectionString;
+            return SingletonInstance.instance;
+        }
+
+        private static class SingletonInstance
+        {
+            public static TableClientSingleton instance = new TableClientSingleton()
+            {
+                TableClient = CloudStorageAccount.Parse(_connectionString).CreateCloudTableClient()
+            };
+        }
+    }
+}

+ 3 - 2
HaBookCms.AzureStorage/HaBookCms.AzureStorage.csproj

@@ -11,11 +11,12 @@
 
   <ItemGroup>
     <ProjectReference Include="..\HaBookCms.Jwt\HaBookCms.Jwt.csproj" />
+    <ProjectReference Include="..\HaBookCms.ServiceOptions\HaBookCms.ServiceOptions.csproj" />
   </ItemGroup>
 
   <ItemGroup>
-    <Folder Include="AzureBlob\" />
-    <Folder Include="AzureQueue\" />
+    <Folder Include="AzureQueue\Interface\" />
+    <Folder Include="AzureQueue\Implement\" />
   </ItemGroup>
 
 </Project>

+ 23 - 0
HaBookCms.Contest/Controllers/CmsUsersController.cs

@@ -6,6 +6,7 @@ using HaBookCms.Common.JsonHelper;
 using HaBookCms.Common.ValidateHelper;
 using HaBookCms.Core.Dtos;
 using HaBookCms.Core.Models.Common;
+using HaBookCms.Core.Models.System;
 using HaBookCms.Jwt.Model;
 using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Authorization;
@@ -119,5 +120,27 @@ namespace HaBookCms.Contest.Controllers
             }
             return null ;
         }
+        [HttpGet]
+        [Route("test")]
+        [EnableCors("any")]
+        [AllowAnonymous]
+        public async Task<object> Test()
+        {
+            LoginInfo loginInfo = new LoginInfo();
+            loginInfo.RowKey = Guid.NewGuid().ToString();
+            loginInfo.PartitionKey = Guid.NewGuid().ToString();
+            loginInfo.guid= Guid.NewGuid().ToString();
+            await _repository.Save<LoginInfo>(loginInfo);
+            SysUser sysUser = new SysUser();
+            sysUser.RowKey = Guid.NewGuid().ToString();
+            sysUser.PartitionKey = Guid.NewGuid().ToString();
+            sysUser.Guid = Guid.NewGuid().ToString();
+            await _repository.Save<SysUser>(sysUser);
+            return loginInfo;
+        }
     }
+
+
+   
+
 }

+ 1 - 0
HaBookCms.Contest/HaBookCms.Contest.csproj

@@ -19,6 +19,7 @@
     <ProjectReference Include="..\HaBookCms.Core\HaBookCms.Core.csproj" />
     <ProjectReference Include="..\HaBookCms.Jwt\HaBookCms.Jwt.csproj" />
     <ProjectReference Include="..\HaBookCms.RedisStorage\HaBookCms.RedisStorage.csproj" />
+    <ProjectReference Include="..\HaBookCms.ServiceExtension\HaBookCms.ServiceExtension.csproj" />
   </ItemGroup>
 
 </Project>

+ 10 - 1
HaBookCms.Contest/Startup.cs

@@ -5,15 +5,16 @@ using System.Security.Claims;
 using System.Text;
 using System.Text.Encodings.Web;
 using System.Text.Unicode;
-using HaBookCms.AzureStorage.Extensions;
 using HaBookCms.Common.LogHelper;
 using HaBookCms.ContextConfig.Exceptions;
 using HaBookCms.Jwt.Filter;
 using HaBookCms.Jwt.Model;
 using HaBookCms.RedisStorage.Cache;
+using HaBookCms.ServiceExtension.Extension;
 using log4net;
 using log4net.Config;
 using log4net.Repository;
+
 using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
@@ -62,6 +63,14 @@ namespace HaBookCms.Contest
 
 
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
+            //services.AddMvc().AddMvcOptions(
+            //    option =>
+            //    {
+            //        option.OutputFormatters.Clear();
+            //        option.OutputFormatters.Add(new MessagePackOutputFormatter(ContractlessStandardResolver.Instance));
+            //        option.InputFormatters.Clear();
+            //        option.InputFormatters.Add(new MessagePackInputFormatter(ContractlessStandardResolver.Instance));
+            //    });
             //解决视图输出内容中文编码问题
             services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
             services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

+ 3 - 2
HaBookCms.Core/Models/System/SysUser.cs

@@ -1,4 +1,5 @@
-using System;
+using Microsoft.WindowsAzure.Storage.Table;
+using System;
 using System.Collections.Generic;
 using System.Text;
 
@@ -7,7 +8,7 @@ namespace HaBookCms.Core.Models.System
     /// <summary>
     /// 系统用户
     /// </summary>
-    public class SysUser
+    public class SysUser :TableEntity
     {
         public string Guid { get; set; }
         public string UserName { get; set; }

+ 3 - 3
HaBookCms.AzureStorage/Extensions/AzureStorageBuilder.cs

@@ -3,16 +3,16 @@ using System;
 using System.Collections.Generic;
 using System.Text;
 
-namespace HaBookCms.AzureStorage.Extensions
+namespace HaBookCms.ServiceExtension.Extension
 {
-    public class AzureStorageBuilder
+    public class ServiceBuilder
     {
         /// <summary>
         /// Initializes a new instance of the <see cref="IdentityServerBuilder"/> class.
         /// </summary>
         /// <param name="services">The services.</param>
         /// <exception cref="System.ArgumentNullException">services</exception>
-        public AzureStorageBuilder(IServiceCollection services)
+        public ServiceBuilder(IServiceCollection services)
         {
             Services = services ?? throw new ArgumentNullException(nameof(services));
         }

+ 5 - 4
HaBookCms.AzureStorage/Extensions/AzureStorageBuilderExtensions.cs

@@ -1,11 +1,12 @@
-using Microsoft.Extensions.DependencyInjection;
+using HaBookCms.ServiceOptions.Options;
+using Microsoft.Extensions.DependencyInjection;
 using System;
 using System.Collections.Generic;
 using System.Text;
 
-namespace HaBookCms.AzureStorage.Extensions
+namespace HaBookCms.ServiceExtension.Extension
 {
-    public static class AzureStorageBuilderExtensions
+    public static class ServiceBuilderExtensions
     {
 
         /// <summary>
@@ -14,7 +15,7 @@ namespace HaBookCms.AzureStorage.Extensions
         /// <param name="builder">The builder.</param>
         /// <param name="users">The users.</param>
         /// <returns></returns>
-        public static AzureStorageBuilder AddConnection(this AzureStorageBuilder builder, string _connectionString)
+        public static ServiceBuilder AddConnection(this ServiceBuilder builder, string _connectionString)
         {
             DatabaseOptions databaseOptions = new DatabaseOptions();
             databaseOptions.ConnectionString = _connectionString;

+ 6 - 10
HaBookCms.AzureStorage/Extensions/AzureStorageServiceCollectionExtensions.cs

@@ -1,13 +1,9 @@
 using HaBookCms.AzureStorage.AzureTable.Implements;
 using HaBookCms.AzureStorage.AzureTable.Interfaces;
 using Microsoft.Extensions.DependencyInjection;
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace HaBookCms.AzureStorage.Extensions
+namespace HaBookCms.ServiceExtension.Extension
 {
-    public static class AzureStorageServiceCollectionExtensions
+    public static class ServiceCollectionExtensions
     {
 
         /// <summary>
@@ -15,9 +11,9 @@ namespace HaBookCms.AzureStorage.Extensions
         /// </summary>
         /// <param name="services">The services.</param>
         /// <returns></returns>
-        private static AzureStorageBuilder AddAzureTableServerBuilder(this IServiceCollection services)
+        private static ServiceBuilder AddServerBuilder(this IServiceCollection services)
         {
-            return new AzureStorageBuilder(services);
+            return new ServiceBuilder(services);
         }
 
         /// <summary>
@@ -25,9 +21,9 @@ namespace HaBookCms.AzureStorage.Extensions
         /// </summary>
         /// <param name="services">The services.</param>
         /// <returns></returns>
-        public static AzureStorageBuilder AddAzureTableStorage(this IServiceCollection services)
+        public static ServiceBuilder AddAzureTableStorage(this IServiceCollection services)
         {
-            var builder = services.AddAzureTableServerBuilder();
+            var builder = services.AddServerBuilder();
             services.AddSingleton<IAzureTableDBRepository, AzureTableDBRepository>();
             return builder;
         }

+ 15 - 0
HaBookCms.ServiceExtension/HaBookCms.ServiceExtension.csproj

@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\HaBookCms.AzureStorage\HaBookCms.AzureStorage.csproj" />
+  </ItemGroup>
+
+</Project>

+ 7 - 0
HaBookCms.ServiceOptions/HaBookCms.ServiceOptions.csproj

@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp2.2</TargetFramework>
+  </PropertyGroup>
+
+</Project>

+ 1 - 1
HaBookCms.AzureStorage/Extensions/DatabaseOptions.cs

@@ -1,4 +1,4 @@
-namespace HaBookCms.AzureStorage.Extensions
+namespace HaBookCms.ServiceOptions.Options
 {
     public class  DatabaseOptions
     {

+ 23 - 2
HaBookCms.sln

@@ -37,9 +37,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaBookCms.Response", "HaBoo
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-应用测试", "05-应用测试", "{4B1BDA90-D27E-4597-9B68-D1D9273F0B5D}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaBookCms.JosnRPCTest", "HaBookCms.JosnRPCTest\HaBookCms.JosnRPCTest.csproj", "{0FB3E14C-41DF-4686-BD7C-7A6E03B1C548}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaBookCms.JosnRPCTest", "HaBookCms.JosnRPCTest\HaBookCms.JosnRPCTest.csproj", "{0FB3E14C-41DF-4686-BD7C-7A6E03B1C548}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaBookCms.IP2Region", "HaBookCms.IP2Region\HaBookCms.IP2Region.csproj", "{F7832670-7572-4EE7-A61B-9732DE01E9FC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaBookCms.IP2Region", "HaBookCms.IP2Region\HaBookCms.IP2Region.csproj", "{F7832670-7572-4EE7-A61B-9732DE01E9FC}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HaBookCms.AzureBlobStorageTest", "HaBookCms.AzureBlobStorageTest\HaBookCms.AzureBlobStorageTest.csproj", "{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaBookCms.ServiceExtension", "HaBookCms.ServiceExtension\HaBookCms.ServiceExtension.csproj", "{BD988F61-D8C4-4BB6-9C36-FA266441A9BC}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaBookCms.ServiceOptions", "HaBookCms.ServiceOptions\HaBookCms.ServiceOptions.csproj", "{31EADFD5-AACF-4BE4-BB65-053B36C91F97}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -103,6 +109,18 @@ Global
 		{F7832670-7572-4EE7-A61B-9732DE01E9FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{F7832670-7572-4EE7-A61B-9732DE01E9FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{F7832670-7572-4EE7-A61B-9732DE01E9FC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1}.Release|Any CPU.Build.0 = Release|Any CPU
+		{BD988F61-D8C4-4BB6-9C36-FA266441A9BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{BD988F61-D8C4-4BB6-9C36-FA266441A9BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{BD988F61-D8C4-4BB6-9C36-FA266441A9BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{BD988F61-D8C4-4BB6-9C36-FA266441A9BC}.Release|Any CPU.Build.0 = Release|Any CPU
+		{31EADFD5-AACF-4BE4-BB65-053B36C91F97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{31EADFD5-AACF-4BE4-BB65-053B36C91F97}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{31EADFD5-AACF-4BE4-BB65-053B36C91F97}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{31EADFD5-AACF-4BE4-BB65-053B36C91F97}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -122,6 +140,9 @@ Global
 		{AEF0F17F-CC2C-44A7-BB92-C77BCF8712D1} = {CB0A287C-1551-4E69-8CCB-3A32F1CB1536}
 		{0FB3E14C-41DF-4686-BD7C-7A6E03B1C548} = {4B1BDA90-D27E-4597-9B68-D1D9273F0B5D}
 		{F7832670-7572-4EE7-A61B-9732DE01E9FC} = {CB0A287C-1551-4E69-8CCB-3A32F1CB1536}
+		{1F3D1D57-BC66-44D5-A2A3-DCD3B0930EA1} = {4B1BDA90-D27E-4597-9B68-D1D9273F0B5D}
+		{BD988F61-D8C4-4BB6-9C36-FA266441A9BC} = {ED40E78C-C863-42B7-8D86-41BF178336BB}
+		{31EADFD5-AACF-4BE4-BB65-053B36C91F97} = {ED40E78C-C863-42B7-8D86-41BF178336BB}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {AE47BE78-B3F5-4723-ACDF-BC403B131012}