using Long.Common.Basedata;
using Long.Dapper;

namespace Long.DAO.Basedata
{
    /// <summary>
    /// 系统用户-数据库
    /// </summary>
    public class SystemUserDatabase : Database<SystemUser>, ISystemUserDatabase
    {
        /// <summary>
        /// 通过登录名获取一条系统用户数据
        /// </summary>
        /// <param name="userName">登录名</param>
        /// <returns>系统用户</returns>
        public Task<SystemUser> GetByUserNameAsync(string userName)
        {
            string sql = "SELECT Id, Opened, UserName, Password, Email, Name, Gender, Age, `Language`, City, Province, Country, AvatarUrl, Phone, CreatedBy, CreatedOn, LastModifiedBy, LastModifiedOn FROM systemuser WHERE UserName = @UserName;";
            return GetFirstAsync(sql, new { UserName = userName });
        }
    }
}
