diff --git a/src/Destiny.Core.Flow.API/Controllers/AssetController.cs b/src/Destiny.Core.Flow.API/Controllers/AssetController.cs index 9420e6b..502166a 100644 --- a/src/Destiny.Core.Flow.API/Controllers/AssetController.cs +++ b/src/Destiny.Core.Flow.API/Controllers/AssetController.cs @@ -12,7 +12,11 @@ namespace Destiny.Core.Flow.API.Controllers { - [Description("资产控制器")] + + /// + /// 资产管理 + /// + [Description("资产管理")] public class AssetController : CrudAdminControllerBase { diff --git a/src/Destiny.Core.Flow.API/Controllers/IdentityController.cs b/src/Destiny.Core.Flow.API/Controllers/IdentityController.cs index 224f8b9..33f952c 100644 --- a/src/Destiny.Core.Flow.API/Controllers/IdentityController.cs +++ b/src/Destiny.Core.Flow.API/Controllers/IdentityController.cs @@ -55,7 +55,6 @@ public async Task LoginAsync([FromBody] LoginDto loginDto) /// [HttpPost] [Description("更改密码")] - [NoAuthorityVerification] public async Task ChangePassword([FromBody] ChangePassInputDto dto) { diff --git a/src/Destiny.Core.Flow.API/Controllers/UserController.cs b/src/Destiny.Core.Flow.API/Controllers/UserController.cs index 3ff1a9d..794db8f 100644 --- a/src/Destiny.Core.Flow.API/Controllers/UserController.cs +++ b/src/Destiny.Core.Flow.API/Controllers/UserController.cs @@ -148,6 +148,18 @@ public async Task GetUsersAsync() { return (await _userService.GetUsersAsync()).ToAjaxResult(); + } + + /// + /// 异步重置密码 + /// + /// 用户ID + /// + [HttpGet] + [Description("异步重置密码")] + public Task ResetPasswordAsync(Guid userId) + { + return _userService.ResetPasswordAsync(userId).ToAjaxResult(); } } } diff --git a/src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.xml b/src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.xml index af4bd55..e9b39ba 100644 --- a/src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.xml +++ b/src/Destiny.Core.Flow.API/Destiny.Core.Flow.API.xml @@ -4,6 +4,11 @@ Destiny.Core.Flow.API + + + 资产管理 + + 数据审计 @@ -656,6 +661,13 @@ + + + 异步重置密码 + + 用户ID + + 文件上传 diff --git a/src/Destiny.Core.Flow.API/Startup.cs b/src/Destiny.Core.Flow.API/Startup.cs index 85b3be5..b3d9f44 100644 --- a/src/Destiny.Core.Flow.API/Startup.cs +++ b/src/Destiny.Core.Flow.API/Startup.cs @@ -25,7 +25,6 @@ public Startup(IConfiguration configuration) // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddApplication(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Destiny.Core.Flow.AspNetCore/CrudAdminControllerBaseOfModle.cs b/src/Destiny.Core.Flow.AspNetCore/CrudAdminControllerBaseOfModle.cs index 786849d..f2dde2a 100644 --- a/src/Destiny.Core.Flow.AspNetCore/CrudAdminControllerBaseOfModle.cs +++ b/src/Destiny.Core.Flow.AspNetCore/CrudAdminControllerBaseOfModle.cs @@ -176,8 +176,6 @@ public abstract class CrudAdminControllerBase { - - protected CrudAdminControllerBase(ICrudService crudServiceAsync) : base(crudServiceAsync) { diff --git a/src/Destiny.Core.Flow.AuthenticationCenter/Views/Account/Login.cshtml b/src/Destiny.Core.Flow.AuthenticationCenter/Views/Account/Login.cshtml index d1a9e46..826bb5f 100644 --- a/src/Destiny.Core.Flow.AuthenticationCenter/Views/Account/Login.cshtml +++ b/src/Destiny.Core.Flow.AuthenticationCenter/Views/Account/Login.cshtml @@ -5,7 +5,7 @@

- 欢迎使用DestinyCore系统 + 欢迎使用星睿系统

diff --git a/src/Destiny.Core.Flow.AuthenticationCenter/Views/Shared/_Layout.cshtml b/src/Destiny.Core.Flow.AuthenticationCenter/Views/Shared/_Layout.cshtml index 786c382..1c04c9b 100644 --- a/src/Destiny.Core.Flow.AuthenticationCenter/Views/Shared/_Layout.cshtml +++ b/src/Destiny.Core.Flow.AuthenticationCenter/Views/Shared/_Layout.cshtml @@ -21,7 +21,7 @@ @**@ @RenderBody() @**@ diff --git a/src/Destiny.Core.Flow.IServices/Users/IUserServices.cs b/src/Destiny.Core.Flow.IServices/Users/IUserServices.cs index bb02c30..f47e11e 100644 --- a/src/Destiny.Core.Flow.IServices/Users/IUserServices.cs +++ b/src/Destiny.Core.Flow.IServices/Users/IUserServices.cs @@ -66,5 +66,12 @@ public interface IUserServices : IScopedDependency ///
/// Task>> GetUsersToSelectListItemAsync(); + + /// + /// 重置密码 + /// + /// 用户ID + /// + Task ResetPasswordAsync(Guid userId); } } diff --git a/src/Destiny.Core.Flow.Services/Users/UserServices.cs b/src/Destiny.Core.Flow.Services/Users/UserServices.cs index 3cb9577..1720766 100644 --- a/src/Destiny.Core.Flow.Services/Users/UserServices.cs +++ b/src/Destiny.Core.Flow.Services/Users/UserServices.cs @@ -117,9 +117,9 @@ public async Task DeleteAsync(Guid id) if (user.NormalizedUserName == "ADMIN") { return OperationResponse.Error("此用户为系统超级管理员,无法删除"); - } - - // IList existRoleNames = await _userManager.GetRolesAsync(user); + } + + // IList existRoleNames = await _userManager.GetRolesAsync(user); return await _unitOfWork.UseTranAsync(async () => { var result = await _userManager.DeleteAsync(user); @@ -152,8 +152,8 @@ public async Task UpdateAsync(UserUpdateInputDto dto) var user = await _userManager.FindByIdAsync(dto.Id.ToString()); user = dto.MapTo(user); var result = await _userManager.UpdateAsync(user); - return result.ToOperationResponse("保存用户成功"); - + return result.ToOperationResponse("保存用户成功"); + } /// @@ -228,6 +228,30 @@ public async Task>> GetUsersToSele Selected = false, }).ToListAsync(); return new OperationResponse>("得到数据成功", users, OperationResponseType.Success); - } + } + + /// + /// 重置密码 + /// + /// + /// + public async Task ResetPasswordAsync(Guid userId) + { + userId.NotEmpty(nameof(userId)); + //是否超级用户 + var isSuperUser = _principal.Identity.GetUserName("name")?.Equals("Admin", StringComparison.OrdinalIgnoreCase); + if (isSuperUser == false) + { + return OperationResponse.Error("不是超过用户无法重置密码"); + } + var password = "123456"; + var user = await _userManager.FindByIdAsync(userId.AsTo()); + //重置此用户令牌 + var token = await _userManager.GeneratePasswordResetTokenAsync(user); + //更新密码 123456 系统默认超级密码 + var result = await _userManager.ResetPasswordAsync(user, token, password); + return result.ToOperationResponse($"重置密码成功,密码为【{password}】"); + + } } } diff --git a/src/Destiny.Core.Flow.Shared/CrudServiceAsync.cs b/src/Destiny.Core.Flow.Shared/CrudServiceAsync.cs index 60729ad..a5ca0e0 100644 --- a/src/Destiny.Core.Flow.Shared/CrudServiceAsync.cs +++ b/src/Destiny.Core.Flow.Shared/CrudServiceAsync.cs @@ -41,8 +41,9 @@ public CrudServiceAsync(IServiceProvider serviceProvider, IRepository CreateAsync(IInputDto inputDto) { - inputDto.NotNull(nameof(inputDto)); + + inputDto.NotNull(nameof(inputDto)); return await this.Repository.InsertAsync(inputDto,this.CreateCheckAsync); } @@ -101,9 +102,21 @@ protected virtual Task UpdateCheckAsync(IInputDto inputDto, IEntity entity) public virtual Task> GetPageAsync(PageRequest request) { request.NotNull(nameof(request)); + request = GetPageRequest(request); return this.Entities.ToPageAsync(request); } + /// + /// 得到分页请求 + /// + /// + /// + protected virtual PageRequest GetPageRequest(PageRequest request) + { + + return request; + } + /// /// 异步根据键加载数据 /// diff --git a/test/Destiny.Core.AspNetMvc.Test/Controller/User_TestController_Tests.cs b/test/Destiny.Core.AspNetMvc.Test/Controller/User_TestController_Tests.cs index 84b90ca..6b91e48 100644 --- a/test/Destiny.Core.AspNetMvc.Test/Controller/User_TestController_Tests.cs +++ b/test/Destiny.Core.AspNetMvc.Test/Controller/User_TestController_Tests.cs @@ -13,8 +13,8 @@ namespace Destiny.Core.AspNetMvc.Test.Controller { public class User_TestController_Tests : AspNetMvcTestBase { - - + //主题+期望结果+参数 + //被测试方法全名_期望的结果_给予的条件 [Fact] public async Task Should_Trigger_User_TestController_CreateAsync() {