平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

325 lines
8.9 KiB

  1. //
  2. namespace SafeCampus.System;
  3. /// <summary>
  4. /// 用户服务
  5. /// </summary>
  6. public interface ISysUserService : ITransient
  7. {
  8. #region 查询
  9. /// <summary>
  10. /// 根据用户ID获取按钮ID集合
  11. /// </summary>
  12. /// <param name="userId"></param>
  13. /// <returns></returns>
  14. Task<List<string>> GetButtonCodeList(long userId);
  15. /// <summary>
  16. /// 根据账号获取用户信息
  17. /// </summary>
  18. /// <param name="account">用户名</param>
  19. /// <param name="tenantId">租户ID</param>
  20. /// <returns>用户信息</returns>
  21. Task<SysUser> GetUserByAccount(string account, long? tenantId = null);
  22. /// <summary>
  23. /// 根据用户ID和机构ID获取角色权限
  24. /// </summary>
  25. /// <param name="userId"></param>
  26. /// <param name="orgId"></param>
  27. /// <returns></returns>
  28. Task<List<DataScope>> GetPermissionListByUserId(long userId, long orgId);
  29. /// <summary>
  30. /// 根据手机号获取用户账号
  31. /// </summary>
  32. /// <param name="phone">手机号</param>
  33. /// <param name="tenantId">租户ID</param>
  34. /// <returns>用户账号名称</returns>
  35. Task<long> GetIdByPhone(string phone, long? tenantId = null);
  36. /// <summary>
  37. /// 用户选择器
  38. /// </summary>
  39. /// <param name="input">查询参数</param>
  40. /// <returns></returns>
  41. Task<SqlSugarPagedList<UserSelectorOutPut>> Selector(UserSelectorInput input);
  42. /// <summary>
  43. /// 用户分页查询
  44. /// </summary>
  45. /// <param name="input">查询参数</param>
  46. /// <returns>用户分页列表</returns>
  47. Task<SqlSugarPagedList<SysUser>> Page(UserPageInput input);
  48. /// <summary>
  49. /// 用户列表
  50. /// </summary>
  51. /// <param name="input">查询</param>
  52. /// <returns></returns>
  53. Task<List<SysUser>> List(UserPageInput input);
  54. /// <summary>
  55. /// 根据用户Id获取用户信息
  56. /// </summary>
  57. /// <param name="userId">用户ID</param>
  58. /// <returns>用户信息</returns>
  59. Task<SysUser> GetUserById(long userId);
  60. /// <summary>
  61. /// 根据用户Id获取用户信息
  62. /// </summary>
  63. /// <param name="userId">用户ID</param>
  64. /// <typeparam name="T">转换的实体</typeparam>
  65. /// <returns></returns>
  66. Task<T> GetUserById<T>(long userId);
  67. /// <summary>
  68. /// 根据用户账号获取用户ID
  69. /// </summary>
  70. /// <param name="account">用户账号</param>
  71. /// <param name="tenantId">租户id</param>
  72. /// <returns></returns>
  73. Task<long> GetIdByAccount(string account, long? tenantId = null);
  74. /// <summary>
  75. /// 根据用户手机获取用户信息
  76. /// </summary>
  77. /// <param name="phone">手机号</param>
  78. /// <param name="tenantId">租户Id</param>
  79. /// <returns>用户信息</returns>
  80. Task<SysUser> GetUserByPhone(string phone, long? tenantId = null);
  81. /// <summary>
  82. /// 获取用户拥有角色
  83. /// </summary>
  84. /// <param name="input">用户ID</param>
  85. /// <returns></returns>
  86. Task<List<RoleSelectorOutPut>> OwnRole(BaseIdInput input);
  87. /// <summary>
  88. /// 获取用户拥有的资源
  89. /// </summary>
  90. /// <param name="input">用户id</param>
  91. /// <returns>资源列表</returns>
  92. Task<RoleOwnResourceOutput> OwnResource(BaseIdInput input);
  93. /// <summary>
  94. /// 获取用户拥有的权限
  95. /// </summary>
  96. /// <param name="input">用户id</param>
  97. /// <returns>权限列表</returns>
  98. Task<RoleOwnPermissionOutput> OwnPermission(BaseIdInput input);
  99. /// <summary>
  100. /// 用户权限树选择
  101. /// </summary>
  102. /// <param name="input">用户id</param>
  103. /// <returns>权限列表</returns>
  104. Task<List<string>> UserPermissionTreeSelector(BaseIdInput input);
  105. /// <summary>
  106. /// 根据id集合获取用户集合
  107. /// </summary>
  108. /// <param name="input">Id集合</param>
  109. /// <returns></returns>
  110. Task<List<UserSelectorOutPut>> GetUserListByIdList(IdListInput input);
  111. /// <summary>
  112. /// 用户详情
  113. /// </summary>
  114. /// <param name="input"></param>
  115. /// <returns></returns>
  116. Task<SysUser> Detail(BaseIdInput input);
  117. /// <summary>
  118. /// 获取用户头像
  119. /// </summary>
  120. /// <param name="userId">用户id</param>
  121. /// <returns>base64头像</returns>
  122. Task<string> GetUserAvatar(long userId);
  123. #endregion 查询
  124. #region 数据范围相关
  125. /// <summary>
  126. /// 获取当前API用户的数据范围
  127. /// null:代表拥有全部数据权限
  128. /// [xx,xx]:代表拥有部分机构的权限
  129. /// []:代表仅自己权限
  130. /// </summary>
  131. /// <returns>机构列表</returns>
  132. Task<List<long>?> GetLoginUserApiDataScope();
  133. /// <summary>
  134. /// 检查用户是否有机构的数据权限
  135. /// </summary>
  136. /// <param name="orgId">机构id</param>
  137. /// <param name="createUerId">创建者id</param>
  138. /// <param name="errMsg">错误提示:不为空则直接抛出异常</param>
  139. /// <returns>是否有权限</returns>
  140. Task<bool> CheckApiDataScope(long? orgId, long? createUerId, string errMsg = "");
  141. /// <summary>
  142. /// 检查用户是否有机构的数据权限
  143. /// </summary>
  144. /// <param name="orgIds">机构id列表</param>
  145. /// <param name="createUerIds">创建者id列表</param>
  146. /// <param name="errMsg">错误提示:不为空则直接抛出异常</param>
  147. /// <returns></returns>
  148. Task<bool> CheckApiDataScope(List<long> orgIds, List<long> createUerIds, string errMsg = "");
  149. #endregion
  150. #region 新增
  151. /// <summary>
  152. /// 添加用户
  153. /// </summary>
  154. /// <param name="input">添加参数</param>
  155. /// <returns></returns>
  156. Task Add(UserAddInput input);
  157. #endregion 新增
  158. #region 编辑
  159. /// <summary>
  160. /// 编辑
  161. /// </summary>
  162. /// <param name="input">编辑参数</param>
  163. /// <returns></returns>
  164. Task Edit(UserEditInput input);
  165. /// <summary>
  166. /// 启用用户
  167. /// </summary>
  168. /// <param name="input">用户Id</param>
  169. /// <returns></returns>
  170. Task EnableUser(BaseIdInput input);
  171. /// <summary>
  172. /// 禁用用户
  173. /// </summary>
  174. /// <param name="input">用户Id</param>
  175. /// <returns></returns>
  176. Task DisableUser(BaseIdInput input);
  177. /// <summary>
  178. /// 重置密码
  179. /// </summary>
  180. /// <param name="input">用户Id</param>
  181. /// <returns></returns>
  182. Task ResetPassword(BaseIdInput input);
  183. /// <summary>
  184. /// 给用户授权角色
  185. /// </summary>
  186. /// <param name="input">授权参数</param>
  187. /// <returns></returns>
  188. Task GrantRole(UserGrantRoleInput input);
  189. /// <summary>
  190. /// 给用户授权资源
  191. /// </summary>
  192. /// <param name="input">授权参数</param>
  193. /// <returns></returns>
  194. Task GrantResource(UserGrantResourceInput input);
  195. /// <summary>
  196. /// 给用户授权权限
  197. /// </summary>
  198. /// <param name="input"></param>
  199. /// <returns></returns>
  200. Task GrantPermission(GrantPermissionInput input);
  201. /// <summary>
  202. /// 设置用户默认值
  203. /// </summary>
  204. /// <param name="sysUsers"></param>
  205. /// <returns></returns>
  206. Task SetUserDefault(List<SysUser> sysUsers);
  207. /// <summary>
  208. /// 批量编辑
  209. /// </summary>
  210. /// <param name="input">批量编辑信息</param>
  211. /// <returns></returns>
  212. Task Edits(BatchEditInput input);
  213. #endregion 编辑
  214. #region 删除
  215. /// <summary>
  216. /// 删除用户
  217. /// </summary>
  218. /// <param name="input">Id列表</param>
  219. /// <returns></returns>
  220. Task Delete(BaseIdListInput input);
  221. /// <summary>
  222. /// 从redis中删除用户信息
  223. /// </summary>
  224. /// <param name="ids">用户ID列表</param>
  225. void DeleteUserFromRedis(List<long> ids);
  226. /// <summary>
  227. /// 从redis中删除用户信息
  228. /// </summary>
  229. /// <param name="userId">用户ID</param>
  230. void DeleteUserFromRedis(long userId);
  231. #endregion 删除
  232. #region 导入导出
  233. /// <summary>
  234. /// 导出用户
  235. /// </summary>
  236. /// <param name="input"></param>
  237. /// <returns></returns>
  238. Task<FileStreamResult> Export(UserPageInput input);
  239. /// <summary>
  240. /// 导入模板下载
  241. /// </summary>
  242. /// <returns>模板</returns>
  243. Task<FileStreamResult> Template();
  244. /// <summary>
  245. /// 导入预览
  246. /// </summary>
  247. /// <param name="input">预览参数</param>
  248. /// <returns>预览结果</returns>
  249. Task<ImportPreviewOutput<SysUserImportInput>> Preview(ImportPreviewInput input);
  250. /// <summary>
  251. /// 用户导入
  252. /// </summary>
  253. /// <param name="input"></param>
  254. /// <returns></returns>
  255. Task<ImportResultOutPut<SysUserImportInput>> Import(ImportResultInput<SysUserImportInput> input);
  256. /// <summary>
  257. /// 检查导入数据
  258. /// </summary>
  259. /// <param name="data">数据</param>
  260. /// <param name="clearError">是否初始化错误</param>
  261. /// <returns></returns>
  262. Task<List<T>> CheckImport<T>(List<T> data, bool clearError = false) where T : SysUserImportInput;
  263. #endregion 导入导出
  264. }