From 6ae97d768948e197a89492239441feca04c1dbb9 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期一, 07 四月 2025 17:16:02 +0800
Subject: [PATCH] fix:bug修复

---
 LifePayment/LifePayment.Application/User/UserRoleService.cs |   62 ++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/LifePayment/LifePayment.Application/User/UserRoleService.cs b/LifePayment/LifePayment.Application/User/UserRoleService.cs
index 97fbd78..decdddd 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)
@@ -53,10 +59,11 @@
                             Name = r.Name,
                         },
                 Channles = from uc in u.UserChannle
-                           from c in _channleRepository.Where(s => s.Id == uc.ChannleId)
+                           from c in _channleRepository.Where(s => s.ChannlesNum == uc.ChannleId)
                         select new UserChannleDto
                         {
                             Id = c.Id,
+                            ChannlesNum = c.ChannlesNum,
                             Name = c.ChannlesName,
                         },
                 Remark = u.Remark,
@@ -97,10 +104,16 @@
             List<UserChannle> userChannles = new List<UserChannle>();
             foreach (var item in input.ChannlesId)
             {
+                var channleNum = item;
+                if (IsGuid(channleNum))
+                {
+                    channleNum = await _channleRepository.Where(x => x.Id == Guid.Parse(item)).Select(s => s.ChannlesNum).FirstOrDefaultAsync();
+                }
+
                 userChannles.Add(new UserChannle()
                 {
                     Id = Guid.NewGuid(),
-                    ChannleId = item,
+                    ChannleId = channleNum,
                     UserId = entity.Id
                 });
             }
@@ -108,6 +121,29 @@
             await _userChannleRep.InsertManyAsync(userChannles);
 
             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)
@@ -124,8 +160,16 @@
 
         public async Task<Guid> CreateRole(CreateOrUpdateRoleInput input)
         {
-            var entity = ObjectMapper.Map<CreateOrUpdateRoleInput, Role>(input);
-            return await _roleRepository.InsertAndGetIdAsync(entity);
+            Role role = new Role()
+            {
+                Id = input.Id,
+                Name = input.Name,
+                Sequence = input.Sequence,
+                DepartmentId = input.DepartmentId,
+                DataRange = input.DataRange,
+                Remark = input.Remark
+            };
+            return await _roleRepository.InsertAndGetIdAsync(role);
         }
 
         public async Task<PageOutput<RoleInfo>> GetRoles(GetRolesInput input)
@@ -193,5 +237,11 @@
             await _roleRepository.DeleteAsync(id);
             return Constant.SUCCESS;
         }
+
+        private bool IsGuid(string input)
+        {
+            Guid guidOutput;
+            return Guid.TryParse(input, out guidOutput);
+        }
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.1