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

namespace Long.DAO.Basedata
{
    /// <summary>
    /// 系统用户-数据库
    /// </summary>
    public interface IUserDatabase : IDatabase<User>
    {
        /// <summary>
        /// 通过登录名获取一条系统用户数据
        /// </summary>
        /// <param name="userName">登录名</param>
        /// <returns>用户</returns>
        Task<User> GetUserAsync(string userName);

        /// <summary>
        /// 通过登录名获取一条系统用户数据
        /// </summary>
        /// <param name="userName">登录名</param>
        /// <returns>用户</returns>
        Task<User> GetByUserNameAsync(string userName);

        /// <summary>
        /// 通过推广码获取一条系统用户数据
        /// </summary>
        /// <param name="userName">登录名</param>
        /// <returns>用户</returns>
        Task<User> GetByPromotionCodeAsync(string promotionCode);

        /// <summary>
        /// 判断推广码是否重复
        /// </summary>
        /// <param name="promotionCode">推广码</param>
        /// <returns>重复标记</returns>
        Task<bool> PromotionCodeIsRepeatAsync(string promotionCode);

        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="id">内码</param>
        /// <param name="password">新密码</param>
        /// <returns></returns>
        Task<int> UpdatePassword(long id, string password);

        /// <summary>
        /// 判断用户是否存在
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> HasUser(long id);
    }
}
