From d6ffbd97603decf4d3922a697414f4f7cec30434 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 28 三月 2025 11:13:26 +0800
Subject: [PATCH] fix:获取用户是否为管理员返回值优化

---
 LifePayment/LifePayment.Application/User/UserRoleService.cs |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/LifePayment/LifePayment.Application/User/UserRoleService.cs b/LifePayment/LifePayment.Application/User/UserRoleService.cs
index be79492..e8239f5 100644
--- a/LifePayment/LifePayment.Application/User/UserRoleService.cs
+++ b/LifePayment/LifePayment.Application/User/UserRoleService.cs
@@ -103,10 +103,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
                 });
             }
@@ -221,5 +227,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