服务端的TigerApi 框架,基于.NET6 2024 版本
YangYuGang
2025-03-12 8b6a2cabe0ef6cf2384537f6878964469e256eda
Tiger.Controllers.System/Controllers/Base/BaseController.cs
@@ -569,10 +569,49 @@
            {
                await file.CopyToAsync(stream);
            }
            return Ok(new { file.FileName, file.ContentType, file.Length, url= $@"{BizConfig.Configuration["DownloadAddress"]}/"+ file.FileName });
            var downloadAddress = entityName == "BAS_LABEL_TEMP" || entityName == "BAS_LABEL_VAR" ? "/Template" : "";
            return Ok(new { file.FileName, file.ContentType, file.Length, url= $@"{BizConfig.Configuration["DownloadAddress"]}{downloadAddress}/"+ file.FileName });
        }
        #endregion
        #region 导入Excel
        [HttpPost]
        public async Task<IActionResult> ImportExcel([FromBody] ApiAction<ImportInput> action)
        {
            ApiAction response;
            try
            {
                IImportExcel import = DI.Resolve(action.Data.typeFullName) as IImportExcel;
                response = action.GetResponse(await import.Import(action.NewDataEntity(),action.Data));
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
        /// <summary>
        /// 导入Excel前验证
        /// </summary>
        /// <param name="action"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ValidateTableImport([FromBody] ApiAction<ImportValidateInput> action)
        {
            ApiAction response;
            try
            {
                IImportExcel import = DI.Resolve(action.Data.typeFullName) as IImportExcel;
                response = action.GetResponse(await import.ValidateTableImport(action.NewDataEntity(), action.Data));
            }
            catch (System.Exception ex)
            {
                response = action.GetResponse().CatchExceptionWithLog(ex);
            }
            return Ok(response);
        }
        #endregion
    }
}