username@email.com
2024-08-27 f2f61fdb9a81fba256b1bd05330fbbac2633149a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using 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 正面  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 正面  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代表未填写,1代表男性,2代表女性。</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>
        /// 获取到客户端的IPv4
        /// </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; }
 
    }
}