From f4e84a98facb28bbfc63343c81095a9787812e27 Mon Sep 17 00:00:00 2001
From: 南骏 池 <chiffly@163.com>
Date: 星期六, 30 八月 2025 16:25:51 +0800
Subject: [PATCH] 1.PDA分组织

---
 service/base/LoginService.cs |  110 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 87 insertions(+), 23 deletions(-)

diff --git a/service/base/LoginService.cs b/service/base/LoginService.cs
index c4b5a68..e3e9081 100644
--- a/service/base/LoginService.cs
+++ b/service/base/LoginService.cs
@@ -2,39 +2,80 @@
 using NewPdaSqlServer.DB;
 using NewPdaSqlServer.entity;
 using NewPdaSqlServer.util;
+using SqlSugar;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
 
 namespace NewPdaSqlServer.service.@base;
 
 public class LoginService : RepositoryNoEntity
 {
-    public SysUser login(string name, string pwd)
+    public dynamic login(string name, string pwd)
     {
+
         var strPass = UtilityHelper.MD5Encrypt32(pwd);
-        var sysUser = Db.Queryable<SysUser>()
-            .Where(s => s.Account == name
-                        && s.Password == strPass).First();
+        //var sysUser = Db.Queryable<SysUser>()
+        //    .Where(s => s.Account == name
+        //                && s.Password == strPass).First();
 
-        if (sysUser == null) throw new Exception("鐢ㄦ埛涓嶅瓨鍦�");
 
-        var db_password = sysUser.Password;
-        if (!strPass.Equals(db_password)) throw new Exception("鐢ㄦ埛鍚嶆垨鑰呭瘑鐮侀敊璇�");
 
-        return sysUser;
+
+        var parameters = new[]
+        {
+        new SugarParameter("@pi_account", name),
+        new SugarParameter("@pi_password", strPass),
+        new SugarParameter("@inP1", null),
+        new SugarParameter("@inP2", null),
+        new SugarParameter("@inP3", null)
+    };
+
+        try
+        {
+            var sysUser = Db.Ado.SqlQuery<dynamic>("EXEC prc_pda_login_selUserOrgInfo @pi_account,@pi_password,@inP1,@inP2,@inP3", parameters).First();
+
+            if (sysUser == null) throw new Exception("鐢ㄦ埛涓嶅瓨鍦�");
+
+            var db_password = sysUser.Password;
+            if (!strPass.Equals(db_password)) throw new Exception("鐢ㄦ埛鍚嶆垨鑰呭瘑鐮侀敊璇�");
+            return sysUser;
+        }
+        catch (Exception ex)
+        {
+            // 淇濈暀鍘熸湁寮傚父澶勭悊閫昏緫
+            throw new Exception($"{ex.Message}");
+        }
+
     }
 
     public List<dynamic> getUserMenu(string name)
     {
-        var sql = "";
-
-        var pageViewList = Db.Queryable<MesSysPageview>()
-            .Where(s => s.PageStatus == true)
-            .OrderBy(s => s.PageIdx)
-            .ToList();
-
-        var result = new List<dynamic>();
-
+        var pageViewList = new List<MesSysPageview>();
         if ("admin".Equals(name))
         {
+            pageViewList = Db.Queryable<MesSysPageview>()
+           .Where(s => s.PageStatus == true)
+           .OrderBy(s => s.PageIdx)
+           .ToList();
+        }
+        else
+        {
+            string sql = string.Format(@"SELECT A.* FROM MES_SYS_PAGEVIEW A
+         LEFT JOIN SYS_USER_BIND B ON CAST(A.guid AS VARCHAR(100)) = B.aboutGuid
+         LEFT JOIN SYS_USER C ON C.GUID = B.userGuid
+        WHERE C.ACCOUNT = '{0}'", name);
+            pageViewList = Db.Ado.SqlQuery<MesSysPageview>(sql);
+        }
+
+        //if(pageViewList.Count < 0)
+        //{
+        //    throw new Exception("璇ョ敤鎴锋病鏈夋潈闄愯闂�");
+        //}
+
+        try
+        {
+            var result = new List<dynamic>();
+
+
             var groupedPageViews = pageViewList
                 .GroupBy(p =>
                     string.IsNullOrEmpty(p.PageGroup) ? "鏈垎缁�" : p.PageGroup)
@@ -49,15 +90,21 @@
                 foreach (var pageView in group)
                 {
                     var mesFile = Db.Queryable<MesFile>()
-                        .Where(s => s.ParentGuid == pageView.Guid).First();
+                        .Where(s => s.ParentGuid == pageView.Guid)
+                        .OrderByDescending(s => s.CreateDate)
+                        .First();
+
+                    var icoimg = "";
+                    if (mesFile != null)
+                        icoimg = "http://192.168.1.145:81/upload/" +
+                                 mesFile.UrlPath;
 
                     groupObj.child.Add(new MesSysPageview
                     {
                         Guid = pageView.Guid,
                         PageView = pageView.PageView,
                         Path = pageView.Path,
-                        Icoimg = "http://192.168.1.145:81/upload/" +
-                                 mesFile.UrlPath,
+                        Icoimg = icoimg,
                         PageGroup = pageView.PageGroup,
                         PageIdx = pageView.PageIdx,
                         PageStatus = pageView.PageStatus
@@ -68,10 +115,12 @@
             }
 
             return result;
+
         }
-
-
-        return null;
+        catch(Exception e)
+        {
+            throw new Exception(e.Message);
+        }
     }
 
     public int resetPassword(string newPwd, string name, string pwd)
@@ -84,4 +133,19 @@
             .Where(s => s.Account == name)
             .ExecuteCommand();
     }
+
+
+    public List<dynamic> getUserInfo(string userGuid)
+    {
+
+        //string sql = string.Format(@"SELECT A.* FROM MES_SYS_PAGEVIEW A
+        // LEFT JOIN SYS_USER_BIND B ON A.guid = B.aboutGuid
+        // LEFT JOIN SYS_USER C ON C.GUID = B.userGuid
+        //WHERE C.ACCOUNT = '{0}'", userGuid);
+        //var sysUser = Db.Ado.SqlQuery<dynamic>(sql);
+
+
+        //return sysUser;
+        return null;
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3