using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Common.Page;
using GxPress.Entity;
using GxPress.Request.User;
using GxPress.Result.User;
using Datory;
using GxPress.Result.App.User;
using GxPress.Result.Job;

namespace GxPress.Repository.Interface
{
    public interface IUserRepository : IRepository
    {
        Task<User> GetAsync(int id);
        Task<User> GetAsync(SqlKata.Query query);
        Task<UserDetail> GetDetailAsync(int id);
        Task<string> GetNameAsync(int id);

        Task<string> GetAvatarUrlAsync(int id);

        string GetAvatarUrl(User user);

        Task<User> GetByPhoneAsync(string phone);

        Task<bool> DeleteUsersAsync(IEnumerable<int> userIds);

        Task<bool> ChangeRoleAsync(IEnumerable<int> userIds, int roleId);

        Task<bool> ChangeDepartmentAsync(IEnumerable<int> userIds, int department);

        Task<bool> UpdateAsync(User user);
        Task<bool> UpdateAsync(SqlKata.Query query);
        Task<int> GetCountAsync(int departmentId, int roleId, string keyword);

        /// <summary>
        /// Set the limit and offset for a given page.
        /// </summary>
        /// <param name="page"></param>
        /// <param name="perPage"></param>
        /// <param name="departmentId"></param>
        /// <param name="roleId"></param>
        /// <param name="keyword"></param>
        /// <returns></returns>
        Task<IEnumerable<User>> GetPageListAsync(int page, int perPage, int departmentId, int roleId, string keyword);

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<UserSignInResult> SignInAsync(UserSignInRequest request);

        Task<int> InsertAsync(User user);

        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 更新用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(int id, User request);

        /// <summary>
        /// 用户分页列表
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<PagedList<UserResult>> GetPagedListAsync(UserPageSearchRequest request);

        Task<List<UserResult>> GetListAsync(ArticleSearchRequest request);

        /// <summary>
        /// 更新excel用户数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateUserExcelAsync(List<User> request);

        /// <summary>
        /// 更新用户是否接收私信
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateUserPrivateLetterAsync(UserPrivateLetterRequest request);

        /// <summary>
        /// 更新用户是否接收通知
        /// </summary>
        Task<bool> UpdateUserNoticeAsync(UserNoticeRequest request);

        /// <summary>
        /// 更新用户是否接收回复
        /// </summary>
        Task<bool> UpdateUserReplyAsync(UserReplyRequest request);

        /// <summary>
        /// 更新用户是否静音
        /// </summary>
        Task<bool> UpdateUserMuteAsync(UserMuteRequest request);

        /// <summary>
        /// 更新用户是否震动
        /// </summary>
        Task<bool> UpdateUserShakeAsync(UserShakeRequest request);

        /// <summary>
        /// 修改用户手机号码
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateUserPhoneAsync(UserUpdatePhoneRequest request);

        /// <summary>
        /// 用户邮箱验证
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> SendEmailVerifyCodeAsync(UserEmailVerifyCodeRequest request);

        /// <summary>
        /// 用户修改密码
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateUserEmailAsync(UserUpdateEmailRequest request);

        /// <summary>
        /// 根据部门ID获取下面的用户
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        Task<IEnumerable<User>> GetUserByDepartmentIdAsync(int departmentId);

        /// <summary>
        /// 根据部门ID获取下面的用户ID
        /// </summary>
        /// <param name="departmentId"></param>
        /// <returns></returns>
        Task<IEnumerable<int>> GetUserIdListByDepartmentIdAsync(int departmentId);

        /// <summary>
        /// 根据角色ID获取下面的用户ID
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        Task<IEnumerable<int>> GetUserIdListByRoleIdAsync(int roleId);

        /// <summary>
        /// 创建环信用户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> CreateMiUserAsync(User request);

        /// <summary>
        /// 模糊搜索用户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<IEnumerable<UserInfoResult>> SearchUserNameAsync(SearchUserNameRequest request);

        /// <summary>
        /// 获取用户
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<User>> FindAllUserAsync(SqlKata.Query query);

        /// <summary>
        /// 根据GUID获取用户信息
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        Task<UserDetail> GetGuidAsync(string guid);

        Task<int> CountAsync(SqlKata.Query query);

        Task<IEnumerable<User>> GetAllAsync(SqlKata.Query query);

        /// <summary>
        /// 根据ID集合查询用户
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        Task<IEnumerable<User>> UserListInsAsync(List<int> ids);

        /// <summary>
        /// 获取用户未读数据
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Task<UserCountResult> GetUserCountAsync(int userId);

        /// <summary>
        /// 获取工作用户选择审核和抄送人
        /// </summary>
        /// <param name="userIds"></param>
        /// <param name="flowId"></param>
        /// <returns></returns>
        Task<List<Entity.User>> GeFlowUsers(List<int> userIds, int flowId, string type);

        Task<List<JobUserResult>> ElasticSearchUser();
        /// <summary>
        /// 根据姓名查询用户
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<IEnumerable<UserInfoResult>> UserByNameAsync(string name);

        /// <summary>
        /// openId微信认证
        /// </summary>
        /// <param name="openId"></param>
        /// /// <returns></returns>
        Task<User> GetByOpenIdAsync(string openId);
        /// <summary>
        /// 绑定微信
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateByOpendIdAsync(UserSignInRequest request);
        /// <summary>
        /// vip用户
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<PagedList<UserDetail>> GetUserVipDetail(UserSearchVipRequest request);
    }
}