using System; using System.Collections.Generic; using System.Threading.Tasks; using Timeline.Entities; using Timeline.Models; namespace Timeline.Services.User { public interface IUserService { /// /// Check if a user exists. /// /// The id of the user. /// True if exists. Otherwise false. Task CheckUserExistenceAsync(long id); /// /// Get the user id of given username. /// /// Username of the user. /// The id of the user. /// Thrown when is null. /// Thrown when is of bad format. /// Thrown when the user with given username does not exist. Task GetUserIdByUsernameAsync(string username); /// /// Get the username modified time of a user. /// /// User id. /// The time. /// Thrown when user does not exist. Task GetUsernameLastModifiedTimeAsync(long userId); /// /// Try to get a user by id. /// /// The id of the user. /// The user info. /// Thrown when the user with given id does not exist. Task GetUserAsync(long id); /// /// List all users. /// /// The user info of users. Task> GetUsersAsync(); Task> GetUsersV2Async(int page, int pageSize); /// /// Create a user with given info. /// /// Info of new user. /// The the new user. /// Thrown when is null. /// Thrown when param field is illegal. /// Thrown when a user with given username already exists. Task CreateUserAsync(CreateUserParams param); /// /// Modify a user. /// /// The id of the user. /// The new information. /// The new user info. /// Thrown when some fields in is bad. /// Thrown when user with given id does not exist. /// /// Version will increase if password is changed. /// Task ModifyUserAsync(long id, ModifyUserParams? param); /// /// Try to verify the given username and password. /// /// The username of the user to verify. /// The password of the user to verify. /// User id. /// Thrown when or is null. /// Thrown when is of bad format or is empty. /// Thrown when the user with given username does not exist. /// Thrown when password is wrong. Task VerifyCredential(string username, string password); /// /// Try to change a user's password with old password. /// /// The id of user to change password of. /// Old password. /// New password. /// Thrown if or is null. /// Thrown if or is empty. /// Thrown if the user with given username does not exist. /// Thrown if the old password is wrong. Task ChangePassword(long id, string oldPassword, string newPassword); } }