From 4ce691641ff8d95053347807504c04e9fd6fd602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BD=BB=E9=A3=8E2016?= <616036448@qq.com> Date: Wed, 28 Aug 2024 16:24:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dweb=5Fapi=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=8D=E7=A7=B0=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/template/service_Service.cs.vm | 13 ++++++++++--- .../wwwroot/template/web_api.ts.vm | 11 +++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm index 80fe7c18..26ea6097 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm @@ -214,7 +214,7 @@ if(@column.EffectType == "fk" && (@column.WhetherAddUpdate == "Y" || column.Quer @:/// 获取@(@column.ColumnComment)列表 @:/// @:/// - @:[ApiDescriptionSettings(Name = "@(@column.FkEntityName)@(@column.PropertyName)Dropdown", Description = "获取@(@column.ColumnComment)列表", Order = 940), HttpGet] + @:[ApiDescriptionSettings(Name = "@(LowerFirstLetter(@column.FkEntityName))@(@column.PropertyName)Dropdown", Description = "获取@(@column.ColumnComment)列表", Order = 940), HttpGet] @:[DisplayName("获取@(@column.ColumnComment)列表")] @:public async Task> @(@column.FkEntityName)@(@column.PropertyName)Dropdown() @:{ @@ -236,7 +236,7 @@ if(@column.EffectType == "Upload"){ @:/// @:/// @:/// - @:[ApiDescriptionSettings(Name = "Upload@(@column.PropertyName)", Description = "上传@(@column.ColumnComment)", Order = 930), HttpPost] + @:[ApiDescriptionSettings(Name = "upload@(@column.PropertyName)", Description = "上传@(@column.ColumnComment)", Order = 930), HttpPost] @:[DisplayName("上传@(@column.ColumnComment)")] @:public async Task Upload@(@column.PropertyName)([Required] IFormFile file) @:{ @@ -249,7 +249,7 @@ if(@column.EffectType == "Upload"){ @foreach (var column in Model.TableField){ if(@column.EffectType == "ApiTreeSelect" && !definedObjects.ContainsKey("@(@column.FkEntityName)Tree")){ @{definedObjects.Add("@(@column.FkEntityName)Tree", 1);} - @:[ApiDescriptionSettings(Name = ""@(@column.FkEntityName)Tree"", Description = "获取@(@column.ColumnComment)列表", Order = 920), HttpGet] + @:[ApiDescriptionSettings(Name = "@(LowerFirstLetter(@column.FkEntityName))Tree", Description = "获取@(@column.ColumnComment)列表", Order = 920), HttpGet] @:[DisplayName("获取@(@column.FkEntityName)Tree")] @:public async Task @(@column.FkEntityName)Tree() @:{ @@ -286,3 +286,10 @@ if(@column.EffectType == "ApiTreeSelect" && !definedObjects.ContainsKey("@(@colu } } + +@{ +string LowerFirstLetter(string text) +{ +return text.ToString()[..1].ToLower() + text[1..]; // 首字母小写 +} +} diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_api.ts.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_api.ts.vm index e53cab1a..f16aefb5 100644 --- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_api.ts.vm +++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_api.ts.vm @@ -23,10 +23,10 @@ enum Api { } @foreach (var column in Model.TableField){ if(@column.EffectType == "fk" && (@column.WhetherAddUpdate == "Y" || column.QueryWhether == "Y")){ - @:Get@(@column.FkEntityName)@(@column.PropertyName)Dropdown = '/api/@(@Model.LowerClassName)/@(@column.FkEntityName)@(@column.PropertyName)Dropdown', + @:Get@(@column.FkEntityName)@(@column.PropertyName)Dropdown = '/api/@(@Model.LowerClassName)/@(LowerFirstLetter(@column.FkEntityName))@(@column.PropertyName)Dropdown', }else if(@column.EffectType == "ApiTreeSelect" && !definedObjects.ContainsKey("Get@(@column.FkEntityName)Tree")){ @{definedObjects.Add("Get@(@column.FkEntityName)Tree", 1);} - @:Get@(@column.FkEntityName)Tree = '/api/@(@Model.LowerClassName)/@(@column.FkEntityName)Tree', + @:Get@(@column.FkEntityName)Tree = '/api/@(@Model.LowerClassName)/@(LowerFirstLetter(@column.FkEntityName))Tree', }else if(@column.EffectType == "Upload"){ @:Upload@(@column.PropertyName) = '/api/@(@Model.LowerClassName)/upload@(@column.PropertyName)', } @@ -136,4 +136,11 @@ if(@column.EffectType == "Upload"){ @:method: 'post', @:data: params, @:}); +} + +@{ +string LowerFirstLetter(string text) +{ +return text.ToString()[..1].ToLower() + text[1..]; // 首字母小写 +} } \ No newline at end of file