milimoe d25dd8d2e3
添加自定义 Converter (#31)
* 添加DataTable Converter

* 修改DataSet Converter,支持多个Tables反序列化,此转换器也支持兼容DataTable

* 修改构造方法、工厂方法,添加常用类自定义转换器
2023-06-10 01:01:45 +08:00

61 lines
2.5 KiB
C#

using System.Data;
using Milimoe.FunGame.Core.Interface.Entity;
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
namespace Milimoe.FunGame.Core.Entity
{
public class User : BaseEntity
{
public override long Id { get; set; }
public string Username { get; set; } = "";
public string Password { get; set; } = "";
public DateTime RegTime { get; set; }
public DateTime LastTime { get; set; }
public string Email { get; set; } = "";
public string NickName { get; set; } = "";
public bool IsAdmin { get; set; } = false;
public bool IsOperator { get; set; } = false;
public bool IsEnable { get; set; } = false;
public decimal Credits { get; set; } = 0;
public decimal Materials { get; set; } = 0;
public decimal GameTime { get; set; } = 0;
public string AutoKey { get; set; } = "";
public UserStatistics? Statistics { get; set; } = null;
public Inventory? Inventory { get; set; } = null;
internal User()
{
}
internal User(DataSet? DataSet, int Index = 0)
{
if (DataSet != null && DataSet.Tables[0].Rows.Count > 0)
{
DataRow DataRow = DataSet.Tables[0].Rows[Index];
Id = (long)DataRow[UserQuery.Column_UID];
Username = (string)DataRow[UserQuery.Column_Username];
Password = (string)DataRow[UserQuery.Column_Password];
RegTime = (DateTime)DataRow[UserQuery.Column_RegTime];
LastTime = (DateTime)DataRow[UserQuery.Column_LastTime];
Email = (string)DataRow[UserQuery.Column_Email];
NickName = (string)DataRow[UserQuery.Column_Nickname];
IsAdmin = Convert.ToInt32(DataRow[UserQuery.Column_IsAdmin]) == 1;
IsOperator = Convert.ToInt32(DataRow[UserQuery.Column_IsOperator]) == 1;
IsEnable = Convert.ToInt32(DataRow[UserQuery.Column_IsEnable]) == 1;
Credits = Convert.ToDecimal(DataRow[UserQuery.Column_Credits]);
Materials = Convert.ToDecimal(DataRow[UserQuery.Column_Materials]);
GameTime = Convert.ToDecimal(DataRow[UserQuery.Column_GameTime]);
AutoKey = (string)DataRow[UserQuery.Column_AutoKey];
}
}
public override bool Equals(IBaseEntity? other)
{
if (other == null) return false;
if (((User)other).Id == Id) return true;
return false;
}
}
}