aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Services/User/IUserService.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-04-27 19:29:20 +0800
committercrupest <crupest@outlook.com>2021-04-27 19:29:20 +0800
commita665f5d894539cae5f4188e4a72ea9634b8c4ed0 (patch)
tree03aa9d578e13213018c178ba47755167e2ccc2d4 /BackEnd/Timeline/Services/User/IUserService.cs
parent89e3c2103fa478ebc659a1b914e75d5138c06c08 (diff)
downloadtimeline-a665f5d894539cae5f4188e4a72ea9634b8c4ed0.tar.gz
timeline-a665f5d894539cae5f4188e4a72ea9634b8c4ed0.tar.bz2
timeline-a665f5d894539cae5f4188e4a72ea9634b8c4ed0.zip
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Services/User/IUserService.cs')
-rw-r--r--BackEnd/Timeline/Services/User/IUserService.cs71
1 files changed, 71 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/User/IUserService.cs b/BackEnd/Timeline/Services/User/IUserService.cs
new file mode 100644
index 00000000..06155c55
--- /dev/null
+++ b/BackEnd/Timeline/Services/User/IUserService.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Timeline.Entities;
+
+namespace Timeline.Services.User
+{
+ public interface IUserService : IBasicUserService
+ {
+ /// <summary>
+ /// Try to get a user by id.
+ /// </summary>
+ /// <param name="id">The id of the user.</param>
+ /// <returns>The user info.</returns>
+ /// <exception cref="UserNotExistException">Thrown when the user with given id does not exist.</exception>
+ Task<UserEntity> GetUserAsync(long id);
+
+ /// <summary>
+ /// List all users.
+ /// </summary>
+ /// <returns>The user info of users.</returns>
+ Task<List<UserEntity>> GetUsersAsync();
+
+ /// <summary>
+ /// Create a user with given info.
+ /// </summary>
+ /// <param name="param">Info of new user.</param>
+ /// <returns>The the new user.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="param"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when param field is illegal.</exception>
+ /// <exception cref="EntityAlreadyExistException">Thrown when a user with given username already exists.</exception>
+ Task<UserEntity> CreateUserAsync(CreateUserParams param);
+
+ /// <summary>
+ /// Modify a user.
+ /// </summary>
+ /// <param name="id">The id of the user.</param>
+ /// <param name="param">The new information.</param>
+ /// <returns>The new user info.</returns>
+ /// <exception cref="ArgumentException">Thrown when some fields in <paramref name="param"/> is bad.</exception>
+ /// <exception cref="UserNotExistException">Thrown when user with given id does not exist.</exception>
+ /// <remarks>
+ /// Version will increase if password is changed.
+ /// </remarks>
+ Task<UserEntity> ModifyUserAsync(long id, ModifyUserParams? param);
+
+ /// <summary>
+ /// Try to verify the given username and password.
+ /// </summary>
+ /// <param name="username">The username of the user to verify.</param>
+ /// <param name="password">The password of the user to verify.</param>
+ /// <returns>User id.</returns>
+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="username"/> or <paramref name="password"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown when <paramref name="username"/> is of bad format or <paramref name="password"/> is empty.</exception>
+ /// <exception cref="UserNotExistException">Thrown when the user with given username does not exist.</exception>
+ /// <exception cref="BadPasswordException">Thrown when password is wrong.</exception>
+ Task<long> VerifyCredential(string username, string password);
+
+ /// <summary>
+ /// Try to change a user's password with old password.
+ /// </summary>
+ /// <param name="id">The id of user to change password of.</param>
+ /// <param name="oldPassword">Old password.</param>
+ /// <param name="newPassword">New password.</param>
+ /// <exception cref="ArgumentNullException">Thrown if <paramref name="oldPassword"/> or <paramref name="newPassword"/> is null.</exception>
+ /// <exception cref="ArgumentException">Thrown if <paramref name="oldPassword"/> or <paramref name="newPassword"/> is empty.</exception>
+ /// <exception cref="UserNotExistException">Thrown if the user with given username does not exist.</exception>
+ /// <exception cref="BadPasswordException">Thrown if the old password is wrong.</exception>
+ Task ChangePassword(long id, string oldPassword, string newPassword);
+ }
+}