mirror of
https://github.com/EggLinks/DanhengServer-OpenSource.git
synced 2026-01-03 04:36:03 +08:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using EggLink.DanhengServer.Util;
|
|
|
|
namespace EggLink.DanhengServer.Database.Account
|
|
{
|
|
public static class AccountHelper
|
|
{
|
|
public static void CreateAccount(string username, int uid)
|
|
{
|
|
if (AccountData.GetAccountByUserName(username) != null)
|
|
{
|
|
throw new Exception("Account already exists");
|
|
}
|
|
if (AccountData.GetAccountByUid(uid) != null)
|
|
{
|
|
|
|
}
|
|
int newUid = uid;
|
|
if (uid == 0)
|
|
{
|
|
newUid = 10001; // start from 10001
|
|
while (AccountData.GetAccountByUid(newUid) != null)
|
|
{
|
|
newUid++;
|
|
}
|
|
}
|
|
var per = ConfigManager.Config.ServerOption.DefaultPermissions;
|
|
var perStr = string.Join(",", per);
|
|
var account = new AccountData()
|
|
{
|
|
Uid = newUid,
|
|
Username = username,
|
|
Permissions = perStr
|
|
};
|
|
DatabaseHelper.Instance?.SaveInstance(account);
|
|
}
|
|
}
|
|
}
|