Selaa lähdekoodia

课纲数据结构

黄贺彬 6 vuotta sitten
vanhempi
commit
5f62357662

+ 2 - 2
HaBookCms.AzureStorage/AzureBlob/Implement/AzureBlobDBRepository.cs

@@ -1,5 +1,5 @@
 using HaBookCms.AzureStorage.AzureBlob.Container;
-using HaBookCms.AzureStorage.AzureBlob.Interface;
+using HaBookCms.AzureStorage.AzureBlob.Interfaces;
 using HaBookCms.AzureStorage.ServiceExtension;
 using Microsoft.AspNetCore.Http;
 using Microsoft.Extensions.Options;
@@ -12,7 +12,7 @@ using System.Net.Http.Headers;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace HaBookCms.AzureStorage.AzureBlob.Implement
+namespace HaBookCms.AzureStorage.AzureBlob.Implements
 {
     public  class AzureBlobDBRepository : IAzureBlobDBRepository
     {

+ 1 - 1
HaBookCms.AzureStorage/AzureBlob/Interface/IAzureBlobDBRepository.cs

@@ -2,7 +2,7 @@
 using System.Collections.Generic;
 using System.Text;
 
-namespace HaBookCms.AzureStorage.AzureBlob.Interface
+namespace HaBookCms.AzureStorage.AzureBlob.Interfaces
 {
     public interface  IAzureBlobDBRepository
     {

+ 37 - 0
HaBookCms.AzureStorage/AzureBlob/Models/AzureBlobModel.cs

@@ -0,0 +1,37 @@
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HaBookCms.AzureStorage.AzureBlob.Models
+{
+    public  class AzureBlobModel
+    {
+        //
+        // 摘要:
+        //     Gets the raw Content-Type header of the uploaded file.
+        string ContentType { get; }
+        //
+        // 摘要:
+        //     Gets the raw Content-Disposition header of the uploaded file.
+        string ContentDisposition { get; }
+        //
+        // 摘要:
+        //     Gets the header dictionary of the uploaded file.
+        IHeaderDictionary Headers { get; }
+        //
+        // 摘要:
+        //     Gets the file length in bytes.
+        long Length { get; }
+        //
+        // 摘要:
+        //     Gets the form field name from the Content-Disposition header.
+        string Name { get; }
+        //
+        // 摘要:
+        //     Gets the file name from the Content-Disposition header.
+        string FileName { get; }
+        //上传时间戳
+        long UploadTime { get; set; } = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
+    }
+}

+ 2 - 2
HaBookCms.AzureStorage/ServiceExtension/AzureStorageServiceCollectionExtensions.cs

@@ -1,5 +1,5 @@
-using HaBookCms.AzureStorage.AzureBlob.Implement;
-using HaBookCms.AzureStorage.AzureBlob.Interface;
+using HaBookCms.AzureStorage.AzureBlob.Implements;
+using HaBookCms.AzureStorage.AzureBlob.Interfaces;
 using HaBookCms.AzureStorage.AzureTable.Implements;
 using HaBookCms.AzureStorage.AzureTable.Interfaces;
 using Microsoft.Extensions.DependencyInjection;

+ 40 - 0
HaBookCms.Contest/Controllers/SyllabusController.cs

@@ -0,0 +1,40 @@
+using HaBookCms.AzureCosmos.CosmosDB.Interfaces;
+using HaBookCms.Core.Models.Syllabus;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Cors;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace HaBookCms.Contest.Controllers
+{
+    [Route("api/syllabus")]
+    [ApiController]
+    public class SyllabusController : BaseController
+    {
+
+        public IAzureCosmosDBRepository _aAzureCosmosDBRepository;
+
+        public SyllabusController(IAzureCosmosDBRepository aAzureCosmosDBRepository) {
+            _aAzureCosmosDBRepository = aAzureCosmosDBRepository;
+        }
+        [HttpPost]
+        [Route("save")]
+        [EnableCors("any")]
+        [AllowAnonymous]
+        public async Task<object> Save(SyllabusRoot root) {
+            return await _aAzureCosmosDBRepository.Save<SyllabusRoot>(root);
+        }
+
+        [HttpGet]
+        [Route("getById")]
+        [EnableCors("any")]
+        [AllowAnonymous]
+        public object GetById()
+        {
+            return _aAzureCosmosDBRepository.FindAll<SyllabusRoot>().Result.FirstOrDefault();
+        }
+    }
+}

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

@@ -13,6 +13,7 @@
 
 
   <ItemGroup>
+    <ProjectReference Include="..\HaBookCms.AzureCosmos\HaBookCms.AzureCosmos.csproj" />
     <ProjectReference Include="..\HaBookCms.AzureStorage\HaBookCms.AzureStorage.csproj" />
     <ProjectReference Include="..\HaBookCms.Common\HaBookCms.Common.csproj" />
     <ProjectReference Include="..\HaBookCms.ContextConfig\HaBookCms.ContextConfig.csproj" />

+ 1 - 0
HaBookCms.Contest/Program.cs

@@ -19,6 +19,7 @@ namespace HaBookCms.Contest
 
         public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
             WebHost.CreateDefaultBuilder(args)
+             .UseUrls("http://*:5000")
                 .UseStartup<Startup>();
     }
 }

+ 18 - 2
HaBookCms.Contest/Startup.cs

@@ -5,12 +5,15 @@ using System.Security.Claims;
 using System.Text;
 using System.Text.Encodings.Web;
 using System.Text.Unicode;
+using HaBookCms.AzureCosmos.ServiceExtension;
 using HaBookCms.AzureStorage.ServiceExtension;
 using HaBookCms.Common.LogHelper;
+using HaBookCms.ContextConfig.Attributes;
 using HaBookCms.ContextConfig.Exceptions;
 using HaBookCms.Jwt.Filter;
 using HaBookCms.Jwt.Model;
 using HaBookCms.RedisStorage.Cache;
+using HaBookCms.ServiceOptions.Options;
 using log4net;
 using log4net.Config;
 using log4net.Repository;
@@ -65,7 +68,11 @@ namespace HaBookCms.Contest
                 options.MinimumSameSitePolicy = SameSiteMode.None;
             });
 
-
+            services.AddAzureCosmosDB().AddCosmosDBConnection(new AzureCosmosDBOptions() {
+                ConnectionString = Configuration["AppSettings:Azure:CosmosDBConnection:AccountEndpoint"],
+                ConnectionKey= Configuration["AppSettings:Azure:CosmosDBConnection:AccountKey"],
+                Database = Configuration["AppSettings:Azure:CosmosDBConnection:Database"],
+            });
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
             //services.AddMvc().AddMvcOptions(
             //    option =>
@@ -195,7 +202,16 @@ namespace HaBookCms.Contest
             #region 性能 压缩
             services.AddResponseCompression();
             #endregion
-        }
+
+            //跨域//设置了允许所有来源
+            services.AddCors(options =>
+                options.AddPolicy("any",
+                    builder => builder.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin().AllowCredentials()));
+            services.AddMvc(options =>
+            {
+                options.Filters.Add(new AllowCorsAttribute());
+            });
+         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
         public void Configure(IApplicationBuilder app, IHostingEnvironment env)

+ 2 - 1
HaBookCms.Contest/appsettings.json

@@ -19,7 +19,8 @@
       "StorageConnection": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn",
       "CosmosDBConnection": {
         "AccountEndpoint": "https://teammodelostest.documents.azure.cn:443/",
-        "AccountKey": "ReGoiHuTbU4Q31YYq4NaiormE6Ci71piT7OrvTzAuhrlgt63ajdtDZmwOZKzcz6gnwR326mJp53InY7rohepQQ=="
+        "AccountKey": "ReGoiHuTbU4Q31YYq4NaiormE6Ci71piT7OrvTzAuhrlgt63ajdtDZmwOZKzcz6gnwR326mJp53InY7rohepQQ==",
+        "Database": "BaseActivty"
       }
     }
   },

+ 22 - 0
HaBookCms.ContextConfig/Attributes/AllowCorsAttribute.cs

@@ -0,0 +1,22 @@
+using Microsoft.AspNetCore.Mvc.Filters;
+namespace HaBookCms.ContextConfig.Attributes
+{
+
+    /// <summary>
+    /// 跨域处理
+    /// </summary>
+    public class AllowCorsAttribute : ActionFilterAttribute
+    {
+        public override void OnActionExecuting(ActionExecutingContext filterContext)
+        {
+            var context = filterContext.HttpContext;
+            //context.Response.Headers.Add("Access-Control-Allow-Origin", "*");
+            context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS, POST, PUT");
+            context.Response.Headers.Add("Access-Control-Allow-Headers", "Access-Control-Allow-Headers," +
+                                         " Origin,Accept, X-Requested-With, Content-Type, " +
+                                         "Access-Control-Request-Method, Access-Control-Request-Headers," +
+                                         " Content-Type,Accept,access_token, token ");
+            base.OnActionExecuting(filterContext);
+        }
+    }
+}

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

@@ -6,7 +6,6 @@
 
   <ItemGroup>
     <Folder Include="Filters\" />
-    <Folder Include="Attributes\" />
   </ItemGroup>
 
   <ItemGroup>

+ 66 - 0
HaBookCms.Core/Models/Syllabus/SyllabusNode.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HaBookCms.Core.Models.Syllabus
+{
+    public class SyllabusNode
+    {
+        /// <summary>
+        /// 主键
+        /// </summary>
+        public string id { get; set; }
+        /// <summary>
+        /// 颜色
+        /// </summary>
+        public string  color { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string side { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string layout { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public int collapsed { get; set; }
+        /// <summary>
+        /// 图标
+        /// </summary>
+        public string icon { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string shape { get; set; }
+        /// <summary>
+        /// 状态
+        /// </summary>
+        public string status { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public int autoShape { get; set; }
+        /// <summary>
+        /// 值
+        /// </summary>
+        public string value { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string oldText { get; set; }
+        /// <summary>
+        /// 内容
+        /// </summary>
+        public string text { get; set; }
+        /// <summary>
+        /// 引用
+        /// </summary>
+        public string[] quotes { get; set; }
+        /// <summary>
+        /// 子级
+        /// </summary>
+        public ICollection<SyllabusNode> children { get; set; }
+    }
+}

+ 11 - 0
HaBookCms.Core/Models/Syllabus/SyllabusRoot.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HaBookCms.Core.Models.Syllabus
+{
+    public class SyllabusRoot : SyllabusNode
+    {
+        public SyllabusNode root { get; set; }
+    }
+}

+ 9 - 3
HaBookCms.JosnRPCTest/Program.cs

@@ -1,4 +1,5 @@
-using HaBookCms.Common.JsonHelper;
+using HaBookCms.Common;
+using HaBookCms.Common.JsonHelper;
 using HaBookCms.Common.ValidateHelper;
 using HaBookCms.Core.Dtos;
 using HaBookCms.Core.Models.Common;
@@ -18,6 +19,11 @@ namespace HaBookCms.JosnRPCTest
     {
         static void Main(string[] args)
         {
+
+            Console.WriteLine((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) ) ;
+            long das = DateTime.Now.ToUniversalTime().Ticks - 621355968000000000;
+            DateTime dateTime= Utils.ConvertToDateTime(DateTime.Now.ToUniversalTime().Ticks- 621355968000000000);
+            long date = Utils.ConvertToTimeStamp(DateTime.Now);
             List<CmsUser> users = new List<CmsUser>();
             CmsUser user = new CmsUser();
             user.city = "123";
@@ -27,7 +33,7 @@ namespace HaBookCms.JosnRPCTest
 
             responses.CurrPage(1).PageSize(23).totalCount(53).TotalPage(2).Data(users);
             BaseResponse baseResponse= responses.build();
-           string s =  MessagePackHelper.ObjectToJson(baseResponse);
+            string s =  MessagePackHelper.ObjectToJson(baseResponse);
             string rp = "{\"id\":1.0,\"jsonrpc\":\"2.0\",\"result\":null,\"error\":{\"code\":-32601,\"message\":\"No method found with the requested signature or multiple methods matched the request.\",\"data\":null}}";
             JosnRPCResponse<TeamModelIdInfo> rs= MessagePackHelper.JsonToObject<JosnRPCResponse<TeamModelIdInfo>>(rp);
             Task<DataBlock> dataBlock= DataIP2Region.IP2Region("110.185.29.187");
@@ -47,7 +53,7 @@ namespace HaBookCms.JosnRPCTest
             TicketInfo ticketInfo = new TicketInfo();
             ticketInfo.name = "";
             ticketInfo.ticket = "";
-            ValidateHelper.IsValid(ticketInfo);
+           // ValidateHelper.IsValid(ticketInfo);
           
             Console.WriteLine("HelMlo World!");
         }