From d696eaaac907769f0dfa5608eac1baa1f6158d42 Mon Sep 17 00:00:00 2001 From: sunhonglei Date: Fri, 27 Dec 2024 17:19:02 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A4=9A=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Entity/MethodConfigEntity.cs | 83 ------------------------------ 1 file changed, 83 deletions(-) delete mode 100644 Model/Entity/MethodConfigEntity.cs diff --git a/Model/Entity/MethodConfigEntity.cs b/Model/Entity/MethodConfigEntity.cs deleted file mode 100644 index eb6e33e..0000000 --- a/Model/Entity/MethodConfigEntity.cs +++ /dev/null @@ -1,83 +0,0 @@ -using SparkClient.Model.Entity.Base; -using System.Reflection; -using System.Runtime.CompilerServices; - -namespace SparkClient.Model.Entity; - -/// -/// 系统设置实体 -/// - -public class MethodConfigEntity : BaseEntity -{ - public static readonly new string TableName = "METHOD_CONFIG"; - [DbField("GUID")] - public Guid GUID { get; set; } - /// - /// json内容 - /// - [DbField("JSON")] - public string Json { get; set; } - /// - /// Json排序 - /// - [DbField("JSON_ORDER")] - public int JsonOrder { get; set; } - - private static Dictionary GetFieldMappings() - { - var properties = typeof(MethodConfigEntity).GetProperties(BindingFlags.Public | BindingFlags.Instance); - return properties - .Where(p => Attribute.IsDefined(p, typeof(DbFieldAttribute))) - .ToDictionary( - p => p.Name, - p => ((DbFieldAttribute)p.GetCustomAttribute(typeof(DbFieldAttribute))).FieldName - ); - } - - // 生成 Insert 语句 - public string GenerateInsertSQL() - { - var mappings = GetFieldMappings(); - var columns = string.Join(", ", mappings.Values); - var values = string.Join(", ", mappings.Keys.Select(k => $"@{k}")); - return $"INSERT INTO {TableName} ({columns}) VALUES ({values});"; - } - - // 生成 Update 语句 - public string GenerateUpdateSQL(Dictionary fieldsToUpdate = null) - { - if (fieldsToUpdate == null || fieldsToUpdate.Count == 0) - { - // 默认根据 ID 更新所有字段 - var mappings = GetFieldMappings(); - var setClause = string.Join(", ", mappings.Values.Select(f => $"{f} = @{f}")); - return $"UPDATE {TableName} SET {setClause} WHERE GUID = " + GUID.ToString() + ";"; - } - else - { - // 根据传入的字段更新 - var setClause = string.Join(", ", fieldsToUpdate.Keys.Select(f => $"{f} = @{f}")); - return $"UPDATE {TableName} SET {setClause} WHERE GUID = " + GUID.ToString() + ";"; - } - } - - // 生成 Delete 语句 - public string GenerateDeleteSQL(Dictionary conditions = null) - { - if (conditions == null || conditions.Count == 0) - { - // 默认根据 ID 删除 - return $"DELETE FROM {TableName} WHERE GUID =" + GUID.ToString() + ";"; - } - else - { - // 根据传入条件删除 - var whereClause = string.Join(" AND ", conditions.Keys.Select(f => $"{f} = @{f}")); - return $"DELETE FROM {TableName} WHERE {whereClause};"; - } - } - -} - -