From 20f099aee8715510406bf46c5e8ff4a8f5d532df Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期三, 02 四月 2025 16:27:19 +0800
Subject: [PATCH] 111

---
 项目代码/WIDESEAWCS_Server 正式/WIDESEAWCS_SystemServices/Sys_UserService.cs |  527 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 487 insertions(+), 40 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs"
index 35d6315..2f18d6d 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/WIDESEAWCS_SystemServices/Sys_UserService.cs"
@@ -12,6 +12,15 @@
 using System.Net;
 using WIDESEAWCS_Core.Caches;
 using WIDESEA_ISerialPortRepository;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
+using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
+using Microsoft.AspNetCore.Builder;
+using WIDESEAWCS_DTO.SerialPort;
+using WIDESEAWCS_DTO.Telescopic;
+using WIDESEAWCS_Common;
+using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
 
 namespace WIDESEAWCS_SystemServices
 {
@@ -22,15 +31,22 @@
         private readonly ISys_MenuService _menuService;
         private readonly ISys_RoleRepository _RoleRepository;
         private readonly ILoginHistoryRepository _loginHistoryRepository;
-        public Sys_UserService(ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage,
-            ICacheService cacheService, ISys_MenuService menuService , ISys_RoleRepository roleRepository, ILoginHistoryRepository loginHistoryRepository) : base(repository)
+        private readonly IPutakeRepository _putakeRepository;
+        private readonly IFaceRecognitionRepository _faceRecognitionRepository;
+
+
+
+        public Sys_UserService(IFaceRecognitionRepository faceRecognitionRepository, ISys_UserRepository repository, IUnitOfWorkManage unitOfWorkManage,
+            ICacheService cacheService, ISys_MenuService menuService, ISys_RoleRepository roleRepository, ILoginHistoryRepository loginHistoryRepository, IPutakeRepository putakeRepository) : base(repository)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _cacheService = cacheService;
             _menuService = menuService;
             _RoleRepository = roleRepository;
-            _RoleRepository= roleRepository;
+            _RoleRepository = roleRepository;
             _loginHistoryRepository = loginHistoryRepository;
+            _putakeRepository = putakeRepository;
+            _faceRecognitionRepository = faceRecognitionRepository;
 
         }
 
@@ -39,7 +55,7 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                //BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);
+                // BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);
 
                 string msg = string.Empty;
 
@@ -53,48 +69,71 @@
 
                 }
                 #endregion
-
-                UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password);
-                if (user != null)
+                if (!string.IsNullOrEmpty(loginInfo.path))
                 {
-                    object obj = _menuService.GetMenuActionList(user.RoleId);
-                    if (obj is not IEnumerable<object> list)
+                    var faceResult = BaiDuFaceHelper.FaceSearch(loginInfo.path);
+
+                    if (faceResult != null && faceResult.error_code == 0)
                     {
-                        return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
-                    }
-                    if (!list.Any())
-                    {
-                        return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
+                        // 鑾峰彇鏈�楂樺尮閰嶅害鐨勭敤鎴�
+                        var bestMatch = faceResult.result.user_list.OrderByDescending(u => u.score).FirstOrDefault();//鎷跨涓�涓渶楂樼殑
+
+                        if (bestMatch != null && double.TryParse(bestMatch.score, out double score) && score > 80) // 璁惧畾80鍒嗕负鍙俊搴﹂槇鍊�
+                        {
+                            return new WebResponseContent { Data = true };
+                        }
                     }
 
-                    string token = JwtHelper.IssueJwt(new TokenModelJwt()
-                    {
-                        UserId = user.UserId,
-                        RoleId = user.RoleId,
-                        UserName = user.UserName,
-                        TenantId = user.TenantId,
-                    });
-                    var loghis = new Dt_LoginHistory
-                    {
-                        Account = user.UserName,
-                        TrurName=user.UserTrueName,
-                        Createdate=DateTime.Now
-
-
-
-                    };
-                   
-
-                    _cacheService.AddOrUpdate(user.UserId.ToString(), token);
-                    _loginHistoryRepository.AddData(loghis);
-
-                    content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl });
+                    return WebResponseContent.Instance.Error("浜鸿劯璇嗗埆澶辫触锛岃閲嶈瘯");
                 }
                 else
                 {
-                    content = WebResponseContent.Instance.Error("璐﹀彿鎴栧瘑鐮侀敊璇�");
+                    UserInfo user = BaseDal.GetUserInfo(loginInfo.UserName, loginInfo.Password);
+                    var disbled = BaseDal.QueryFirst(x => x.UserName == loginInfo.UserName);//鏍规嵁杩欎釜鐢ㄦ埛鍚嶆潵鏌ョ湅鐢ㄦ埛
+                    if (user != null)
+                    {
+                        object obj = _menuService.GetMenuActionList(user.RoleId);
+                        if (obj is not IEnumerable<object> list)
+                        {
+                            return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
+                        }
+                        if (!list.Any())
+                        {
+                            return WebResponseContent.Instance.Error("鏃犵櫥褰曟潈闄�");
+                        }
+                        if (disbled.Enable != 1)
+                        {
+                            return WebResponseContent.Instance.Error("浣犵殑璐﹀彿宸茶绂佺敤锛岃鑱旂郴绠$悊鍛�");
+                        }
+
+                        string token = JwtHelper.IssueJwt(new TokenModelJwt()
+                        {
+                            UserId = user.UserId,
+                            RoleId = user.RoleId,
+                            UserName = user.UserName,
+                            TenantId = user.TenantId,
+                        });
+                        var loghis = new Dt_LoginHistory
+                        {
+                            Account = user.UserName,
+                            TrurName = user.UserTrueName,
+                            CreateDate = DateTime.Now
+
+                        };
+
+
+                        _cacheService.AddOrUpdate(user.UserId.ToString(), token);
+                        _loginHistoryRepository.AddData(loghis);
+
+                        content = WebResponseContent.Instance.OK(data: new { token, userName = user.UserTrueName, img = user.HeadImageUrl, ID = user.UserId, RoleId = user.RoleId });
+                    }
+                    else
+                    {
+                        content = WebResponseContent.Instance.Error("璐﹀彿鎴栧瘑鐮侀敊璇�");
+                    }
                 }
             }
+
             catch (Exception ex)
             {
                 content = WebResponseContent.Instance.Error(ex.Message);
@@ -173,6 +212,7 @@
                 if (newPwd.Length < 6) return WebResponseContent.Instance.Error("瀵嗙爜涓嶈兘灏戜簬6浣�");
 
                 int userId = App.User.UserId;
+
                 string userCurrentPwd = BaseDal.QueryFirst(x => x.User_Id == userId, s => s.UserPwd);
 
                 string _oldPwd = oldPwd.EncryptDES(AppSecret.User);
@@ -192,8 +232,8 @@
                     nameof(Sys_User.LastModifyPwdDate),
                     nameof(Sys_User.UserPwd)
                 });
-
-                content = WebResponseContent.Instance.OK("瀵嗙爜淇敼鎴愬姛");
+                //content = WebResponseContent.Instance.OK("瀵嗙爜淇敼鎴愬姛");
+                content = WebResponseContent.Instance.OK("瀵嗙爜淇敼鎴愬姛", userId);
             }
             catch (Exception ex)
             {
@@ -201,6 +241,7 @@
                 content = WebResponseContent.Instance.Error("鏈嶅姟鍣ㄤ簡鐐归棶棰�,璇风◢鍚庡啀璇�");
             }
             return content;
+
         }
 
         public WebResponseContent GetUerType()
@@ -229,8 +270,414 @@
             {
 
 
-                return new WebResponseContent { Status = false, Message="澶辫触"+ex };
+                return new WebResponseContent { Status = false, Message = "澶辫触" + ex };
             }
         }
+
+
+        public WebResponseContent PermissionView(int userId, string group)
+        {
+            try
+            {
+                // 1. 鑾峰彇鐢ㄦ埛淇℃伅
+                var user = BaseDal.QueryData(x => x.User_Id == userId).FirstOrDefault();
+                var allTasks = _putakeRepository.QueryData();
+
+                if (user == null)
+                {
+                    return new WebResponseContent { Status = false, Message = "鐢ㄦ埛涓嶅瓨鍦�" };
+                }
+
+                string roleName = user.RoleName;
+
+                // 2. 鍒ゆ柇鏄惁鏄秴绾х鐞嗗憳
+                if (roleName.Contains("瓒呯骇绠$悊鍛�"))
+                {
+                    // 瓒呯骇绠$悊鍛樹粛鐒惰绛涢�夋寚瀹� group
+                    var adminTasks = allTasks.Where(x => x.Grouptype == group).ToList();
+                    return new WebResponseContent { Status = true, Data = adminTasks, Message = "鑾峰彇鎴愬姛" };
+                }
+
+                // 3. 纭畾鏅�氱敤鎴疯鑹插尮閰嶇殑浠诲姟绫诲瀷
+                List<string> allowedGroups = new List<string>();
+
+                if (roleName.Contains("鍦版矡")) allowedGroups.Add("鍦版矡");//濡傛灉娣诲姞杩涙暟缁勪腑
+                if (roleName.Contains("鐢垫皵")) allowedGroups.Add("鐢垫皵");
+                if (roleName.Contains("鏈烘")) allowedGroups.Add("鏈烘");
+
+                if (allowedGroups.Count == 0)
+                {
+                    return new WebResponseContent { Status = false, Message = "鎮ㄦ棤鏉冮檺鏌ョ湅浠诲姟" };
+                }
+
+                // 4. 鏅�氱敤鎴峰彧鑳界湅鑷繁鏉冮檺鑼冨洿鍐呯殑浠诲姟
+                if (!allowedGroups.Contains(group))
+                {
+                    return new WebResponseContent { Status = false, Message = "鎮ㄦ棤鏉冮檺鏌ョ湅璇ヤ换鍔$被鍒�" };
+                }
+
+                var tasks = allTasks.Where(t => t.Grouptype == group).ToList();
+
+                return new WebResponseContent { Status = true, Data = tasks, Message = "鑾峰彇鎴愬姛" };
+            }
+            catch (Exception ex)
+            {
+                return new WebResponseContent { Status = false, Message = "閿欒: " + ex.Message };
+            }
+        }
+
+
+        /// <summary>
+        /// 鍥剧墖鏂囦欢鍚�
+        /// </summary>
+        /// <param name="files"></param>
+        /// <returns></returns>
+        public WebResponseContent SaveFiles(IFormCollection files)
+        {
+            if (files == null || files.Files.Count == 0)
+                return new WebResponseContent { Status = false, Message = "璇蜂笂浼犳枃浠�" };
+
+            // 1. 纭繚瀛樺偍鐩綍瀛樺湪
+            string baseDirectory = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "image");
+            if (!Directory.Exists(baseDirectory))
+                Directory.CreateDirectory(baseDirectory);
+
+            try
+            {
+                var file = files.Files[0]; // 鍙鐞嗙涓�涓枃浠�
+                string fileName = file.FileName; // 鐩存帴浣跨敤鍓嶇鐨勬枃浠跺悕
+
+                string fullFilePath = Path.Combine(baseDirectory, fileName);
+
+                // 2. 淇濆瓨鏂囦欢锛堝鏋滃瓨鍦紝鍒欒鐩栵級
+                using (var stream = new FileStream(fullFilePath, FileMode.Create))
+                {
+                    file.CopyTo(stream);
+                }
+
+                // 3. 杩斿洖鏂囦欢鍚�
+                return new WebResponseContent { Status = true, Message = "鏂囦欢涓婁紶鎴愬姛", Data = fileName };
+            }
+            catch (Exception ex)
+            {
+                return new WebResponseContent { Status = false, Message = "涓婁紶鏂囦欢澶辫触锛�" + ex.Message };
+            }
+        }
+
+        /// <summary>
+        /// 鏇存柊瀵嗙爜
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="oldPwd"></param>
+        /// <param name="newPwd"></param>
+        /// <returns></returns>
+        public WebResponseContent UpdatePwd(int id, string oldPwd, string newPwd)
+        {
+            WebResponseContent content = new WebResponseContent();
+            oldPwd = oldPwd?.Trim();
+            newPwd = newPwd?.Trim();
+
+            try
+            {
+                if (string.IsNullOrEmpty(oldPwd)) return content.Error("鏃у瘑鐮佷笉鑳戒负绌�");
+                if (string.IsNullOrEmpty(newPwd)) return content.Error("鏂板瘑鐮佷笉鑳戒负绌�");
+                if (newPwd.Length < 6) return content.Error("瀵嗙爜涓嶈兘灏戜簬6浣�");
+
+                // 鑾峰彇鐢ㄦ埛褰撳墠瀵嗙爜
+                string userCurrentPwd = BaseDal.QueryFirst(x => x.User_Id == id, s => s.UserPwd) ?? "";
+
+                if (string.IsNullOrEmpty(userCurrentPwd)) return content.Error("鐢ㄦ埛涓嶅瓨鍦ㄦ垨瀵嗙爜鏈缃�");
+
+                //// 杩涜瀵嗙爜鍔犲瘑瀵规瘮
+                //string _oldPwd = oldPwd.EncryptDES(AppSecret.User);
+                //if (_oldPwd != userCurrentPwd) return content.Error("鏃у瘑鐮佷笉姝g‘");
+
+                // 鐢熸垚鏂板瘑鐮佸姞瀵嗗��
+                string _newPwd = newPwd.EncryptDES(AppSecret.User);
+                if (userCurrentPwd == _newPwd) return content.Error("鏂板瘑鐮佷笉鑳戒笌鏃у瘑鐮佺浉鍚�");
+
+                // 鏇存柊瀵嗙爜
+                bool isUpdated = BaseDal.UpdateData(new Sys_User
+                {
+                    User_Id = id,
+                    UserPwd = _newPwd,
+                    LastModifyPwdDate = DateTime.Now
+                }, new List<string>
+        {
+            nameof(Sys_User.LastModifyPwdDate),
+            nameof(Sys_User.UserPwd)
+        });
+
+                if (!isUpdated)
+                {
+                    return content.Error("瀵嗙爜淇敼澶辫触锛岃绋嶅悗閲嶈瘯");
+                }
+
+                return content.OK("瀵嗙爜淇敼鎴愬姛", id);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine($"淇敼瀵嗙爜寮傚父: {ex.Message}");
+                return content.Error($"鏈嶅姟鍣ㄩ敊璇�: {ex.Message}");
+            }
+        }
+
+        public WebResponseContent Upuserbase(UserDTO userDTO)
+        {
+            try
+            {
+                var user = BaseDal.QueryData(x => x.User_Id == userDTO.id).FirstOrDefault();
+                if (user == null)
+                {
+                    return new WebResponseContent { Status = false, Message = "娌℃壘鍒拌鐢ㄦ埛" };
+                }
+                user.UserTrueName = userDTO.usertruename;
+                user.PhoneNo = userDTO.phone;
+                user.HeadImageUrl = userDTO.files;
+                BaseDal.UpdateData(user); // 纭繚鏇存柊鍒版暟鎹簱
+                return new WebResponseContent { Status = true, Data = user };
+            }
+            catch (Exception ex)
+            {
+
+                return new WebResponseContent { Status = false, Message = "澶辫触锛�" + ex };
+            }
+
+        }
+
+
+        /// <summary>
+        /// 鏌ョ湅鐢ㄦ埛淇℃伅鍜屼汉鑴歌瘑鍒〃
+        /// </summary>
+        /// <param name="paginationDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent GetUserFace(PaginationDTO paginationDTO)
+        {
+            try
+            {
+                int totalCount = 0;
+                var sys = Db.Queryable<Sys_User>();
+                var face = _faceRecognitionRepository.Db.Queryable<Dt_FaceRecognition>();
+
+                if (face == null)
+                {
+                    return new WebResponseContent { Status = false, Message = "鏁版嵁涓虹┖" };
+                }
+
+                var query = sys.LeftJoin<Dt_FaceRecognition>((a, b) => a.Log_id == b.GroupID);
+                if (!string.IsNullOrEmpty(paginationDTO.searchKeyword))
+                {
+                    query = query.Where((a, b) =>
+                        a.UserName.Contains(paginationDTO.searchKeyword) ||
+                        a.UserTrueName.Contains(paginationDTO.searchKeyword) ||
+                        a.PhoneNo.Contains(paginationDTO.searchKeyword) ||
+                        a.RoleName.Contains(paginationDTO.searchKeyword) ||
+                        a.Role_Id.ToString().Contains(paginationDTO.searchKeyword)
+                    );
+                }
+                if (paginationDTO.startDate.HasValue && paginationDTO.endDate.HasValue)
+                {
+                    query = query.Where((a, b) => a.CreateDate >= paginationDTO.startDate && a.CreateDate <= paginationDTO.endDate);
+                }
+
+                var result = query.Select((a, b) => new
+                {
+                    a.UserPwd,
+                    a.Log_id,
+                    a.User_Id,
+                    a.UserName,
+                    a.UserTrueName,
+                    a.PhoneNo,
+                    a.Role_Id,
+                    a.RoleName,
+                    a.HeadImageUrl,
+                    a.Enable,
+                    a.CreateDate,
+                    a.Face_token,
+                    b.GroupID,
+                }).ToPageList(paginationDTO.pageIndex, paginationDTO.pageSize, ref totalCount);
+                return new WebResponseContent
+                {
+                    Status = true,
+                    Data = new
+                    {
+                        TotalCount = totalCount,//鎬绘暟
+                        PageIndex = paginationDTO.pageIndex,//椤垫暟
+                        PaseSize = paginationDTO.pageSize,//涓�椤靛灏戞暟鎹�
+                        Items = result//杩斿洖瀛楁
+                    }
+
+                };
+
+            }
+            catch (Exception)
+            {
+
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞鐢ㄦ埛
+        /// </summary>
+        /// <param name="addUserDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent AdduserData(AddUserDTO addUserDTO)
+        {
+            try
+            {
+                if (addUserDTO == null)
+                {
+                    return new WebResponseContent { Status = false, Message = "璇锋眰鏁版嵁涓虹┖锛屽彲鑳芥槸 JSON 瑙f瀽澶辫触" };
+                }
+
+                var face = _faceRecognitionRepository.QueryData().Select(x => x.GroupID).FirstOrDefault(); ;
+                var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo
+                {
+                    ImgPath = addUserDTO.path,
+                    user_id = addUserDTO.username,
+                    group_id = face // 杩欓噷搴旇濉櫨搴︿汉鑴稿簱鍒嗙粍
+                   // group_id = baiduResult.result.log_id
+                });
+
+
+                // 鍒ゆ柇鐧惧害杩斿洖鏄惁鎴愬姛
+                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 = face,
+                    Face_token = baiduResult.result.face_token,
+                    PhoneNo = addUserDTO.phoneno,
+                    Role_Id = addUserDTO.roleid,
+                    RoleName = addUserDTO.rolename,
+                    Enable = addUserDTO.enable,
+                    UserPwd= "j79rYYvCz4vdhcboB1Ausg==",
+                    CreateDate=DateTime.Now
+                };
+                BaseDal.AddData(sys);
+                return new WebResponseContent { Status = true, Data = sys };
+            }
+            catch (Exception ex)
+            {
+
+                return new WebResponseContent { Status = false, Message = "澶辫触" + ex };
+            }
+
+        }
+
+
+        /// <summary>
+        /// 鏇存柊鐢ㄦ埛
+        /// </summary>
+        /// <param name="addUserDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent UpuserData(AddUserDTO addUserDTO)
+        {
+            try
+            {
+                var sys = BaseDal.QueryData(x => x.User_Id == addUserDTO.id).FirstOrDefault();
+                
+                if (sys == null)
+                {
+                    return new WebResponseContent { Status = false, Message = "娌℃壘鍒拌鐢ㄦ埛" };
+                }
+                var face = _faceRecognitionRepository.QueryData().Select(x => x.GroupID).FirstOrDefault();
+                // 鍒ゆ柇鏄惁闇�瑕佹洿鏂颁汉鑴稿浘鐗�
+                string faceToken = null;
+                if (!string.IsNullOrEmpty(addUserDTO.path)) // 濡傛灉浼犱簡鍥剧墖璺緞锛屾墠鏇存柊浜鸿劯淇℃伅
+                {
+                    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;
+                }
+
+                // 鏌ヨ鐜版湁鐢ㄦ埛
+               
+
+                // 鏇存柊鏌ヨ鍒扮殑鐢ㄦ埛鏁版嵁
+                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.Message };
+            }
+        }
+
+
+
+        /// <summary>
+        /// 鍒犻櫎
+        /// </summary>
+        /// <param name="deleteUserDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent DeleteUserData(DeleteUserImg deleteUserDTO)
+        {
+            try
+            {
+                
+                string apiResult = BaiDuFaceHelper.DeleteUser(deleteUserDTO);//鍙缁檛oken鍜宭og_id
+
+                // 2. 瑙f瀽杩斿洖缁撴灉锛屽垽鏂垹闄ゆ槸鍚︽垚鍔�
+                dynamic resultObj = JsonConvert.DeserializeObject(apiResult);
+                if (resultObj.error_code == 0)
+                {
+                   // 鐧惧害鍒犻櫎鎴愬姛鍚庯紝鍒犻櫎鏁版嵁搴撲腑鐨勭敤鎴�
+                    var user = BaseDal.QueryData(deleteUserDTO.user_id);
+                    if (user != null)
+                    {
+                        BaseDal.DeleteData(user);
+                    }
+                    return WebResponseContent.Instance.OK("鐢ㄦ埛鍒犻櫎鎴愬姛");
+                }
+                else
+                {
+                    return WebResponseContent.Instance.Error("鐧惧害 API 鍒犻櫎澶辫触锛�" + resultObj.error_msg);
+                }
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error("鍒犻櫎鐢ㄦ埛澶辫触锛�" + ex.Message);
+            }
+        }
+
+
+       
     }
 }
+
+

--
Gitblit v1.9.3