From 7326f36860d3a7d5355bd2f7546f905010a8fb6f Mon Sep 17 00:00:00 2001
From: 移动系统liao <liaoxujun@qq.com>
Date: 星期一, 19 八月 2024 15:06:06 +0800
Subject: [PATCH] 增加企业执照文件,身份证文件验证上传,增加人脸特征上传

---
 cylsg/EzUpFile/EzFileUploadService.cs        |   78 ++++++++++++++++++++++++-
 cylsg/EzTencentCloud/ITencentCloudService.cs |   29 +++++++++
 cylsg/cylsg.Model/UserModel/UserWorker.cs    |    6 ++
 cylsg/EzUpFile/UpFileController.cs           |   16 +++++
 cylsg/EzTencentCloud/TencentCloudService.cs  |   31 ++++++++++
 cylsg/EzUpFile/IEzFileUploadService.cs       |   10 +++
 6 files changed, 166 insertions(+), 4 deletions(-)

diff --git a/cylsg/EzTencentCloud/ITencentCloudService.cs b/cylsg/EzTencentCloud/ITencentCloudService.cs
index 4cc0e0a..da37eff 100644
--- a/cylsg/EzTencentCloud/ITencentCloudService.cs
+++ b/cylsg/EzTencentCloud/ITencentCloudService.cs
@@ -4,6 +4,7 @@
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using TencentCloud.Iai.V20200303.Models;
 using TencentCloud.Ocr.V20181119.Models;
 
 namespace EzTencentCloud
@@ -34,8 +35,36 @@
         BizLicenseOCRResponse BizLicenseOCR(string ImageBase64);
         #endregion
         #region iai 浜鸿劯璇嗗埆
+        /// <summary>
+        /// 鍒涘缓浜鸿劯搴擄紝涓�鑸竴涓簯璐﹀彿鍙渶瑕佸垱寤轰竴娆�
+        /// </summary>
         public void IaiCreatGroup();
+        /// <summary>
+        /// 浜鸿劯楠岃瘉 涓�鑸垎鏁拌秴杩�50 鍒嗚瘑鍒负涓�涓汉
+        /// </summary>
+        /// <param name="img64"></param>
+        /// <param name="PersonNameId"></param>
+        /// <returns></returns>
+        public VerifyFaceResponse VerifyFace(string img64, string PersonNameId);
+        /// <summary>
+        /// 澧炲姞涓�涓汉鐨勪汉鑴稿浘鐗囩壒寰侊紝涓�涓渶澶氬彧鍏佽鏈変簲涓汉鑴哥壒杩�
+        /// </summary>
+        /// <param name="img64"></param>
+        /// <param name="PersonNameId"></param>
+        /// <param name="PersonName"></param>
+        /// <param name="PersonGender"></param>
+        /// <returns></returns>
+        public bool IaiAddPersoImg(string img64, string PersonNameId, string PersonName, int PersonGender);
 
+        /// <summary>
+        /// 澧炲姞涓�涓汉
+        /// </summary>
+        /// <param name="img64">浜鸿劯鐓�</param>
+        /// <param name="PersonNameId">浜鸿劯ID 涓�涓簯璐︽埛涓敮涓�</param>
+        /// <param name="PersonName">濮撳悕</param>
+        /// <param name="PersonGender">鎬у埆    0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param>
+        /// <returns></returns>
+        public bool IaiAddPerso(string img64, string PersonNameId, string PersonName, int  PersonGender);
         #endregion
 
     }
diff --git a/cylsg/EzTencentCloud/TencentCloudService.cs b/cylsg/EzTencentCloud/TencentCloudService.cs
index aa364a0..1f80d16 100644
--- a/cylsg/EzTencentCloud/TencentCloudService.cs
+++ b/cylsg/EzTencentCloud/TencentCloudService.cs
@@ -275,6 +275,37 @@
 
 
         }
+
+
+        public VerifyFaceResponse VerifyFace(string img64, string PersonNameId)
+        {
+            Credential cred = new Credential
+            {
+                SecretId = App.Configuration["TencentCloud:SecretId"] ?? "AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T",
+                SecretKey = App.Configuration["TencentCloud:SecretKey"] ?? "4rNcaHhrkMhmb9QQ9bmgKipfFZcOt86n"
+            };
+
+            ClientProfile clientProfile = new ClientProfile();
+            HttpProfile httpProfile = new HttpProfile();
+
+
+            httpProfile.Endpoint = ("iai.tencentcloudapi.com");
+            clientProfile.HttpProfile = httpProfile;
+            var iaiClient = new IaiClient(cred, "ap-chengdu", clientProfile);
+            var ret = iaiClient.VerifyFaceSync(new  TencentCloud.Iai.V20200303.Models.VerifyFaceRequest
+            {
+
+                PersonId = PersonNameId,
+                 Image= img64
+
+
+
+            });
+            return ret;
+
+
+
+        }
         #endregion
 
     }
diff --git a/cylsg/EzUpFile/EzFileUploadService.cs b/cylsg/EzUpFile/EzFileUploadService.cs
index ea94781..e877b52 100644
--- a/cylsg/EzUpFile/EzFileUploadService.cs
+++ b/cylsg/EzUpFile/EzFileUploadService.cs
@@ -283,7 +283,13 @@
 
         }
 
-        public async Task<(IDCardOCRResponse,string)> UpIdCord(  string PageName = "FRONT")
+
+
+
+        #endregion
+
+        #region 璇嗗埆涓婁紶
+        public async Task<(IDCardOCRResponse, string)> UpIdCord(string PageName = "FRONT")
         {
             try
             {
@@ -334,7 +340,7 @@
 
                     url = await UploadFilesFByBase64(_tcs.GetIdCordImg());
 
-                    return ( idcordinfo, url );
+                    return (idcordinfo, url);
 
                 }
                 catch (Exception e)
@@ -417,8 +423,72 @@
         }
 
 
+        public async Task<(bool,string)> IaiAddPerso(string CoredID,string Name,int PersonGender)
+        {
+            try
+            {
+
+                var maxSize = 1024 * 1024 * 5; //涓婁紶澶у皬5M
+
+                var FileData = _request?.Form?.Files["file"];
+
+                if (FileData.Length > maxSize)
+                {
+                    throw Oops.Oh(" 涓婁紶鏂囦欢涓嶅彲瓒呭嚭500K");
+                }
+
+
+                //澶勭悊鍥惧舰
+                //  var FileData = Request.Form.Files[0];
+
+                Image oimage = Image.FromStream(FileData.OpenReadStream());
+                if (oimage == null)
+                {
+                    throw Oops.Oh(" 涓婁紶澶辫触");
+                }
+
+                MemoryStream ms = new MemoryStream();
+                if (oimage.Width > 600)
+
+                {
+                    if (oimage.Width > oimage.Height)
+                        oimage.GetThumbnailImage(600, 400, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                    else
+                        oimage.GetThumbnailImage(400, 600, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                }
+                else
+                    oimage.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
+                ms.Position = 0;
+
+                var arr = ms.ToArray();
+                string img64 = Convert.ToBase64String(arr);
+
+                bool  info = false;
+                string url = "";
+
+                try
+                {
+                    info =  _tcs.IaiAddPerso(img64, CoredID, Name, PersonGender);
+
+                    url = await UploadFilesFByBase64(img64);
+
+                    return (info, url);
+
+                }
+                catch (Exception e)
+                {
+
+                    throw Oops.Oh(e.Message);
+                }
+            }
+            catch (Exception e)
+            {
+
+                throw Oops.Oh(e.Message);
+            }
+        }
+
+       
         #endregion
-
-
     }
 }
diff --git a/cylsg/EzUpFile/IEzFileUploadService.cs b/cylsg/EzUpFile/IEzFileUploadService.cs
index dae0969..28cd115 100644
--- a/cylsg/EzUpFile/IEzFileUploadService.cs
+++ b/cylsg/EzUpFile/IEzFileUploadService.cs
@@ -41,6 +41,16 @@
         /// <returns></returns>
         Task<(BizLicenseOCRResponse, string)> UpBizLicense();
 
+        /// <summary>
+        /// 鍒涘缓浜鸿劯鐗瑰緛
+        /// </summary>
+        /// <param name="CoredID"> 韬唤璇佸彿</param>
+        /// <param name="Name">濮撳悕</param>  
+        /// <param name="PersonGender"> 鎬у埆    0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param>
+        /// <returns></returns>
+        Task<(bool, string)> IaiAddPerso(string CoredID, string Name, int PersonGender);
+
+
     }
 
 
diff --git a/cylsg/EzUpFile/UpFileController.cs b/cylsg/EzUpFile/UpFileController.cs
index 62d9d3a..fb6614d 100644
--- a/cylsg/EzUpFile/UpFileController.cs
+++ b/cylsg/EzUpFile/UpFileController.cs
@@ -49,6 +49,22 @@
             return await fileUploadService.UpBizLicense();
 
         }
+        /// <summary>
+        /// 澧炲姞浜鸿劯鐗瑰緛
+        /// </summary>         
+        /// <param name="CordId">韬唤璇佸彿</param>
+        /// <param name="Name">鍚嶇О</param>
+        /// <param name="Gender">0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��</param>
+        /// <returns></returns>
+        [HttpPost]
+        public async Task<(bool , string)> IaiAddPerso([FromServices] IEzFileUploadService fileUploadService, IFormFile file,[FromQuery] string CordId, [FromQuery] string Name, [FromQuery] int Gender)
+        {
+
+
+            return await fileUploadService.IaiAddPerso(CordId, Name,Gender);
+
+
+        }
         public async Task test([FromServices] ITencentCloudService fileUploadService)
         {
 
diff --git a/cylsg/cylsg.Model/UserModel/UserWorker.cs b/cylsg/cylsg.Model/UserModel/UserWorker.cs
index 6eba7b5..e0ba6bc 100644
--- a/cylsg/cylsg.Model/UserModel/UserWorker.cs
+++ b/cylsg/cylsg.Model/UserModel/UserWorker.cs
@@ -99,5 +99,11 @@
         [SugarColumn(ColumnDescription = "浜鸿劯搴撳悕绉�", IsNullable = true)]
         public string? IAIGroupName { get; set; }
 
+        /// <summary>
+        /// 鎬у埆    0浠h〃鏈~鍐欙紝1浠h〃鐢锋�э紝2浠h〃濂虫�с��
+        /// </summary>
+        [SugarColumn(ColumnDescription = "浜鸿劯搴撳悕绉�", IsNullable = true)]
+        public long? Gender { get; set; } = 0;
+
     }
 }

--
Gitblit v1.9.1