From a979b4ac22ddaba5012d32bbce2f1e44144e13d3 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期三, 19 三月 2025 17:32:15 +0800
Subject: [PATCH] fix:新增重置密码接口
---
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 17 ++++++--
LifePayment/LifePayment.Application/User/UserRoleService.cs | 30 ++++++++++++++
LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs | 15 +++++--
LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs | 14 ++++++
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml | 7 +++
LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs | 7 +++
6 files changed, 78 insertions(+), 12 deletions(-)
diff --git a/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs b/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
index 3f7d519..89d0e22 100644
--- a/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
@@ -12,11 +12,6 @@
public string Name { get; set; }
/// <summary>
- /// 瀵嗙爜
- /// </summary>
- public string Password { get; set; }
-
- /// <summary>
/// 鎵嬫満鍙�
/// </summary>
public string PhoneNumber { get; set; }
@@ -85,6 +80,16 @@
public string Remark { get; set; }
}
+ /// <summary>
+ /// 閲嶇疆瀵嗙爜鍩虹杈撳叆鍙傛暟
+ /// </summary>
+ public class ResetPasswordBaseInput
+ {
+ public Guid UserId { get; set; }
+
+ public string? Password { get; set; }
+ }
+
public class UpdateBackClientUserInput : CreateBackClientUserInput
{
/// <summary>
diff --git a/LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs b/LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs
index d6c047b..cf16ff0 100644
--- a/LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs
@@ -11,6 +11,13 @@
Task<int> UpdateBackClientUser(UpdateBackClientUserInput input);
+ /// <summary>
+ /// 閲嶇疆瀵嗙爜
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ Task ResetPassword(ResetPasswordBaseInput input);
+
Task<int> DeleteBackClientUser(Guid id);
Task<Guid> CreateRole(CreateOrUpdateRoleInput input);
diff --git a/LifePayment/LifePayment.Application/User/UserRoleService.cs b/LifePayment/LifePayment.Application/User/UserRoleService.cs
index 3a0aad5..be79492 100644
--- a/LifePayment/LifePayment.Application/User/UserRoleService.cs
+++ b/LifePayment/LifePayment.Application/User/UserRoleService.cs
@@ -1,6 +1,7 @@
锘縰sing LifePayment.Application.Contracts;
using LifePayment.Domain;
using LifePayment.Domain.Models;
+using LifePayment.Domain.Shared;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
@@ -9,8 +10,10 @@
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Identity;
using Z.EntityFramework.Plus;
using ZeroD.Util;
+using static LifePayment.Domain.Shared.LifePaymentConstant;
namespace HumanResourcesServices.Application
{
@@ -21,19 +24,22 @@
private readonly IRepository<LifePayChannles, Guid> _channleRepository;
private readonly IRepository<UserRole, Guid> _userRoleRep;
private readonly IRepository<UserChannle, Guid> _userChannleRep;
+ private readonly IIdentityUserAppService _identityUserService;
public UserRoleService(
IRepository<User, Guid> userRepository,
IRepository<Role, Guid> roleRepository,
IRepository<LifePayChannles, Guid> channleRepository,
IRepository<UserRole, Guid> userRoleRep,
- IRepository<UserChannle, Guid> userChannleRep)
+ IRepository<UserChannle, Guid> userChannleRep,
+ IIdentityUserAppService identityUserService)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
_channleRepository = channleRepository;
_userRoleRep = userRoleRep;
_userChannleRep = userChannleRep;
+ _identityUserService = identityUserService;
}
public async Task<PageOutput<UserDto>> GetBackClientUsers(GetBackClientUsersInput input)
@@ -110,6 +116,28 @@
return Constant.SUCCESS;
}
+ /// <summary>
+ /// 閲嶇疆瀵嗙爜
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ public async Task ResetPassword(ResetPasswordBaseInput input)
+ {
+ var user = await _userRepository.FirstOrDefaultAsync(x => x.Id == input.UserId);
+ CheckExtensions.IfTrueThrowUserFriendlyException(user == null, CustomeErrorMessage.IsNoExistUser);
+ CheckExtensions.IfTrueThrowUserFriendlyException(string.IsNullOrEmpty(input.Password), "璇疯緭鍏ュ瘑鐮�");
+ var identiResetInput = new ResetPassWordInput
+ {
+ UserId = input.UserId,
+ Name = user.Name,
+ UserName = user.UserName,
+ Password = input.Password,
+ PhoneNumber = user.PhoneNumber
+ };
+ var result = await _identityUserService.ResetPassword(identiResetInput);
+ CheckExtensions.IfTrueThrowUserFriendlyException(result != Constant.SUCCESS,
+ CustomeErrorMessage.ResetPasswordFail);
+ }
public async Task<int> DeleteBackClientUser(Guid id)
{
var entity = await _userRepository.FirstOrDefaultAsync(s => s.Id == id && s.ClientId == Constant.ClientType.Back);
diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
index 676a9e4..d63ca45 100644
--- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -350,6 +350,13 @@
<param name="input"></param>
<returns></returns>
</member>
+ <member name="M:LifePayment.HttpApi.UserRoleController.ResetUserPassword(LifePayment.Application.Contracts.ResetPasswordBaseInput)">
+ <summary>
+ 閲嶇疆瀵嗙爜
+ </summary>
+ <param name="input"></param>
+ <returns></returns>
+ </member>
<member name="M:LifePayment.HttpApi.UserRoleController.DeleteBackClientUser(System.Guid)">
<summary>
鍒犻櫎鍚庡彴绠$悊璐︽埛
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 3ccf60b..0dad992 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -1466,11 +1466,6 @@
鍚嶇О
</summary>
</member>
- <member name="P:LifePayment.Application.Contracts.CreateBackClientUserInput.Password">
- <summary>
- 瀵嗙爜
- </summary>
- </member>
<member name="P:LifePayment.Application.Contracts.CreateBackClientUserInput.PhoneNumber">
<summary>
鎵嬫満鍙�
@@ -1529,6 +1524,11 @@
<member name="P:LifePayment.Application.Contracts.CreateBaseRoleInput.Remark">
<summary>
澶囨敞
+ </summary>
+ </member>
+ <member name="T:LifePayment.Application.Contracts.ResetPasswordBaseInput">
+ <summary>
+ 閲嶇疆瀵嗙爜鍩虹杈撳叆鍙傛暟
</summary>
</member>
<member name="P:LifePayment.Application.Contracts.UpdateBackClientUserInput.Id">
@@ -1680,6 +1680,13 @@
<returns></returns>
<exception cref="T:Volo.Abp.UserFriendlyException"></exception>
</member>
+ <member name="M:LifePayment.Application.Contracts.IUserRoleService.ResetPassword(LifePayment.Application.Contracts.ResetPasswordBaseInput)">
+ <summary>
+ 閲嶇疆瀵嗙爜
+ </summary>
+ <param name="input"></param>
+ <returns></returns>
+ </member>
<member name="P:LifePayment.Application.Contracts.LifePayPhoneMesssageCodeLoginInput.PhoneNumber">
<summary>
鎵嬫満鍙�
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs b/LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs
index b1413ec..2add6da 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs
@@ -73,12 +73,24 @@
PhoneNumber = input.PhoneNumber,
UserName = input.UserName,
RoleNames = input.RoleNames,
- Password = input.Password,
});
return await _userRoleService.UpdateBackClientUser(input);
}
/// <summary>
+ /// 閲嶇疆瀵嗙爜
+ /// </summary>
+ /// <param name="input"></param>
+ /// <returns></returns>
+ [HttpPost]
+ public virtual async Task<int> ResetUserPassword(ResetPasswordBaseInput input)
+ {
+ await _userRoleService.ResetPassword(input);
+
+ return Constant.SUCCESS;
+ }
+
+ /// <summary>
/// 鍒犻櫎鍚庡彴绠$悊璐︽埛
/// </summary>
/// <param name="id">鐢ㄦ埛Id</param>
--
Gitblit v1.9.1