mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-02 20:26:03 +08:00
55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using EggLink.DanhengServer.Util;
|
|
using Microsoft.Data.Sqlite;
|
|
using SqlSugar;
|
|
|
|
namespace EggLink.DanhengServer.Database.Account
|
|
{
|
|
[SugarTable("Account")]
|
|
public class AccountData() : BaseDatabaseDataHelper
|
|
{
|
|
public string? Username { get; set; }
|
|
|
|
[SugarColumn(IsNullable = true)]
|
|
public string? ComboToken { get; set; }
|
|
|
|
[SugarColumn(IsNullable = true)]
|
|
public string? DispatchToken { get; set; }
|
|
|
|
[SugarColumn(IsNullable = true)]
|
|
public string? Permissions { get; set; } // type: permission1,permission2,permission3...
|
|
|
|
public static AccountData? GetAccountByUserName(string username)
|
|
{
|
|
AccountData? result = null;
|
|
DatabaseHelper.GetAllInstance<AccountData>()?.ForEach((account) =>
|
|
{
|
|
if (account.Username == username)
|
|
{
|
|
result = account;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
public static AccountData? GetAccountByUid(long uid)
|
|
{
|
|
AccountData? result = DatabaseHelper.Instance?.GetInstance<AccountData>((int)uid);
|
|
return result;
|
|
}
|
|
|
|
public string GenerateDispatchToken()
|
|
{
|
|
DispatchToken = Crypto.CreateSessionKey(Uid.ToString());
|
|
DatabaseHelper.Instance?.UpdateInstance(this);
|
|
return DispatchToken;
|
|
}
|
|
|
|
public string GenerateComboToken()
|
|
{
|
|
ComboToken = Crypto.CreateSessionKey(Uid.ToString());
|
|
DatabaseHelper.Instance?.UpdateInstance(this);
|
|
return ComboToken;
|
|
}
|
|
}
|
|
}
|