From 4c50acc30954422d0eb2b57a7d62f6c2f04b508c Mon Sep 17 00:00:00 2001 From: xRain Date: Sat, 23 Mar 2024 07:10:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86model=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configurations/SimApiOptions.cs | 6 +++--- Models/SimApiBaseModel.cs | 15 +++++++++++---- SimApi.csproj | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Configurations/SimApiOptions.cs b/Configurations/SimApiOptions.cs index 51a69fc..678fc66 100644 --- a/Configurations/SimApiOptions.cs +++ b/Configurations/SimApiOptions.cs @@ -61,14 +61,14 @@ namespace SimApi.Configs /// /// Swagger文档相关配置,需要启用 EnableSimApiDoc /// - public SimApiDocOptions SimApiDocOptions { get; set; } = new SimApiDocOptions(); + public SimApiDocOptions SimApiDocOptions { get; set; } = new(); /// /// S3兼容的存储系统配置,需要启用 EnableSimApiStorage /// - public SimApiStorageOptions SimApiStorageOptions { get; set; } = new SimApiStorageOptions(); + public SimApiStorageOptions SimApiStorageOptions { get; set; } = new(); - public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new SimApiSynapseOptions(); + public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new(); public void ConfigureSimApiSynapse(Action options = null) { diff --git a/Models/SimApiBaseModel.cs b/Models/SimApiBaseModel.cs index 2cbcfbc..790491e 100644 --- a/Models/SimApiBaseModel.cs +++ b/Models/SimApiBaseModel.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text.Json; using SimApi.Helpers; @@ -7,10 +8,16 @@ namespace SimApi.Models { public class SimApiBaseModel { - protected virtual string[] MapperIgnoreField { get; set; } = - { - "Id", "CreatedAt", "UpdatedAt" - }; + [Column(Order = 1)] + public string Id { get; set; } = Guid.NewGuid().ToString(); + + [Column(Order = 9998)] + public DateTime UpdatedAt { get; set; } = SimApiUtil.CstNow; + + [Column(Order = 9999)] + public DateTime CreatedAt { get; set; } = SimApiUtil.CstNow; + + protected virtual string[] MapperIgnoreField { get; set; } = { "Id", "CreatedAt", "UpdatedAt" }; protected virtual string UpdatedTimeField { get; set; } = "UpdatedAt"; diff --git a/SimApi.csproj b/SimApi.csproj index 2273f62..1c593b9 100644 --- a/SimApi.csproj +++ b/SimApi.csproj @@ -14,7 +14,7 @@ false true 5.0.2 - net7.0 + net7.0;net8.0