diff --git a/Infrastructure/Controllers/BaseController.cs b/Infrastructure/Controllers/BaseController.cs index 500d55f..9a88f4e 100644 --- a/Infrastructure/Controllers/BaseController.cs +++ b/Infrastructure/Controllers/BaseController.cs @@ -194,6 +194,9 @@ namespace Infrastructure.Controllers if (!Directory.Exists(fullPath)) { Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); + } + if (!Path.Exists(fullPath)) + { MiniExcel.SaveAs(fullPath, list, overwriteFile: true); } return (sFileName, fullPath); diff --git a/README.md b/README.md index 6647f00..476c11c 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,10 @@ ## 💒 代码仓库 -| 仓库 | Github | Gitee | -| -------------- | ------------------------------------------------------ | ---------------------------------------------------------------- | +| 仓库 | Github | Gitee | +| -------------- | ------------------------------------------------------ | --------------------------------------------------- | | Net7 | [克隆/下载](https://github.com/izhaorui/Zr.Admin.NET) | [克隆/下载](https://gitee.com/izory/ZrAdminNetCore) | -| Vue3(推荐使用) | [克隆/下载](https://github.com/izhaorui/ZR.Admin.Vue3) | [克隆/下载](https://gitee.com/izory/ZRAdmin-vue) | +| Vue3(推荐使用) | [克隆/下载](https://github.com/izhaorui/ZR.Admin.Vue3) | [克隆/下载](https://gitee.com/izory/ZRAdmin-vue) | ## 🍁 前端技术 @@ -72,7 +72,7 @@ Vue 版前端技术栈 :基于 vue2.x/vue3.x/uniapp、vuex、vue-router 、vue - 分库分表:使用 orm sqlsugar 可以很轻松的实现分库分库性能优越 - 多 租 户:支持多租户功能 - 缓存数据:内置内存缓存和 Redis -- signalR:使用signalr管理用户在线状态 +- signalR:使用 signalr 管理用户在线状态 ## 🍖 内置功能 @@ -195,6 +195,7 @@ Vue 版前端技术栈 :基于 vue2.x/vue3.x/uniapp、vuex、vue-router 、vue 5. 自定义的代码生成功能 6. 依赖少,上手容易 7. 文档全面 +8. 支持中文表头导入数据 ## 💐 特别鸣谢 diff --git a/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs b/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs index f0a3dc3..e24cb0e 100644 --- a/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs +++ b/ZR.Admin.WebApi/Controllers/System/CommonLangController.cs @@ -177,15 +177,16 @@ namespace ZR.Admin.WebApi.Controllers public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile) { List list = new(); + var nowTime = DateTime.Now; using (var stream = formFile.OpenReadStream()) { var rows = stream.Query(startCell: "A2").ToList(); foreach (var item in rows) { - list.Add(new CommonLang() { LangCode = "zh-cn", LangKey = item.A, LangName = item.B, Addtime = DateTime.Now }); - list.Add(new CommonLang() { LangCode = "en", LangKey = item.A, LangName = item.C, Addtime = DateTime.Now }); - list.Add(new CommonLang() { LangCode = "zh-tw", LangKey = item.A, LangName = item.D, Addtime = DateTime.Now }); + list.Add(new CommonLang() { LangCode = "zh-cn", LangKey = item.A, LangName = item.B, Addtime = nowTime }); + list.Add(new CommonLang() { LangCode = "en", LangKey = item.A, LangName = item.C, Addtime = nowTime }); + list.Add(new CommonLang() { LangCode = "zh-tw", LangKey = item.A, LangName = item.D, Addtime = nowTime }); } } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt index 96642e3..fec4063 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt @@ -171,17 +171,17 @@ $if(replaceDto.ShowBtnImport) /// /// [HttpPost("importData")] - [Log(Title = "${genTable.FunctionName}导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)] + [Log(Title = "${genTable.FunctionName}导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false)] [ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:import")] public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile) { - List<${replaceDto.ModelTypeName}> list = new(); + List<${replaceDto.ModelTypeName}Dto> list = new(); using (var stream = formFile.OpenReadStream()) { - list = stream.Query<${replaceDto.ModelTypeName}>(startCell: "A1").ToList(); + list = stream.Query<${replaceDto.ModelTypeName}Dto>(startCell: "A1").ToList(); } - return SUCCESS(_${replaceDto.ModelTypeName}Service.Import${replaceDto.ModelTypeName}(list)); + return SUCCESS(_${replaceDto.ModelTypeName}Service.Import${replaceDto.ModelTypeName}(list.Adapt>())); } /// @@ -189,11 +189,11 @@ $if(replaceDto.ShowBtnImport) /// /// [HttpGet("importTemplate")] - [Log(Title = "${genTable.FunctionName}模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = true, IsSaveResponseData = false)] + [Log(Title = "${genTable.FunctionName}模板", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] [AllowAnonymous] public IActionResult ImportTemplateExcel() { - var result = DownloadImportTemplate(new List<${replaceDto.ModelTypeName}>() { }, "${replaceDto.ModelTypeName}"); + var result = DownloadImportTemplate(new List<${replaceDto.ModelTypeName}Dto>() { }, "${replaceDto.ModelTypeName}"); return ExportExcel(result.Item2, result.Item1); } $end diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt index fa46613..802ed6f 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt @@ -39,6 +39,7 @@ $end $if(replaceDto.ShowBtnExport) $if(item.IsExport) [ExcelColumn(Name = "$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}"$if(item.CsharpType == "DateTime"), Format = "yyyy-MM-dd HH:mm:ss"$end)] + [ExcelColumnName("$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}")] $else [ExcelIgnore] $end