diff --git a/FunGame.Core/Api/Data/SQLHelper.cs b/FunGame.Core/Api/Data/SQLHelper.cs new file mode 100644 index 0000000..b0d7a9c --- /dev/null +++ b/FunGame.Core/Api/Data/SQLHelper.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Milimoe.FunGame.Core.Interface.Base; +using Milimoe.FunGame.Core.Library.Common.Network; +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Core.Api.Data +{ + public class SQLHelper : ISQLHelper + { + public string Script { get; set; } = ""; + + public EntityType EntityType { get; private set; } = EntityType.Empty; + + public object Entity { get; private set; } = General.EntityInstance; + + public SQLResult Result { get; private set; } = SQLResult.Success; + + public SQLServerInfo ServerInfo { get; private set; } = new SQLServerInfo(); + + public int UpdateRows { get; private set; } = 0; + + public SQLHelper Instance { get; private set; } = new SQLHelper(); + + public static SQLHelper GetHelper(EntityType type) + { + return new SQLHelper(type); + } + + private SQLHelper(EntityType type) + { + this.EntityType = type; + } + + private SQLHelper() + { + + } + } +} diff --git a/FunGame.Core/Api/Proxy/SQLProxy.cs b/FunGame.Core/Api/Proxy/SQLProxy.cs deleted file mode 100644 index a52c437..0000000 --- a/FunGame.Core/Api/Proxy/SQLProxy.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Milimoe.FunGame.Core.Interface.Base; -using Milimoe.FunGame.Core.Library.Constant; -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Milimoe.FunGame.Core.Api.Proxy -{ - public class SQLProxy : ISQLProxy - { - public ProxyResult Execute() - { - throw new NotImplementedException(); - } - - public ProxyResult Execute(object[]? objs = null) - { - throw new NotImplementedException(); - } - - public ProxyResult Execute(StringBuilder script) - { - throw new NotImplementedException(); - } - - public int ExecuteRow() - { - throw new NotImplementedException(); - } - - public int ExecuteRow(object[]? objs = null) - { - throw new NotImplementedException(); - } - - public int ExecuteRow(StringBuilder script) - { - throw new NotImplementedException(); - } - - public DataSet GetData(EntityType type, object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataSet GetData(object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataSet GetData(StringBuilder script) - { - throw new NotImplementedException(); - } - - public DataRow GetDataRow(EntityType type, object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataRow GetDataRow(DataSet set, object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataRow GetDataRow(DataTable table, object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataRow GetDataRow(StringBuilder script) - { - throw new NotImplementedException(); - } - - public DataTable GetDataTable(EntityType type, object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataTable GetDataTable(object[]? objs = null) - { - throw new NotImplementedException(); - } - - public DataTable GetDataTable(StringBuilder script) - { - throw new NotImplementedException(); - } - } -} diff --git a/FunGame.Core/Api/Utility/Implement.cs b/FunGame.Core/Api/Utility/Implement.cs index fa8c9fb..3b3c02f 100644 --- a/FunGame.Core/Api/Utility/Implement.cs +++ b/FunGame.Core/Api/Utility/Implement.cs @@ -1,4 +1,4 @@ - using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; diff --git a/FunGame.Core/Interface/Base/ISQLHelper.cs b/FunGame.Core/Interface/Base/ISQLHelper.cs new file mode 100644 index 0000000..c290f32 --- /dev/null +++ b/FunGame.Core/Interface/Base/ISQLHelper.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Core.Interface.Base +{ + public interface ISQLHelper + { + public string Script { get; set; } + public EntityType EntityType { get; } + public object Entity { get; } + public SQLResult Result { get; } + int UpdateRows { get; } + public Library.Common.Network.SQLServerInfo ServerInfo { get; } + } +} diff --git a/FunGame.Core/Interface/Base/ISQLProxy.cs b/FunGame.Core/Interface/Base/ISQLProxy.cs deleted file mode 100644 index 221fdb2..0000000 --- a/FunGame.Core/Interface/Base/ISQLProxy.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Milimoe.FunGame.Core.Library.Constant; - -namespace Milimoe.FunGame.Core.Interface.Base -{ - public interface ISQLProxy - { - public ProxyResult Execute(); - public ProxyResult Execute(object[]? objs = null); - public ProxyResult Execute(StringBuilder script); - public int ExecuteRow(); - public int ExecuteRow(object[]? objs = null); - public int ExecuteRow(StringBuilder script); - public System.Data.DataSet GetData(EntityType type, object[]? objs = null); - public System.Data.DataSet GetData(object[]? objs = null); - public System.Data.DataSet GetData(StringBuilder script); - public System.Data.DataTable GetDataTable(EntityType type, object[]? objs = null); - public System.Data.DataTable GetDataTable(object[]? objs = null); - public System.Data.DataTable GetDataTable(StringBuilder script); - public System.Data.DataRow GetDataRow(EntityType type, object[]? objs = null); - public System.Data.DataRow GetDataRow(System.Data.DataSet set, object[]? objs = null); - public System.Data.DataRow GetDataRow(System.Data.DataTable table, object[]? objs = null); - public System.Data.DataRow GetDataRow(StringBuilder script); - } -} diff --git a/FunGame.Core/Interface/Base/ISQLService.cs b/FunGame.Core/Interface/Base/ISQLService.cs index 6b84290..03c0e69 100644 --- a/FunGame.Core/Interface/Base/ISQLService.cs +++ b/FunGame.Core/Interface/Base/ISQLService.cs @@ -9,24 +9,18 @@ namespace Milimoe.FunGame.Core.Interface.Base { internal interface ISQLService { - internal ProxyResult Execute(); - internal ProxyResult Execute(object[]? objs = null); - internal ProxyResult Execute(StringBuilder script); - internal int UpdateRow(object[]? objs = null); - internal int UpdateRow(StringBuilder script); - internal int DeleteRow(object[]? objs = null); - internal int DeleteRow(StringBuilder script); - internal int AddRow(object[]? objs = null); - internal int AddRow(StringBuilder script); - internal System.Data.DataSet GetData(EntityType type, object[]? objs = null); - internal System.Data.DataSet GetData(object[]? objs = null); - internal System.Data.DataSet GetData(StringBuilder script); - internal System.Data.DataTable GetDataTable(EntityType type, object[]? objs = null); - internal System.Data.DataTable GetDataTable(object[]? objs); - internal System.Data.DataTable GetDataTable(StringBuilder script); - internal System.Data.DataRow GetDataRow(EntityType type, object[]? objs = null); - internal System.Data.DataRow GetDataRow(System.Data.DataSet set, object[]? objs = null); - internal System.Data.DataRow GetDataRow(System.Data.DataTable table, object[]? objs = null); - internal System.Data.DataRow GetDataRow(StringBuilder script); + internal SQLResult Execute(); + internal SQLResult Execute(StringBuilder sql); + internal SQLResult Execute(string sql); + internal int Update(StringBuilder sql, ref SQLResult result); + internal int Remove(StringBuilder sql, ref SQLResult result); + internal int Add(StringBuilder sql, ref SQLResult result); + internal int Update(string sql, ref SQLResult result); + internal int Remove(string sql, ref SQLResult result); + internal int Add(string sql, ref SQLResult result); + internal object Query(EntityType type, StringBuilder sql); + internal T Query(StringBuilder sql); + internal object Query(EntityType type, string sql); + internal T Query(string sql); } } diff --git a/FunGame.Core/Library/Common/Network/SQLConnection.cs b/FunGame.Core/Library/Common/Network/SQLConnection.cs index 090c415..c6d279d 100644 --- a/FunGame.Core/Library/Common/Network/SQLConnection.cs +++ b/FunGame.Core/Library/Common/Network/SQLConnection.cs @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace Milimoe.FunGame.Core.Library.Common.Network { - public class SQLConnection + public class SQLServerInfo { + } } diff --git a/FunGame.Core/Library/Constant/ResultEnum.cs b/FunGame.Core/Library/Constant/ResultEnum.cs index f0a7146..e853761 100644 --- a/FunGame.Core/Library/Constant/ResultEnum.cs +++ b/FunGame.Core/Library/Constant/ResultEnum.cs @@ -37,10 +37,12 @@ namespace Milimoe.FunGame.Core.Library.Constant FindServerFailed } - public enum ProxyResult + public enum SQLResult { Success, Fail, - NotFound + NotFound, + SQLError, + IsExist } } diff --git a/FunGame.Core/Service/SQLManager.cs b/FunGame.Core/Service/SQLManager.cs index 11fe541..818b081 100644 --- a/FunGame.Core/Service/SQLManager.cs +++ b/FunGame.Core/Service/SQLManager.cs @@ -11,97 +11,67 @@ namespace Milimoe.FunGame.Core.Service { internal class SQLManager : ISQLService { - int ISQLService.AddRow(object[]? objs) + int ISQLService.Add(StringBuilder sql, ref SQLResult result) { throw new NotImplementedException(); } - int ISQLService.AddRow(StringBuilder script) + int ISQLService.Add(string sql, ref SQLResult result) { throw new NotImplementedException(); } - int ISQLService.DeleteRow(object[]? objs) + SQLResult ISQLService.Execute() { throw new NotImplementedException(); } - int ISQLService.DeleteRow(StringBuilder script) + SQLResult ISQLService.Execute(StringBuilder sql) { throw new NotImplementedException(); } - ProxyResult ISQLService.Execute() + SQLResult ISQLService.Execute(string sql) { throw new NotImplementedException(); } - ProxyResult ISQLService.Execute(object[]? objs) + object ISQLService.Query(EntityType type, StringBuilder sql) { throw new NotImplementedException(); } - ProxyResult ISQLService.Execute(StringBuilder script) + T ISQLService.Query(StringBuilder sql) { throw new NotImplementedException(); } - DataSet ISQLService.GetData(EntityType type, object[]? objs) + object ISQLService.Query(EntityType type, string sql) { throw new NotImplementedException(); } - DataSet ISQLService.GetData(object[]? objs) + T ISQLService.Query(string sql) { throw new NotImplementedException(); } - DataSet ISQLService.GetData(StringBuilder script) + int ISQLService.Remove(StringBuilder sql, ref SQLResult result) { throw new NotImplementedException(); } - DataRow ISQLService.GetDataRow(EntityType type, object[]? objs) + int ISQLService.Remove(string sql, ref SQLResult result) { throw new NotImplementedException(); } - DataRow ISQLService.GetDataRow(DataSet set, object[]? objs) + int ISQLService.Update(StringBuilder sql, ref SQLResult result) { throw new NotImplementedException(); } - DataRow ISQLService.GetDataRow(DataTable table, object[]? objs) - { - throw new NotImplementedException(); - } - - DataRow ISQLService.GetDataRow(StringBuilder script) - { - throw new NotImplementedException(); - } - - DataTable ISQLService.GetDataTable(EntityType type, object[]? objs) - { - throw new NotImplementedException(); - } - - DataTable ISQLService.GetDataTable(object[]? objs) - { - throw new NotImplementedException(); - } - - DataTable ISQLService.GetDataTable(StringBuilder script) - { - throw new NotImplementedException(); - } - - int ISQLService.UpdateRow(object[]? objs) - { - throw new NotImplementedException(); - } - - int ISQLService.UpdateRow(StringBuilder script) + int ISQLService.Update(string sql, ref SQLResult result) { throw new NotImplementedException(); }