ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Common/BaiDuFaceHelper.cs
@@ -17,14 +17,18 @@ /// <returns></returns> public static string GetAccessToken() { string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials"); string returnStr = BDWebRequest(url, "", "POST"); //string url = string.Format("https://aip.baidubce.com/oauth/2.0/token?client_id={0}&client_secret={1}&grant_type={2}", "TqFQHXSNt6Z7cPQ4vDBfBNjq", "0cli6I6s8JFz3qM1Czi5ciRpDqrJuVvm", "client_credentials"); //string returnStr = BDWebRequest(url, "", "POST"); NLog.LogManager.GetCurrentClassLogger().Trace("ç¾åº¦äººè¸è¯å«è¿åï¼" + returnStr); BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr); token.getdate = DateTime.Now.ToString(); //NLog.LogManager.GetCurrentClassLogger().Trace("ç¾åº¦äººè¸è¯å«è¿åï¼" + returnStr); //BDToken token = JsonConvert.DeserializeObject<BDToken>(returnStr); //token.getdate = DateTime.Now.ToString(); return token.access_token; //return token.access_token; var str = "24.83aee44079e5a27530bc72d5ec7049a3.2592000.1746152354.282335-118294290"; return str; } public static string BDWebRequest(string url, string data, string method) @@ -113,16 +117,38 @@ /// </summary> /// <param name="path">æä»¶è·¯å¾</param> /// <returns>base64ç¼ç ä¿¡æ¯ï¼ä¸å¸¦æä»¶å¤´</returns> public static string GetFileContentAsBase64(string path) //public static string GetFileContentAsBase64(string path) //{ // using (FileStream filestream = new FileStream(path, FileMode.Open)) // { // byte[] arr = new byte[filestream.Length]; // filestream.Read(arr, 0, (int)filestream.Length); // string base64 = Convert.ToBase64String(arr); // return base64; // } //} public static string GetFileContentAsBase64(string filePath) { using (FileStream filestream = new FileStream(path, FileMode.Open)) // åªä¿çæä»¶åï¼é¿å è·¯å¾é误 string fileName = Path.GetFileName(filePath); // è·åæä»¶ç宿´è·¯å¾ string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "image", fileName); if (!File.Exists(fullPath)) { throw new FileNotFoundException("æä»¶ä¸åå¨ï¼" + fullPath); } using (FileStream filestream = new FileStream(fullPath, FileMode.Open, FileAccess.Read)) { byte[] arr = new byte[filestream.Length]; filestream.Read(arr, 0, (int)filestream.Length); string base64 = Convert.ToBase64String(arr); return base64; filestream.Read(arr, 0, arr.Length); return Convert.ToBase64String(arr); } } /// <summary> /// äººè¸æ³¨å @@ -261,7 +287,7 @@ /// <summary> /// ç¨æ·ç»idï¼æ è¯ä¸ç»ç¨æ·ï¼ç±æ°åã忝ãä¸åçº¿ç»æï¼ï¼é¿åº¦éå¶48B /// </summary> public int group_id { get; set; } public string group_id { get; set; } /// <summary> /// ç¨æ·idï¼ç±æ°åã忝ãä¸åçº¿ç»æï¼ï¼å¯¹åºç³»ç»è´¦å· /// </summary> ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_DTO/SerialPort/AddUserDTO.cs
@@ -8,20 +8,50 @@ { public class AddUserDTO { /// <summary> /// ç¨æ·idç¨æ¥ä¿®æ¹ /// </summary> public int id { get; set; } public string username { get; set; } public int log_id { get; set; } public string usertruename { get; set; } //public string facetoken { get; set; } /// <summary> /// ç¾åº¦äºåç» /// </summary> // public int log_id { get; set; } public string phoneno { get; set; } /// <summary> /// ç»å« /// </summary> public int roleid { get; set; } /// <summary> /// ç¨æ·ç±»å« /// </summary> public string rolename { get; set; } /// <summary> /// æ¯å¦å¯ç¨ /// </summary> public byte enable { get; set; } public string path { get; set; } /// <summary> /// ä¸ä¼ å¾çå /// </summary> public string?path { get; set; } /// <summary> /// å¾çtoken /// </summary> //public string ?face_token { get; set; } } } ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Model/Models/System/Sys_User.cs
@@ -22,8 +22,8 @@ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "ç¨æ·ID")] public int User_Id { get; set; } [SugarColumn( IsNullable = true, ColumnDescription = "人è¸è¯å«id")] public int Log_id { get; set; } [SugarColumn( IsNullable = true, ColumnDescription = "人è¸è¯å«")] public string Log_id { get; set; } [SugarColumn(Length = 100, IsNullable = true, ColumnDescription = "人è¸è¯å«token")] ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/Controllers/System/Sys_RoleController.cs
@@ -52,7 +52,8 @@ [HttpPost, Route("getUserTreePermission")] public IActionResult GetUserTreePermission(int roleId) { return Json(Service.GetUserTreePermission(roleId)); var ss = Service.GetUserTreePermission(roleId); return Json(ss); } [HttpPost, Route("savePermission")] ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/WIDESEAWCS_Server.csproj
@@ -67,7 +67,6 @@ <ItemGroup> <Folder Include="Controllers\BasicInfo\" /> <Folder Include="wwwroot\image\" /> </ItemGroup> </Project> ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492051182.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492244242.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492263811.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492568523.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492760375.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492791698.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492809549.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743492833343.pngBinary files differ
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555123354.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555145885.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555260571.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555310550.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555372954.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743555395910.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743562028103.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575983021.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575985033.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575987026.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575989030.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575991033.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575993033.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575995036.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575997026.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743575999035.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576001036.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576003026.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576005027.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576007027.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576009033.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576011032.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576013029.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576015030.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/1743576017025.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/51dcb60a86eb571dca49c55e983918b.jpg
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/59293addef4da93a4de193c42fc3c21.jpg
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_Server/wwwroot/image/Snipaste_2025-04-02_14-19-25.png
ÏîÄ¿´úÂë/WIDESEAWCS_Server Õýʽ/WIDESEAWCS_SystemServices/Sys_UserService.cs
@@ -20,6 +20,7 @@ using WIDESEAWCS_DTO.Telescopic; using WIDESEAWCS_Common; using Newtonsoft.Json; using OfficeOpenXml.FormulaParsing.Excel.Functions.Math; namespace WIDESEAWCS_SystemServices { @@ -463,7 +464,7 @@ return new WebResponseContent { Status = false, Message = "æ°æ®ä¸ºç©º" }; } var query = sys.LeftJoin<Dt_FaceRecognition>((a, b) => a.Log_id == b.ID); var query = sys.LeftJoin<Dt_FaceRecognition>((a, b) => a.Log_id == b.GroupID); if (!string.IsNullOrEmpty(paginationDTO.searchKeyword)) { query = query.Where((a, b) => @@ -481,6 +482,8 @@ var result = query.Select((a, b) => new { a.UserPwd, a.Log_id, a.User_Id, a.UserName, a.UserTrueName, @@ -514,17 +517,27 @@ } } /// <summary> /// æ·»å ç¨æ· /// </summary> /// <param name="addUserDTO"></param> /// <returns></returns> public WebResponseContent AdduserData(AddUserDTO addUserDTO) { try { if (addUserDTO == null) { return new WebResponseContent { Status = false, Message = "è¯·æ±æ°æ®ä¸ºç©ºï¼å¯è½æ¯ JSON è§£æå¤±è´¥" }; } var face = _faceRecognitionRepository.QueryData().Select(x => x.GroupID).FirstOrDefault(); ; var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo { ImgPath = addUserDTO.path, user_id = addUserDTO.username, group_id = addUserDTO.log_id // è¿éåºè¯¥å¡«ç¾åº¦äººè¸åºåç» group_id = face // è¿éåºè¯¥å¡«ç¾åº¦äººè¸åºåç» // group_id = baiduResult.result.log_id }); @@ -532,20 +545,24 @@ if (baiduResult == null || baiduResult.error_code != 0) { return new WebResponseContent { Status = false, Data = "äººè¸æ³¨å失败ï¼" + baiduResult.error_msg }; } // åå»ºç¨æ·æ°æ® var sys = new Sys_User { UserName = addUserDTO.username, UserTrueName=addUserDTO.usertruename, HeadImageUrl=addUserDTO.path, Log_id = addUserDTO.log_id, Log_id = face, Face_token = baiduResult.result.face_token, PhoneNo = addUserDTO.phoneno, Role_Id = addUserDTO.roleid, RoleName = addUserDTO.rolename, Enable = addUserDTO.enable, UserPwd= "j79rYYvCz4vdhcboB1Ausg==" UserPwd= "j79rYYvCz4vdhcboB1Ausg==", CreateDate=DateTime.Now }; BaseDal.AddData(sys); return new WebResponseContent { Status = true, Data = sys }; @@ -558,48 +575,70 @@ } /// <summary> /// æ´æ°ç¨æ· /// </summary> /// <param name="addUserDTO"></param> /// <returns></returns> public WebResponseContent UpuserData(AddUserDTO addUserDTO) { try { var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo var sys = BaseDal.QueryData(x => x.User_Id == addUserDTO.id).FirstOrDefault(); if (sys == null) { ImgPath = addUserDTO.path, user_id = addUserDTO.username, group_id = addUserDTO.log_id // è¿éåºè¯¥å¡«ç¾åº¦äººè¸åºåç» }); // 夿ç¾åº¦è¿åæ¯å¦æå if (baiduResult == null || baiduResult.error_code != 0) return new WebResponseContent { Status = false, Message = "没æ¾å°è¯¥ç¨æ·" }; } var face = _faceRecognitionRepository.QueryData().Select(x => x.GroupID).FirstOrDefault(); // 夿æ¯å¦éè¦æ´æ°äººè¸å¾ç string faceToken = null; if (!string.IsNullOrEmpty(addUserDTO.path)) // å¦æä¼ äºå¾çè·¯å¾ï¼ææ´æ°äººè¸ä¿¡æ¯ { return new WebResponseContent { Status = false, Data = "äººè¸æ´æ°å¤±è´¥ï¼" + baiduResult.error_msg }; var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo { ImgPath = addUserDTO.path, user_id = addUserDTO.username, group_id = face // è¿éåºè¯¥å¡«ç¾åº¦äººè¸åºåç» }); // 夿ç¾åº¦è¿åæ¯å¦æå if (baiduResult == null || baiduResult.error_code != 0) { return new WebResponseContent { Status = false, Data = "人è¸ä»¥åå¨ï¼ä¸è¦éå¤ä¸ä¼ ï¼" + baiduResult.error_msg }; } // è·åæ´æ°åç Face_token faceToken = baiduResult.result.face_token; } // æ´æ°ç¨æ·æ°æ® var sys = new Sys_User { UserName = addUserDTO.username, HeadImageUrl = addUserDTO.path, Log_id = addUserDTO.log_id, Face_token = baiduResult.result.face_token, PhoneNo = addUserDTO.phoneno, Role_Id = addUserDTO.roleid, RoleName = addUserDTO.rolename, Enable = addUserDTO.enable, }; // æ¥è¯¢ç°æç¨æ· // æ´æ°æ¥è¯¢å°çç¨æ·æ°æ® sys.UserName = addUserDTO.username; sys.UserTrueName = addUserDTO.usertruename; sys.HeadImageUrl = addUserDTO.path; // æ´æ°å¤´åè·¯å¾ï¼å¦æææ°è·¯å¾ï¼ sys.Log_id = face; //sys.Face_token = faceToken ?? addUserDTO.face_token; // å¦ææ²¡ææ´æ°å¾çï¼ä¿æåæ Face_token sys.Face_token = faceToken; // å¦ææ²¡ææ´æ°å¾çï¼ä¿æåæ Face_token sys.PhoneNo = addUserDTO.phoneno; sys.Role_Id = addUserDTO.roleid; sys.RoleName = addUserDTO.rolename; sys.Enable = addUserDTO.enable; // æ´æ°æ°æ®åº BaseDal.UpdateData(sys); return new WebResponseContent { Status = true, Data = sys }; } catch (Exception ex) { return new WebResponseContent { Status = false, Message = "失败" + ex }; return new WebResponseContent { Status = false, Message = "失败ï¼" + ex.Message }; } } /// <summary> /// å é¤ @@ -611,7 +650,7 @@ try { string apiResult = BaiDuFaceHelper.DeleteUser(deleteUserDTO); string apiResult = BaiDuFaceHelper.DeleteUser(deleteUserDTO);//åªè¦ç»tokenålog_id // 2. è§£æè¿åç»æï¼å¤æå 餿¯å¦æå dynamic resultObj = JsonConvert.DeserializeObject(apiResult);