mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-22 12:09:34 +08:00
Add Authenticator
This commit is contained in:
parent
b923308be2
commit
c3c153635f
@ -14,10 +14,10 @@ namespace Milimoe.FunGame.Core.Api.Transmittal
|
|||||||
public abstract string Script { get; set; }
|
public abstract string Script { get; set; }
|
||||||
public abstract CommandType CommandType { get; set; }
|
public abstract CommandType CommandType { get; set; }
|
||||||
public abstract SQLResult Result { get; }
|
public abstract SQLResult Result { get; }
|
||||||
public abstract bool Success { get; }
|
|
||||||
public abstract SQLServerInfo ServerInfo { get; }
|
public abstract SQLServerInfo ServerInfo { get; }
|
||||||
public abstract int UpdateRows { get; }
|
public abstract int UpdateRows { get; }
|
||||||
public abstract DataSet DataSet { get; }
|
public abstract DataSet DataSet { get; }
|
||||||
|
public bool Success => Result == SQLResult.Success;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 执行一个命令
|
/// 执行一个命令
|
||||||
|
@ -10,10 +10,10 @@ namespace Milimoe.FunGame.Core.Interface.Base
|
|||||||
public string Script { get; set; }
|
public string Script { get; set; }
|
||||||
public CommandType CommandType { get; set; }
|
public CommandType CommandType { get; set; }
|
||||||
public SQLResult Result { get; }
|
public SQLResult Result { get; }
|
||||||
public bool Success { get; }
|
|
||||||
public SQLServerInfo ServerInfo { get; }
|
public SQLServerInfo ServerInfo { get; }
|
||||||
public int UpdateRows { get; }
|
public int UpdateRows { get; }
|
||||||
public DataSet DataSet { get; }
|
public DataSet DataSet { get; }
|
||||||
|
public bool Success { get; }
|
||||||
|
|
||||||
public int Execute();
|
public int Execute();
|
||||||
public DataSet ExecuteDataSet();
|
public DataSet ExecuteDataSet();
|
||||||
|
32
Library/Common/Architecture/Authenticator.cs
Normal file
32
Library/Common/Architecture/Authenticator.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Data;
|
||||||
|
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||||
|
|
||||||
|
namespace Milimoe.FunGame.Core.Library.Common.Architecture
|
||||||
|
{
|
||||||
|
public abstract class Authenticator
|
||||||
|
{
|
||||||
|
private readonly SQLHelper SQLHelper;
|
||||||
|
|
||||||
|
public Authenticator(SQLHelper SQLHelper)
|
||||||
|
{
|
||||||
|
this.SQLHelper = SQLHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Authenticate<T>(string script, string column, T keyword)
|
||||||
|
{
|
||||||
|
SQLHelper.ExecuteDataSet(script);
|
||||||
|
if (SQLHelper.Success)
|
||||||
|
{
|
||||||
|
DataSet ds = SQLHelper.DataSet;
|
||||||
|
if (ds.Tables.Count > 0 &&
|
||||||
|
ds.Tables[0].Columns.Contains(column) &&
|
||||||
|
ds.Tables[0].Rows.Count > 0 &&
|
||||||
|
ds.Tables[0].AsEnumerable().Where(row => row.Field<T>(column)!.Equals(keyword)).Any())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user