From 318d349fc009011a135dbce5a25e392b492c0718 Mon Sep 17 00:00:00 2001 From: yzh <snbbt@21cn.com> Date: 星期五, 20 五月 2022 16:49:20 +0800 Subject: [PATCH] 客户分配个性产品 系统数据权限隔离 --- web/web/GwClient.ashx | 74 ++++++++++++++++++++++++++++++++++-- 1 files changed, 69 insertions(+), 5 deletions(-) diff --git a/web/web/GwClient.ashx b/web/web/GwClient.ashx index 181efcc..667d11a 100644 --- a/web/web/GwClient.ashx +++ b/web/web/GwClient.ashx @@ -1,5 +1,6 @@ 锘�<%@ WebHandler Language="C#" Class="GwClientHandler" %> using System; +using System.Linq; using System.Web; using Dao; using Model; @@ -9,6 +10,7 @@ using System.Text; using System.Text.RegularExpressions; using System.IO; +using Newtonsoft.Json; @@ -19,9 +21,17 @@ private UserDao _SysUserDao = new UserDao(); private List<SysUser> _SysUserList; + private int _userId = -1; + private int _userType = -1; + private string _account = ""; + public override JsonPageResult ProcessRequestInternal(PageContext<Model.SysUser> context) { string action = context.GetString("action"); + + _userId = context.SessionObject.UserID; + _userType = context.SessionObject.UserType; + _account = context.SessionObject.Account; switch (action) { @@ -53,6 +63,9 @@ case "updateBlack": return UpdateBlack(context); + //鎵归噺鍒嗛厤瀹㈡埛鐨勪釜鎬т骇鍝� + case "batchUpdateClientProduct": + return BatchUpdateClientProduct(context); default: throw new Exception("Invalid Action=" + action); @@ -82,10 +95,12 @@ int pageSize = context.GetInt("pageSize", 20); string serverIp = ConfigurationManager.AppSettings["serverIp"]; string clientPort = ConfigurationManager.AppSettings["clientPort"]; + string str = ""; using (GwClientDao dao = new GwClientDao()) { - var list = dao.LoadInfoList(out recordCount, pageIndex, pageSize, ClientID, ClientName, Telephone, Agent, Company, Salesman, ProductId); + string permissionsSQL = dao.GetClientPermissions(_userId, _userType, null); + var list = dao.LoadInfoList(out recordCount, pageIndex, pageSize, ClientID, ClientName, Telephone, Agent, Company, Salesman, ProductId, permissionsSQL); if (list != null && list.Count > 0) { @@ -99,7 +114,7 @@ //edit:yangzh by 20220511 //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Top_up_Amount_Total + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>"; //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>"; - str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + SysUserName(string.IsNullOrEmpty(item.Salesman)? 0: int.Parse(item.Salesman) ) + "</td><td>" + Certification_StatusResult + "</td>"; + str += @"<tr ><td rowspan='1' ><input type='checkbox' name='checkbox' value='" + item.ClientID + "'/></td><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + SysUserName(string.IsNullOrEmpty(item.Salesman)? 0: int.Parse(item.Salesman) ) + "</td><td>" + Certification_StatusResult + "</td>"; str += @"<td>"; @@ -128,7 +143,7 @@ } else { - str += @"<tr><td colspan=""9"">鏆傛棤淇℃伅</td></tr>"; + str += @"<tr><td colspan=""10"">鏆傛棤淇℃伅</td></tr>"; } } @@ -334,13 +349,13 @@ client.Company = company; //client.Password = password; client.Password = savePassword; - + client.ClientName = clientName; client.Address = address; client.Remark = remark; client.Telephone = telephone; client.Agent = agent; - + client.CustomerManager = customerManager; client.Salesman = salesman; client.SupportStaff = supportStaff; @@ -534,6 +549,55 @@ return new JsonPageResult(true, "鍒涘缓璐︽埛鎴愬姛锛�"); } + //鍒嗛厤瀹㈡埛鐨勪釜鎬т骇鍝� + private JsonPageResult BatchUpdateClientProduct(PageContext<SysUser> context) + { + string productId = context.GetString("productId"); + string idArray = context.GetString("idArray"); + if (string.IsNullOrEmpty(productId)) + { + + throw new ArgumentException("涓�т骇鍝佷笉鑳戒负绌猴紝璇烽�夋嫨锛�"); + } + + Model.GwProduct gwProduct = new GwProductDao().Get(productId); + if (gwProduct == null) + { + throw new ArgumentException("鎸囧畾鐨勪釜鎬т骇鍝佷笉瀛樺湪锛岃閲嶆柊閫夋嫨锛�"); + } + string clientIds = gwProduct.ClientIds; + + List<string> tmpList = new List<string>(); + if(!string.IsNullOrEmpty(clientIds)) + { //瀛楃涓茶浆鏁扮粍锛屽啀鏁扮粍鍚堝苟 + tmpList.AddRange( clientIds.Split(',') ); + } + //鏁扮粍鍚堝苟 + tmpList.AddRange( JsonConvert.DeserializeObject<string[]>(context.GetString("idArray")) ); + + //鏁扮粍鍘婚噸 + string[] tmpArray = DelRepeatData(tmpList.ToArray() ); + clientIds = string.Join(",", tmpArray) ; + + if (!string.IsNullOrEmpty(clientIds)) + { + new GwProductDao().UpdateClientIds(clientIds, productId); + } + + + return new JsonPageResult(true, (object)"鎵归噺鍒嗛厤瀹㈡埛涓�т骇鍝佹垚鍔燂紒"); + } + + /// <summary> + /// 绉婚櫎鏁扮粍涓噸澶嶆暟鎹� + /// </summary> + /// <param name="array">闇�瑕侀櫎閲嶇殑鏁扮粍</param> + /// <returns>涓嶉噸澶嶆暟缁�</returns> + public static string[] DelRepeatData(string[] array) + { + return array.GroupBy(p => p).Select(p => p.Key).ToArray(); + } + //鑾峰彇绠$悊绔处鎴峰垪琛� -- Gitblit v1.9.1