zhengyuxuan
2025-03-19 a979b4ac22ddaba5012d32bbce2f1e44144e13d3
fix:新增重置密码接口
6个文件已修改
90 ■■■■ 已修改文件
LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application.Contracts/User/IUserRoleService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Application/User/UserRoleService.cs 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LifePayment/LifePayment.HttpApi/LifePay/UserRoleController.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
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);
LifePayment/LifePayment.Application/User/UserRoleService.cs
@@ -1,6 +1,7 @@
using 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);
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>
            删除后台管理账户
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>
            手机号
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>