From 3cae5fb50ec203a48740ce0752c94a7cda884e94 Mon Sep 17 00:00:00 2001 From: chenqian2008 <39323100+chenqian2008@users.noreply.github.com> Date: Mon, 26 Oct 2020 10:46:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/BuilderTableApp.cs | 37 ++++++++++--------- OpenAuth.WebApi/Template/BuildApp.html | 14 +++---- .../Template/BuildControllerApi.html | 12 +++--- OpenAuth.WebApi/Template/BuildEntity.html | 5 ++- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/OpenAuth.App/BuilderTableApp.cs b/OpenAuth.App/BuilderTableApp.cs index 5032a5c..2730a04 100644 --- a/OpenAuth.App/BuilderTableApp.cs +++ b/OpenAuth.App/BuilderTableApp.cs @@ -262,7 +262,7 @@ namespace OpenAuth.App .Replace("{ModuleName}", sysTableInfo.ModuleName) .Replace("{ClassName}", sysTableInfo.ClassName) .Replace("{StartName}", StratName); - FileHelper.WriteFile(appRootPath, sysTableInfo.ModuleCode + ".cs", domainContent); + FileHelper.WriteFile(appRootPath, sysTableInfo.ModuleCode + "App.cs", domainContent); } /// @@ -297,9 +297,9 @@ namespace OpenAuth.App { attributeBuilder.Append("/// "); attributeBuilder.Append("\r\n"); - attributeBuilder.Append(" ///" + column.Comment + ""); + attributeBuilder.Append(" ///" + column.Comment + ""); attributeBuilder.Append("\r\n"); - attributeBuilder.Append(" /// "); + attributeBuilder.Append(" /// "); attributeBuilder.Append("\r\n"); string entityType = column.EntityType; @@ -308,7 +308,7 @@ namespace OpenAuth.App entityType = entityType + "?"; } - attributeBuilder.Append(" public " + entityType + " " + column.EntityName + " { get; set; }"); + attributeBuilder.Append(" public " + entityType + " " + column.EntityName + " { get; set; }"); attributeBuilder.Append("\r\n\r\n "); } @@ -318,9 +318,9 @@ namespace OpenAuth.App var tableAttr = new StringBuilder(); tableAttr.Append("/// "); tableAttr.Append("\r\n"); - tableAttr.Append(" ///" + sysTableInfo.Comment + ""); + tableAttr.Append(" ///" + sysTableInfo.Comment + ""); tableAttr.Append("\r\n"); - tableAttr.Append(" /// "); + tableAttr.Append("/// "); tableAttr.Append("\r\n"); domainContent = domainContent.Replace("{AttributeManager}", tableAttr.ToString()); @@ -371,15 +371,14 @@ namespace OpenAuth.App foreach (BuilderTableColumn column in sysColumn) { if (column.IsKey) continue; - attributeBuilder.Append("/// "); attributeBuilder.Append("\r\n"); - attributeBuilder.Append(" ///" + column.Comment + ""); + attributeBuilder.Append(" ///" + column.Comment + ""); attributeBuilder.Append("\r\n"); - attributeBuilder.Append(" /// "); + attributeBuilder.Append(" /// "); attributeBuilder.Append("\r\n"); - attributeBuilder.Append(" [Description(\""+ column.Comment +"\")]"); + attributeBuilder.Append(" [Description(\"" + column.Comment +"\")]"); attributeBuilder.Append("\r\n"); string entityType = column.EntityType; @@ -388,11 +387,15 @@ namespace OpenAuth.App entityType = entityType + "?"; } - attributeBuilder.Append(" public " + entityType + " " + column.EntityName + " { get; set; }"); + attributeBuilder.Append(" public " + entityType + " " + column.EntityName + " { get; set; }"); attributeBuilder.Append("\r\n\r\n "); - constructionBuilder.Append(" this." + column.EntityName - + "=" + (GetDefault(column.EntityType)??"\"\"") + if(constructionBuilder.Length>0) + { + constructionBuilder.Append(" "); + } + constructionBuilder.Append("this." + column.EntityName + + " = " + (GetDefault(column.EntityType)??"\"\"") + ";\r\n"); } @@ -413,11 +416,11 @@ namespace OpenAuth.App tableAttr.Append("/// "); tableAttr.Append("\r\n"); - tableAttr.Append(" ///" + tableInfo.Comment + ""); + tableAttr.Append(" ///" + tableInfo.Comment + ""); tableAttr.Append("\r\n"); - tableAttr.Append(" /// "); + tableAttr.Append(" /// "); tableAttr.Append("\r\n"); - tableAttr.Append(" [Table(\"" + tableInfo.TableName + "\")]"); + tableAttr.Append(" [Table(\"" + tableInfo.TableName + "\")]"); domainContent = domainContent.Replace("{AttributeManager}", tableAttr.ToString()); FileHelper.WriteFile( @@ -455,7 +458,7 @@ namespace OpenAuth.App { if (type == "DateTime") { - return "DateTime.Now;"; + return "DateTime.Now"; } return Activator.CreateInstance(t).ToString(); } diff --git a/OpenAuth.WebApi/Template/BuildApp.html b/OpenAuth.WebApi/Template/BuildApp.html index 1850d30..9bd8a15 100644 --- a/OpenAuth.WebApi/Template/BuildApp.html +++ b/OpenAuth.WebApi/Template/BuildApp.html @@ -10,7 +10,7 @@ using OpenAuth.Repository.Interface; namespace OpenAuth.App { - public class {ModuleCode} : BaseApp<{ClassName}> + public class {ModuleCode}App : BaseApp<{ClassName}> { /// @@ -21,21 +21,21 @@ namespace OpenAuth.App var loginContext = _auth.GetCurrentUser(); if (loginContext == null) { - throw new CommonException("登录已过期", Define.INVALID_TOKEN); + throw new CommonException("登录已过期", Define.INVALID_TOKEN); } var properties = loginContext.GetProperties("{ClassName}"); if (properties == null || properties.Count == 0) { - throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置"); + throw new Exception("当前登录用户没有访问该模块字段的权限,请联系管理员配置"); } var result = new TableData(); var objs = GetDataPrivilege("u"); if (!string.IsNullOrEmpty(request.key)) { - objs = objs.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key)); + objs = objs.Where(u => u.Name.Contains(request.key) || u.Id.Contains(request.key)); } var propertyStr = string.Join(',', properties.Select(u => u.Key)); @@ -51,7 +51,7 @@ namespace OpenAuth.App { //程序类型取入口应用的名称,可以根据自己需要调整 var addObj = obj.MapTo<{ClassName}>(); - //addObj.Time = DateTime.Now; + //addObj.Time = DateTime.Now; Repository.Add(addObj); } @@ -59,12 +59,12 @@ namespace OpenAuth.App { UnitWork.Update<{ClassName}>(u => u.Id == obj.Id, u => new {ClassName} { - //todo:要修改的字段赋值 + //todo:要修改的字段赋值 }); } - public {ModuleCode}(IUnitWork unitWork, IRepository<{ClassName}> repository, IAuth auth) : base(unitWork, repository, auth) + public {ModuleCode}App(IUnitWork unitWork, IRepository<{ClassName}> repository, IAuth auth) : base(unitWork, repository, auth) { } } diff --git a/OpenAuth.WebApi/Template/BuildControllerApi.html b/OpenAuth.WebApi/Template/BuildControllerApi.html index c9d933a..786284e 100644 --- a/OpenAuth.WebApi/Template/BuildControllerApi.html +++ b/OpenAuth.WebApi/Template/BuildControllerApi.html @@ -15,7 +15,7 @@ namespace OpenAuth.WebApi.Controllers [ApiController] public class {ClassName}sController : ControllerBase { - private readonly {ModuleCode} _app; + private readonly {ModuleCode}App _app; //获取详情 [HttpGet] @@ -35,8 +35,8 @@ namespace OpenAuth.WebApi.Controllers return result; } - //添加 - [HttpPost] + //添加 + [HttpPost] public Response Add(AddOrUpdate{ClassName}Req obj) { var result = new Response(); @@ -55,7 +55,7 @@ namespace OpenAuth.WebApi.Controllers } //修改 - [HttpPost] + [HttpPost] public Response Update(AddOrUpdate{ClassName}Req obj) { var result = new Response(); @@ -85,7 +85,7 @@ namespace OpenAuth.WebApi.Controllers /// /// 批量删除 /// - [HttpPost] + [HttpPost] public Response Delete([FromBody]string[] ids) { var result = new Response(); @@ -103,7 +103,7 @@ namespace OpenAuth.WebApi.Controllers return result; } - public {ClassName}sController({ModuleCode} app) + public {ClassName}sController({ModuleCode}App app) { _app = app; } diff --git a/OpenAuth.WebApi/Template/BuildEntity.html b/OpenAuth.WebApi/Template/BuildEntity.html index d6b3f57..a84199b 100644 --- a/OpenAuth.WebApi/Template/BuildEntity.html +++ b/OpenAuth.WebApi/Template/BuildEntity.html @@ -17,8 +17,9 @@ namespace OpenAuth.Repository.Domain { public {ClassName}() { - {Construction} + {Construction} } - {AttributeList} + + {AttributeList} } } \ No newline at end of file -- Gitee