From 554cb4d840d2bd2a8c8b925d6e4242a949e88f24 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期四, 16 六月 2022 21:13:54 +0800
Subject: [PATCH] 导入接口接口定义

---
 VueWebApi/Controllers/BasicSettingController.cs |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 93 insertions(+), 0 deletions(-)

diff --git a/VueWebApi/Controllers/BasicSettingController.cs b/VueWebApi/Controllers/BasicSettingController.cs
index f5441e8..5743b48 100644
--- a/VueWebApi/Controllers/BasicSettingController.cs
+++ b/VueWebApi/Controllers/BasicSettingController.cs
@@ -2,6 +2,7 @@
 using Newtonsoft.Json.Linq;
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Net;
 using System.Net.Http;
@@ -96,6 +97,7 @@
             return TJson.toJson(mes);
         }
         #endregion
+
 
 
         #region[鐢ㄦ埛娓呭崟鏌ヨ]
@@ -206,6 +208,64 @@
             //objs = Serializer.Deserialize<List<RoleUserSubmit>>(json);
             mes= BasicSettingBLL.SaveUserAssoctRole(usercode, json);
             return TJson.toJson(mes);
+        }
+        #endregion
+
+        #region[鐢ㄦ埛娓呭崟瀵煎叆]
+        public HttpResponseMessage ImportUserExcel(HttpPostedFileBase files)
+        {
+            string savePath;
+            if (files == null || files.ContentLength <= 0)
+            {
+                mes.code = "300";
+                mes.Message = "涓婁紶鏂囦欢鍐呭涓嶈兘涓虹┖!";
+            }
+            else
+            {
+                var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //鐧诲綍鐢ㄦ埛鍚�
+                string filename = Path.GetFileName(files.FileName);
+                int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+                string fileEx = System.IO.Path.GetExtension(filename);//鑾峰彇涓婁紶鏂囦欢鐨勬墿灞曞悕
+                int Maxsize = 4000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负4M
+                string FileType = ".xls,.xlsx";//瀹氫箟涓婁紶鏂囦欢鐨勭被鍨嬪瓧绗︿覆
+
+                if (!FileType.Contains(fileEx))
+                {
+                    mes.code = "300";
+                    mes.Message = "鏂囦欢绫诲瀷涓嶅锛屽彧鑳藉鍏ls鍜寈lsx鏍煎紡鐨勬枃浠讹紒";
+                }
+                else
+                {
+                    if (filesize >= Maxsize)
+                    {
+                        mes.code = "300";
+                        mes.Message = "涓婁紶鏂囦欢瓒呰繃4M锛屼笉鑳戒笂浼�!";
+                    }
+                    else
+                    {
+                        string path = System.Web.HttpContext.Current.Server.MapPath("/File/excel/");
+
+                        if (Directory.Exists(path) == false)//濡傛灉涓嶅瓨鍦ㄥ氨鍒涘缓file鏂囦欢澶�
+                        {
+                            Directory.CreateDirectory(path); //娣诲姞鏂囦欢澶�
+                        }
+                        savePath = Path.Combine(path, filename);
+                        if (Directory.Exists(savePath) == true)  //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�
+                        {
+                            mes.code = "300";
+                            mes.Message = "宸插瓨鍦ㄥ悓鍚嶆枃浠�";
+                        }
+                        else
+                        {
+                            files.SaveAs(savePath);    //灏嗛�夋嫨鐨勬枃浠朵繚瀛樺埌鎸囧畾鏂囦欢澶逛笅
+                            string FilesName = System.Web.HttpContext.Current.Server.MapPath("/File/excel/" + filename);
+                            mes = BasicSettingBLL.ImportUserExcel(username,FilesName);
+                        }
+                    }
+                }
+            }
+            return TJson.toJson(mes);
+
         }
         #endregion
 
@@ -366,5 +426,38 @@
         }
         #endregion
 
+        #region[瑙掕壊娓呭崟鍏宠仈鍔熻兘鏌ヨ]
+        /// <summary>
+        /// 鐢ㄦ埛娓呭崟鍏宠仈鍔熻兘鏌ヨ
+        /// </summary>
+        /// <param name="rolecode">瑙掕壊缂栫爜</param>
+        /// <param name="type">鎿嶄綔绔垎绫荤紪鐮�</param>
+        /// <returns></returns>
+        [Route(template: "RoleAssociationRight")]
+        [HttpGet]
+        public HttpResponseMessage RoleAssociationRight(string rolecode,string type)
+        {
+            mes = BasicSettingBLL.RoleAssociationRight(rolecode,type);
+            return TJson.toJson(mes);
+        }
+        #endregion
+
+        #region[瑙掕壊娓呭崟鍏宠仈鍔熻兘淇濆瓨]
+        /// <summary>
+        /// 瑙掕壊娓呭崟鍏宠仈鍔熻兘淇濆瓨
+        /// </summary>
+        /// <param name="rolecode">瑙掕壊缂栫爜</param>
+        /// <param name="usercode">鐧诲綍鐢ㄦ埛缂栫爜</param>
+        /// <param name="json">鎻愪氦鏁版嵁瀵硅薄</param>
+        /// <returns></returns>
+        [Route(template: "SaveUserAssoctRight")]
+        [HttpPost]
+        public HttpResponseMessage SaveUserAssoctRight(string rolecode,string usercode, List<TreeDM> json)
+        {
+            mes = BasicSettingBLL.SaveUserAssoctRight(rolecode, usercode, json);
+            return TJson.toJson(mes);
+        }
+        #endregion
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3