From 17308f6494c81fb5a5ee035724a414ec7da11936 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 22 八月 2024 08:38:45 +0800 Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/cylsg --- cylsg/EzUpFile/UpFileController.cs | 187 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 187 insertions(+), 0 deletions(-) diff --git a/cylsg/EzUpFile/UpFileController.cs b/cylsg/EzUpFile/UpFileController.cs new file mode 100644 index 0000000..a3ee514 --- /dev/null +++ b/cylsg/EzUpFile/UpFileController.cs @@ -0,0 +1,187 @@ +锘縰sing EzTencentCloud; +using Furion.FriendlyException; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using Microsoft.IdentityModel.Abstractions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TencentCloud.Ocr.V20181119.Models; + +namespace EzUpFile +{ + /// <summary> + /// 鏂囦欢涓婁紶涓嬭浇 + /// </summary> + [DynamicApiController] + [ApiDescriptionSettings("FileUpdata")] + public class UpFileController + { + + + /// <summary> + /// 涓婁紶韬唤璇佷俊鎭� + /// </summary> + /// <param name="PageName"> 韬唤璇佹鍙嶉潰 FRONT 姝i潰 Back 鍥藉窘鍙嶉潰 </param> + /// <returns></returns> + [HttpPost] + public async Task<Object> UploadIdCord([FromServices] IEzFileUploadService fileUploadService,IFormFile file, [FromQuery] string PageName = "FRONT") + { + + + var ret= await fileUploadService.UpIdCord(PageName); + return new { Info = ret.Item1, url = ret.Item2 }; + } + + /// <summary> + /// 涓婁紶鍜岃瘑鍒惀涓氭墽鐓� + /// </summary> + /// <param name="PageName"> 韬唤璇佹鍙嶉潰 FRONT 姝i潰 Back 鍥藉窘鍙嶉潰 </param> + /// <returns></returns> + [HttpPost] + public async Task<Object> UpBizLicense([FromServices] IEzFileUploadService fileUploadService, IFormFile file) + { + + + var ret= await fileUploadService.UpBizLicense(); + return new { Info = ret.Item1, url = ret.Item2 }; + + } + /// <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<object> IaiAddPerso([FromServices] IEzFileUploadService fileUploadService, IFormFile file,[FromQuery] string CordId, [FromQuery] string Name, [FromQuery] int Gender) + { + + + var ret= await fileUploadService.IaiAddPerso(CordId, Name,Gender); + return new { IsOK = ret.Item1, url = ret.Item2 }; + + + } + + /// <summary> + /// 澧炲姞浜鸿劯搴� base64 + /// </summary> + /// <param name="param"></param> + /// <returns></returns> + [HttpPost] + public async Task<object> IaiAddPersoBase64([FromServices] IEzFileUploadService fileUploadService, UpDataFileData param) + { + if (string.IsNullOrEmpty(param.imgBase64)) + throw Oops.Oh("娌℃湁鏂囦欢绫诲"); + if (string.IsNullOrEmpty(param.Name)) + throw Oops.Oh("娌℃湁濮撳悕"); + if (string.IsNullOrEmpty(param.CordId)) + throw Oops.Oh("娌℃湁韬唤璇佷俊鎭�"); + var ret = await fileUploadService.IaiAddPerso(param.imgBase64, param.CordId, param. Name, param.Gender??0); + return new { IsOK = ret.Item1, url = ret.Item2 }; + + + } + public async Task test([FromServices] ITencentCloudService fileUploadService) + { + + fileUploadService.IaiCreatGroup(); + + } + + /// <summary> + /// 涓婁紶闄勪欢 + /// </summary> + /// <param name="fileUploadService"></param> + /// <returns></returns> + [HttpPost] + public async Task<string> UpdateFile([FromServices] IEzFileUploadService fileUploadService, IFormFile file) + { + return await fileUploadService.UploadFiles(); + } + /// <summary> + /// 鑾峰彇鍒板鎴风鐨処Pv4 + /// </summary> + /// <param name="httpContextAccessor"></param> + /// <returns></returns> + [HttpGet] + public string GetIp4([FromServices] IHttpContextAccessor httpContextAccessor) + { + var httpc = httpContextAccessor.HttpContext; + var ipv4 = httpc.GetRemoteIpAddressToIPv4(); + return ipv4; + } + /// <summary> + /// 涓婁紶闄勪欢 + /// </summary> + /// <param name="fileUploadService"></param> + /// <param name="Param"></param> + /// <returns></returns> + [HttpPost] + public async Task<string> UpdateFileBase64([FromServices] IEzFileUploadService fileUploadService, UpDataFileData Param) + { + return await fileUploadService.UploadFilesFByBase64(Param.imgBase64); + } + [HttpPost] + public async Task<bool> DelFile([FromServices] IEzFileUploadService fileUploadService, DelFileData Param) + { + return await fileUploadService.DelFile(Param.FilePath); + } + } + /// <summary> + /// 涓婁紶鏁版嵁 + /// </summary> + public class UpDataFileData + + { + /// <summary> + /// 鏁版嵁base64 + /// </summary> + public string imgBase64 { get; set; } + /// <summary> + /// 韬唤璇佸彿鐮� + /// </summary> + public string? CordId { get; set; } + /// <summary> + /// 濮撳悕 + /// </summary> + public string? Name { get; set; } + /// <summary> + /// 鎬у埆 + /// </summary> + public int? Gender { get; set; } + } + /// <summary> + /// 涓婁紶鏁版嵁 + /// </summary> + public class DelFileData + + { + /// <summary> + /// 鏁版嵁base64 + /// </summary> + public string FilePath { get; set; } + } + /// <summary> + /// 韬唤璇佽繑鍥炶緭鍑� + /// </summary> + public class IdCordOuput + { + /// <summary> + /// 韬唤璇佺浉鍏充俊鎭� + /// </summary> + public IDCardOCRResponse IdCordInfo { get; set; } + + /// <summary> + /// url + /// </summary> + public string Url { get; set; } + + } +} -- Gitblit v1.9.1