From cdade79054bddf08239bdbdbbc4d0eafb9497adb Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 11 四月 2025 13:42:53 +0800
Subject: [PATCH] 优化更新人脸识别
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/BaiDuFaceHelper.cs | 2
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350013863.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs | 13 ++++
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350001861.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/System/AddUserDTO.cs | 16 ++--
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350004852.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744349998854.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350007862.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350010852.png | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/2025.jpg | 0
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs | 117 ++++++++++++++++++++++++++++----------
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs | 7 ++
12 files changed, 114 insertions(+), 41 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/BaiDuFaceHelper.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
index 5f19dce..4710227 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/BaiDuFaceHelper.cs"
@@ -351,7 +351,7 @@
/// <summary>
/// 璇锋眰鏍囪瘑鐮侊紝闅忔満鏁帮紝鍞竴
/// </summary>
- public int log_id { get; set;}
+ public string log_id { get; set;}
/// <summary>
/// 鐢ㄦ埛id锛堢敱鏁板瓧銆佸瓧姣嶃�佷笅鍒掔嚎缁勬垚锛夛紝闀垮害闄愬埗48B
/// </summary>
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/System/AddUserDTO.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/System/AddUserDTO.cs"
index ec3c6c2..9391b1f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/System/AddUserDTO.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_DTO/System/AddUserDTO.cs"
@@ -17,10 +17,7 @@
public string usertruename { get; set; }
- /// <summary>
- /// 鐧惧害浜戝垎缁�
- /// </summary>
- // public int log_id { get; set; }
+
public string phoneno { get; set; }
@@ -47,11 +44,14 @@
public string?path { get; set; }
- /// <summary>
- /// 鍥剧墖token
- /// </summary>
+ ///// <summary>
+ ///// 鍥剧墖token
+ ///// </summary>
//public string ?face_token { get; set; }
-
+ ///// <summary>
+ ///// 鐧惧害浜戝垎缁�
+ ///// </summary>
+ // public int log_id { get; set; }
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs"
index 288a4a8..f337f41 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_ISystemServices/ISys_UserService.cs"
@@ -71,5 +71,12 @@
/// <returns></returns>
WebResponseContent SaveFaceFiles(IFormCollection files);
+
+ //浜鸿劯鍒犻櫎锛堝垹闄ょ敤鎴风殑鏌愪竴寮犱汉鑴革紝濡傛灉璇ョ敤鎴峰彧鏈変竴寮犱汉鑴稿浘鐗囷紝鍒欏悓鏃跺垹闄ょ敤鎴枫�傦級
+ WebResponseContent DeleteUserIsface(string account);
+
+
+
+
}
}
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs"
index 8cef055..30be21b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserController.cs"
@@ -227,6 +227,19 @@
return Service.SaveFaceFiles(files);
}
+
+
+ /// <summary>
+ /// //浜鸿劯鍒犻櫎锛堝垹闄ょ敤鎴风殑鏌愪竴寮犱汉鑴革紝濡傛灉璇ョ敤鎴峰彧鏈変竴寮犱汉鑴稿浘鐗囷紝鍒欏悓鏃跺垹闄ょ敤鎴枫�傦級
+ /// </summary>
+ /// <param name="addUserDTO"></param>
+ /// <returns></returns>
+ [HttpPost, Route("DeleteUserIsface"), AllowAnonymous]
+ public WebResponseContent DeleteUserIsface(string account)
+ {
+ return Service.DeleteUserIsface(account);
+ }
+
}
public class SwaggerLoginRequest
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744349998854.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744349998854.png"
new file mode 100644
index 0000000..bc1a709
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744349998854.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350001861.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350001861.png"
new file mode 100644
index 0000000..c94514a
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350001861.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350004852.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350004852.png"
new file mode 100644
index 0000000..d8c7e64
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350004852.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350007862.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350007862.png"
new file mode 100644
index 0000000..c12ede2
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350007862.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350010852.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350010852.png"
new file mode 100644
index 0000000..378c996
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350010852.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350013863.png" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350013863.png"
new file mode 100644
index 0000000..fe676b5
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/1744350013863.png"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/2025.jpg" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/2025.jpg"
new file mode 100644
index 0000000..40c1c10
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/wwwroot/image/2025.jpg"
Binary files differ
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs"
index d1cff0e..9a6cab0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_SystemServices/Sys_UserService.cs"
@@ -469,7 +469,7 @@
{
return new WebResponseContent { Status = false, Message = "璐﹀彿閲嶅锛岃閲嶆柊褰曞叆" };
}
- var face = _faceServer.QueryData().Select(x => x.GroupID).FirstOrDefault(); ;
+ var face = _faceServer.QueryData().Select(x => x.GroupID).FirstOrDefault();
var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo
{
ImgPath = addUserDTO.path,
@@ -523,55 +523,58 @@
{
try
{
-
// 1. 鏌ヨ鐢ㄦ埛
- var user = BaseDal.QueryData();
- var sys = user.Where(x => x.User_Id == addUserDTO.id).FirstOrDefault();
+ var userList = BaseDal.QueryData();
+ var sys = userList.FirstOrDefault(x => x.User_Id == addUserDTO.id);
if (sys == null)
{
return new WebResponseContent { Status = false, Message = "娌℃壘鍒拌鐢ㄦ埛" };
}
- // 2. 鏌ヨ浜鸿劯搴撳垎缁� ID
- var faceGroupID = _faceServer.QueryData().Select(x => x.GroupID).FirstOrDefault();
-
- // 3. 鍒ゆ柇鏄惁闇�瑕佹洿鏂颁汉鑴镐俊鎭�
- string faceToken = null;
- if (!string.IsNullOrEmpty(addUserDTO.path)) // 鍙湁浼犱簡鏂板浘鐗囷紝鎵嶆洿鏂颁汉鑴镐俊鎭�
+ // 2. 妫�鏌ヨ处鍙锋槸鍚︿慨鏀癸紝骞跺垽鏂槸鍚﹂噸澶�//StringComparison.OrdinalIgnoreCase锛氳〃绀哄拷鐣ュぇ灏忓啓杩涜姣旇緝锛屾瘮濡� "admin" 鍜� "ADMIN" 涔熻涓烘槸鐩哥瓑鐨�
+ if (!string.Equals(sys.UserName ,addUserDTO.username))
{
- var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo
+ var existUser = userList.FirstOrDefault(a => a.UserName == addUserDTO.username);
+ if (existUser != null)
{
- ImgPath = addUserDTO.path,
- user_id = addUserDTO.username,
- group_id = faceGroupID // 杩欓噷搴旇濉櫨搴︿汉鑴稿簱鍒嗙粍
- });
-
- // 4. 鍒ゆ柇鐧惧害 API 鏄惁鎴愬姛
- if (baiduResult == null || baiduResult.error_code != 0)
- {
- return new WebResponseContent { Status = false, Message = "璇ュ浘鐗囦篃瀛樺湪锛屼笉瑕侀噸澶嶄笂浼狅細" + baiduResult.error_msg };
+ return new WebResponseContent { Status = false, Message = "璐﹀彿閲嶅锛岃閲嶆柊褰曞叆" };
}
-
- // 5. 鍙湁褰撲笂浼犱簡鏂板浘鐗囧苟鎴愬姛鏃讹紝鎵嶆洿鏂拌繖浜涘瓧娈�
- faceToken = baiduResult.result.face_token;
- sys.Log_id = baiduResult.log_id;
- sys.HeadImageUrl = addUserDTO.path;
+ sys.UserName = addUserDTO.username; // 纭鍙互鏀规椂鎵嶄慨鏀�
}
- // 6. 鏇存柊鐢ㄦ埛鍏朵粬淇℃伅
- sys.UserName = addUserDTO.username;
+ // 3. 鏇存柊鍏朵粬鐢ㄦ埛淇℃伅
sys.UserTrueName = addUserDTO.usertruename;
- sys.Face_token = faceToken ?? sys.Face_token; // 鍙湁褰� faceToken 鏈夊�兼椂鎵嶆洿鏂帮紝鍚﹀垯淇濇寔鍘熷��
sys.PhoneNo = addUserDTO.phoneno;
sys.Role_Id = addUserDTO.roleid;
sys.RoleName = addUserDTO.rolename;
sys.Enable = addUserDTO.enable;
- var list = user.Where(a => a.UserName == addUserDTO.username).FirstOrDefault();
- if (list != null)
+
+ // 4. 鏌ヨ浜鸿劯搴撳垎缁� ID
+ var faceGroupID = _faceServer.QueryData().Select(x => x.GroupID).FirstOrDefault();
+
+ // 5. 鍒ゆ柇鏄惁闇�瑕佹洿鏂颁汉鑴镐俊鎭�
+ if (!string.Equals(sys.HeadImageUrl,addUserDTO.path)) // 鏈夋柊鍥剧墖鎵嶅鐞嗕汉鑴告敞鍐�
{
- return new WebResponseContent { Status = false, Message = "璐﹀彿閲嶅锛岃閲嶆柊褰曞叆" };
+ var baiduResult = BaiDuFaceHelper.AddUser(new BDUserInfo
+ {
+ ImgPath = addUserDTO.path,
+ user_id = sys.UserName,
+ group_id = faceGroupID
+ });
+
+ // 6. 鍒ゆ柇鐧惧害 API 鏄惁鎴愬姛
+ if (baiduResult == null || baiduResult.error_code != 0)
+ {
+ return new WebResponseContent { Status = false, Message = "浜鸿劯鏇存柊澶辫触锛�" + baiduResult.error_msg };
+ }
+
+ // 7. 鏇存柊浜鸿劯鐩稿叧瀛楁
+ sys.Log_id = baiduResult.log_id;
+ sys.HeadImageUrl = addUserDTO.path;
+ sys.Face_token = baiduResult.result.face_token;
}
- // 7. 鏇存柊鏁版嵁搴�
+
+ // 8. 鏇存柊鏁版嵁搴�
BaseDal.UpdateData(sys);
return new WebResponseContent { Status = true, Data = sys };
@@ -581,6 +584,7 @@
return new WebResponseContent { Status = false, Message = "澶辫触锛�" + ex.Message };
}
}
+
@@ -726,5 +730,54 @@
{
return BaseDal.QueryFirst(x => x.UserName == userName && x.UserPwd == password, x => new UserInfo { HeadImageUrl = x.HeadImageUrl, RoleId = x.Role_Id, TenantId = x.TenantId, UserId = x.User_Id, UserName = x.UserName, UserTrueName = x.UserTrueName });
}
+
+ /// <summary>
+ /// 浜鸿劯鍒犻櫎锛堝垹闄ょ敤鎴风殑鏌愪竴寮犱汉鑴革紝濡傛灉璇ョ敤鎴峰彧鏈変竴寮犱汉鑴稿浘鐗囷紝鍒欏悓鏃跺垹闄ょ敤鎴枫�傦級
+ /// </summary>
+ /// <param name="addUserDTO"></param>
+ /// <returns></returns>
+ /// <exception cref="NotImplementedException"></exception>
+ public WebResponseContent DeleteUserIsface(string account)
+ {
+ try
+ {
+
+ // 1. 鏌ヨ浜鸿劯搴撳垎缁� ID
+ var faceGroupID = _faceServer.QueryData().Select(x => x.GroupID).FirstOrDefault();
+ //2.鏌ヨ瑕佸垹閭d釜鐢ㄦ埛鐨�
+ var user = BaseDal.QueryData(x => x.UserName == account).FirstOrDefault();
+ if (user == null)
+ {
+ return new WebResponseContent { Status = false, Message = "鐢ㄦ埛涓嶅瓨鍦紝璇锋鏌ヨ处鍙锋槸鍚﹁緭鍏ユ纭�" };
+ }
+
+ WIDESEAWCS_Common.DeleteUserImg deleteUserImg = new WIDESEAWCS_Common.DeleteUserImg();
+ deleteUserImg.group_id = faceGroupID;
+ deleteUserImg.user_id = account;
+ deleteUserImg.face_token = user.Face_token;
+ deleteUserImg.log_id = user.Log_id;
+
+ string apiResult = BaiDuFaceHelper.DeleteUserImg(deleteUserImg);//缁欑敤鎴疯处鍙�/鐢ㄦ埛缁刬d/Face_token/Log_id
+
+ // 2. 瑙f瀽杩斿洖缁撴灉锛屽垽鏂垹闄ゆ槸鍚︽垚鍔�
+ dynamic resultObj = JsonConvert.DeserializeObject(apiResult);
+ if (resultObj.error_code == 0)
+ {
+ 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