mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-12-05 00:06:02 +00:00
水个SQL
This commit is contained in:
parent
47cbdd756a
commit
c97f08ff0e
@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using Milimoe.FunGame.Core.Interface.Base;
|
||||
using Milimoe.FunGame.Core.Library.Common.Network;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using Milimoe.FunGame.Core.Service;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Api.Data
|
||||
{
|
||||
@ -14,31 +15,41 @@ namespace Milimoe.FunGame.Core.Api.Data
|
||||
{
|
||||
public string Script { get; set; } = "";
|
||||
|
||||
public EntityType EntityType { get; private set; } = EntityType.Empty;
|
||||
public EntityType EntityType { get; }
|
||||
|
||||
public object Entity { get; private set; } = General.EntityInstance;
|
||||
public object Entity { get; } = General.EntityInstance;
|
||||
|
||||
public SQLResult Result { get; private set; } = SQLResult.Success;
|
||||
public SQLResult Result { get; }
|
||||
|
||||
public SQLServerInfo ServerInfo { get; private set; } = new SQLServerInfo();
|
||||
public SQLServerInfo ServerInfo { get; }
|
||||
|
||||
public int UpdateRows { get; private set; } = 0;
|
||||
|
||||
public SQLHelper Instance { get; private set; } = new SQLHelper();
|
||||
public int UpdateRows { get; }
|
||||
|
||||
public static SQLHelper GetHelper(EntityType type)
|
||||
{
|
||||
return new SQLHelper(type);
|
||||
}
|
||||
|
||||
private SQLHelper(EntityType type)
|
||||
private SQLHelper(EntityType type = EntityType.Empty, SQLServerInfo? info = null, SQLResult result = SQLResult.Success, int rows = 0)
|
||||
{
|
||||
this.EntityType = type;
|
||||
if (info == null) this.ServerInfo = SQLServerInfo.Create();
|
||||
else this.ServerInfo = info;
|
||||
this.Result = result;
|
||||
this.UpdateRows = rows;
|
||||
}
|
||||
|
||||
private SQLHelper()
|
||||
public SQLResult Execute()
|
||||
{
|
||||
|
||||
switch (EntityType)
|
||||
{
|
||||
case EntityType.NotEntity:
|
||||
SQLManager SQLManager = new(this);
|
||||
return SQLManager.Execute(Script);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
FunGame.Core/Interface/Base/BaseSQLService.cs
Normal file
26
FunGame.Core/Interface/Base/BaseSQLService.cs
Normal file
@ -0,0 +1,26 @@
|
||||
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
|
||||
{
|
||||
internal abstract class BaseSQLService
|
||||
{
|
||||
internal abstract SQLResult Execute();
|
||||
internal abstract SQLResult Execute(StringBuilder sql);
|
||||
internal abstract SQLResult Execute(string sql);
|
||||
internal abstract int Update(StringBuilder sql, ref SQLResult result);
|
||||
internal abstract int Remove(StringBuilder sql, ref SQLResult result);
|
||||
internal abstract int Add(StringBuilder sql, ref SQLResult result);
|
||||
internal abstract int Update(string sql, ref SQLResult result);
|
||||
internal abstract int Remove(string sql, ref SQLResult result);
|
||||
internal abstract int Add(string sql, ref SQLResult result);
|
||||
internal abstract object Query(EntityType type, StringBuilder sql);
|
||||
internal abstract T Query<T>(StringBuilder sql);
|
||||
internal abstract object Query(EntityType type, string sql);
|
||||
internal abstract T Query<T>(string sql);
|
||||
}
|
||||
}
|
||||
@ -1,26 +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
|
||||
{
|
||||
internal interface ISQLService
|
||||
{
|
||||
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<T>(StringBuilder sql);
|
||||
internal object Query(EntityType type, string sql);
|
||||
internal T Query<T>(string sql);
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,51 @@
|
||||
using System;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Library.Common.Network
|
||||
{
|
||||
public class SQLServerInfo
|
||||
{
|
||||
public string SQLServerName { get; } = "";
|
||||
public string SQLServerIP { get; } = "";
|
||||
public string SQLServerPort { get; } = "";
|
||||
public string SQLServerUser { get; } = "";
|
||||
public string SQLServerPassword { get; } = "";
|
||||
|
||||
internal SQLServerInfo(InfoBuilder builder)
|
||||
{
|
||||
SQLServerName = builder.SQLServerName;
|
||||
SQLServerIP = builder.SQLServerIP;
|
||||
SQLServerPort = builder.SQLServerPort;
|
||||
SQLServerUser = builder.SQLServerUser;
|
||||
SQLServerPassword = builder.SQLServerPassword;
|
||||
}
|
||||
|
||||
public static SQLServerInfo Create(string name = "", string ip = "", string port = "", string user = "", string password = "")
|
||||
{
|
||||
return new SQLServerInfo(new InfoBuilder(name, ip, port, user, password));
|
||||
}
|
||||
|
||||
internal class InfoBuilder
|
||||
{
|
||||
internal string SQLServerName { get; } = "";
|
||||
internal string SQLServerIP { get; } = "";
|
||||
internal string SQLServerPort { get; } = "";
|
||||
internal string SQLServerUser { get; } = "";
|
||||
internal string SQLServerPassword { get; } = "";
|
||||
|
||||
internal InfoBuilder(string name, string ip, string port, string user, string password)
|
||||
{
|
||||
SQLServerName = name;
|
||||
SQLServerIP = ip;
|
||||
SQLServerPort = port;
|
||||
SQLServerUser = user;
|
||||
SQLServerPassword = password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +131,8 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
PassiveSkill,
|
||||
GameStatistics,
|
||||
Character,
|
||||
CharacterStatistics
|
||||
CharacterStatistics,
|
||||
NotEntity
|
||||
}
|
||||
|
||||
public enum TimeType
|
||||
|
||||
@ -1,77 +1,85 @@
|
||||
using Milimoe.FunGame.Core.Interface.Base;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Milimoe.FunGame.Core.Api.Data;
|
||||
using Milimoe.FunGame.Core.Interface.Base;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Core.Service
|
||||
{
|
||||
internal class SQLManager : ISQLService
|
||||
internal class SQLManager : BaseSQLService
|
||||
{
|
||||
int ISQLService.Add(StringBuilder sql, ref SQLResult result)
|
||||
internal SQLHelper SQLHelper { get; }
|
||||
|
||||
internal SQLManager(SQLHelper SQLHelper)
|
||||
{
|
||||
this.SQLHelper = SQLHelper;
|
||||
}
|
||||
|
||||
internal override int Add(StringBuilder sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int ISQLService.Add(string sql, ref SQLResult result)
|
||||
internal override int Add(string sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
SQLResult ISQLService.Execute()
|
||||
internal override SQLResult Execute()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
SQLResult ISQLService.Execute(StringBuilder sql)
|
||||
internal override SQLResult Execute(StringBuilder sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
SQLResult ISQLService.Execute(string sql)
|
||||
internal override SQLResult Execute(string sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
object ISQLService.Query(EntityType type, StringBuilder sql)
|
||||
internal override object Query(EntityType type, StringBuilder sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
T ISQLService.Query<T>(StringBuilder sql)
|
||||
internal override T Query<T>(StringBuilder sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
object ISQLService.Query(EntityType type, string sql)
|
||||
internal override object Query(EntityType type, string sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
T ISQLService.Query<T>(string sql)
|
||||
internal override T Query<T>(string sql)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int ISQLService.Remove(StringBuilder sql, ref SQLResult result)
|
||||
internal override int Remove(StringBuilder sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int ISQLService.Remove(string sql, ref SQLResult result)
|
||||
internal override int Remove(string sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int ISQLService.Update(StringBuilder sql, ref SQLResult result)
|
||||
internal override int Update(StringBuilder sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int ISQLService.Update(string sql, ref SQLResult result)
|
||||
internal override int Update(string sql, ref SQLResult result)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user