From f1d67864470069ef22c9844f0041392a19890fe5 Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Thu, 26 Nov 2020 20:29:05 +0800 Subject: [PATCH 1/7] =?UTF-8?q?update=20WaterCloud.Web/Areas/SystemOrganiz?= =?UTF-8?q?e/Controllers/RoleAuthorizeController.cs.=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemOrganize/Controllers/RoleAuthorizeController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WaterCloud.Web/Areas/SystemOrganize/Controllers/RoleAuthorizeController.cs b/WaterCloud.Web/Areas/SystemOrganize/Controllers/RoleAuthorizeController.cs index 9d813c36..f3b0bd42 100644 --- a/WaterCloud.Web/Areas/SystemOrganize/Controllers/RoleAuthorizeController.cs +++ b/WaterCloud.Web/Areas/SystemOrganize/Controllers/RoleAuthorizeController.cs @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright © 2020 WaterCloud.Framework 版权所有 * Author: WaterCloud * Description: WaterCloud快速开发平台 @@ -93,6 +93,7 @@ namespace WaterCloud.Web.Areas.SystemOrganize.Controllers return ResultDTree(treeList.TreeList()); } [HttpPost] + [IgnoreAntiforgeryToken] public async Task GetPermissionFieldsTree(string roleId,string moduleids) { var current = _moduleService.currentuser; -- Gitee From 3ca1baaf246b6c5a69820531ce156d1960a402b1 Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Fri, 27 Nov 2020 08:03:16 +0800 Subject: [PATCH 2/7] no commit message --- WaterCloud.Web/WaterCloud.Web.csproj | 7 ------- 1 file changed, 7 deletions(-) diff --git a/WaterCloud.Web/WaterCloud.Web.csproj b/WaterCloud.Web/WaterCloud.Web.csproj index 6d3aa697..55d29f85 100644 --- a/WaterCloud.Web/WaterCloud.Web.csproj +++ b/WaterCloud.Web/WaterCloud.Web.csproj @@ -12,13 +12,6 @@ AnyCPU - - - - - - - -- Gitee From 6bc85372c97d1721dc447c729200b9624809ff4e Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Fri, 27 Nov 2020 08:05:06 +0800 Subject: [PATCH 3/7] no commit message --- WaterCloud.WebApi/WaterCloud.WebApi.csproj | 7 ------- 1 file changed, 7 deletions(-) diff --git a/WaterCloud.WebApi/WaterCloud.WebApi.csproj b/WaterCloud.WebApi/WaterCloud.WebApi.csproj index 30a9ffdf..9f5051ff 100644 --- a/WaterCloud.WebApi/WaterCloud.WebApi.csproj +++ b/WaterCloud.WebApi/WaterCloud.WebApi.csproj @@ -17,13 +17,6 @@ D:\C#\WaterCloud_Core\WaterCloud.WebApi\WaterCloud.WebApi.xml - - - - - - - -- Gitee From d7777ff9326a0fe760d9006530cc954acb1d38a3 Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Fri, 27 Nov 2020 13:01:59 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A=20(=E5=A4=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8=E8=B0=A8=E6=85=8E=E4=BD=BF=E7=94=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterCloud.Data/Repository/IRepositoryBase.T.cs | 6 ++++++ WaterCloud.Data/Repository/IRepositoryBase.cs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/WaterCloud.Data/Repository/IRepositoryBase.T.cs b/WaterCloud.Data/Repository/IRepositoryBase.T.cs index 70c0a063..11aa3fe2 100644 --- a/WaterCloud.Data/Repository/IRepositoryBase.T.cs +++ b/WaterCloud.Data/Repository/IRepositoryBase.T.cs @@ -36,6 +36,12 @@ namespace WaterCloud.DataBase Task> FindList(Expression> predicate, Pagination pagination); Task> OrderList(IQuery query, Pagination pagination); Task> OrderList(IQuery query, SoulPage pagination); + /// + /// 缓存查询列表(大数据表谨慎使用) + /// + /// + /// + /// Task> CheckCacheList(string cacheKey, long old = 0); Task CheckCache(string cacheKey, string keyValue, long old = 0); } diff --git a/WaterCloud.Data/Repository/IRepositoryBase.cs b/WaterCloud.Data/Repository/IRepositoryBase.cs index 3e599073..a2e3546c 100644 --- a/WaterCloud.Data/Repository/IRepositoryBase.cs +++ b/WaterCloud.Data/Repository/IRepositoryBase.cs @@ -143,7 +143,7 @@ namespace WaterCloud.DataBase /// Task CheckCache(string cacheKey, string keyValue, long old = 0) where TEntity : class; /// - /// 缓存查询列表 + /// 缓存查询列表(大数据表谨慎使用) /// /// /// -- Gitee From 47de5bd362407c875e218f578f486ae6ef3b75da Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Fri, 27 Nov 2020 15:38:42 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E7=AC=AC=E4=B8=89=E6=96=B9=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterCloud.Service/CommonService/FlowRuntime.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/WaterCloud.Service/CommonService/FlowRuntime.cs b/WaterCloud.Service/CommonService/FlowRuntime.cs index f8d6c4ba..94244b3c 100644 --- a/WaterCloud.Service/CommonService/FlowRuntime.cs +++ b/WaterCloud.Service/CommonService/FlowRuntime.cs @@ -441,12 +441,9 @@ namespace WaterCloud.Service.CommonService execTime = tag.TagedTime, isFinish = currentNodeType == 4 }; - - using (HttpContent httpContent = new StringContent(postData.ToJson(), Encoding.UTF8)) - { - httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); - client.PostAsync(currentNode.setInfo.ThirdPartyUrl, httpContent); - } + HttpContent httpContent = new StringContent(postData.ToJson(), Encoding.UTF8); + httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + client.PostAsync(currentNode.setInfo.ThirdPartyUrl, httpContent); } #endregion 共有方法 -- Gitee From 7129113d8607365a8e92a1d1c2a1e2ea90b9a3b0 Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Fri, 27 Nov 2020 15:49:33 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=BC=82=E6=AD=A5=E4=BB=A5=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=BD=A2=E5=BC=8F=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WaterCloud.Service/TimeService/TimedService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WaterCloud.Service/TimeService/TimedService.cs b/WaterCloud.Service/TimeService/TimedService.cs index bc85fed0..d338da5a 100644 --- a/WaterCloud.Service/TimeService/TimedService.cs +++ b/WaterCloud.Service/TimeService/TimedService.cs @@ -59,7 +59,7 @@ namespace WaterCloud.Service.TimeService entity.F_CPU = computer.CPURate; entity.F_IIS = "0"; entity.F_WebSite = _hostingEnvironment.ContentRootPath; - new ServerStateService(_context).SubmitForm(entity); + new ServerStateService(_context).SubmitForm(entity).GetAwaiter().GetResult(); } public override void Dispose() -- Gitee From da889d65e8c4704ad0ecbd6dbdd06fb5a038495d Mon Sep 17 00:00:00 2001 From: MonstorUncle <295228902@qq.com> Date: Mon, 30 Nov 2020 12:58:19 +0800 Subject: [PATCH 7/7] =?UTF-8?q?1.6.0=20=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20api=E5=A2=9E=E5=8A=A0=E5=BF=BD=E7=95=A5=E6=9D=83?= =?UTF-8?q?=E9=99=90=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Template/SingleTableTemplate.cs | 101 +++++++++++++++--- .../Repository/IRepositoryBase.T.cs | 4 +- WaterCloud.Data/Repository/IRepositoryBase.cs | 2 +- .../Repository/RepositoryBase.T.cs | 2 +- WaterCloud.Data/Repository/RepositoryBase.cs | 2 +- .../Controllers/CodeGeneratorController.cs | 47 +++++++- .../Filter/AuthorizeFilterAttribute.cs | 17 +-- 7 files changed, 142 insertions(+), 33 deletions(-) diff --git a/WaterCloud.CodeGenerator/Template/SingleTableTemplate.cs b/WaterCloud.CodeGenerator/Template/SingleTableTemplate.cs index 797dd754..ed82a4f2 100644 --- a/WaterCloud.CodeGenerator/Template/SingleTableTemplate.cs +++ b/WaterCloud.CodeGenerator/Template/SingleTableTemplate.cs @@ -131,9 +131,28 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" /// " + remark); sb.AppendLine(" /// "); sb.AppendLine(" /// "); - if (idColumn== column) + if (idColumn == column) { - sb.AppendLine(" [ColumnAttribute(\""+ column + "\", IsPrimaryKey = true)]"); + + if (datatype == "int?") + { + sb.AppendLine(" [AutoIncrement]"); + sb.AppendLine(" [Column(\"" + column + "\", IsPrimaryKey = true)]"); + sb.AppendLine(" public int " + column + " { get; set; }"); + } + else if (datatype == "long?") + { + sb.AppendLine(" [Column(\"" + column + "\", IsPrimaryKey = true)]"); + sb.AppendLine(" public long " + column + " { get; set; }"); + } + else + { + sb.AppendLine(" [Column(\"" + column + "\", IsPrimaryKey = true)]"); + } + } + else + { + sb.AppendLine(" public " + datatype + " " + column + " { get; set; }"); } //switch (datatype) //{ @@ -145,7 +164,7 @@ namespace WaterCloud.CodeGenerator // sb.AppendLine(" [JsonConverter(typeof(DateTimeJsonConverter))]"); // break; //} - sb.AppendLine(" public " + datatype + " " + column + " { get; set; }"); + } sb.AppendLine(" }"); sb.AppendLine("}"); @@ -155,7 +174,7 @@ namespace WaterCloud.CodeGenerator #endregion #region BuildService - public string BuildService(BaseConfigModel baseConfigModel, DataTable dt, string idColumn = "F_Id") + public string BuildService(BaseConfigModel baseConfigModel, DataTable dt, string idColumn = "F_Id",string idType="int",string deleteMarkField="IsDelete",string createTimeField="AddTime") { var baseEntity = GetBaseEntity(baseConfigModel.FileConfig.EntityName, dt, idColumn); StringBuilder sb = new StringBuilder(); @@ -192,7 +211,7 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" //此处需修改"); sb.AppendLine(" cachedata = cachedata.Where(t => t.F_FullName.Contains(keyword) || t.F_EnCode.Contains(keyword)).ToList();"); sb.AppendLine(" }"); - sb.AppendLine(" return cachedata.Where(t => t.F_DeleteMark == false).OrderByDescending(t => t.F_CreatorTime).ToList();"); + sb.AppendLine($" return cachedata.Where(t => t.{deleteMarkField} == false).OrderByDescending(t => t.{createTimeField}).ToList();"); sb.AppendLine(" }"); sb.AppendLine(); sb.AppendLine(" public async Task> GetLookList(string keyword = \"\")"); @@ -212,10 +231,10 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" //此处需修改"); sb.AppendLine(" list = list.Where(u => u.F_FullName.Contains(keyword) || u.F_EnCode.Contains(keyword)).ToList();"); sb.AppendLine(" }"); - sb.AppendLine(" return GetFieldsFilterData(list.Where(t => t.F_DeleteMark == false).OrderByDescending(t => t.F_CreatorTime).ToList(),className.Substring(0, className.Length - 7));"); + sb.AppendLine($" return GetFieldsFilterData(list.Where(t => t.{deleteMarkField} == false).OrderByDescending(t => t.{createTimeField}).ToList(),className.Substring(0, className.Length - 7));"); sb.AppendLine(" }"); sb.AppendLine(); - sb.AppendLine(" public async Task> GetLookList(SoulPage<"+ baseConfigModel.FileConfig.EntityName + "> pagination,string keyword = \"\")"); + sb.AppendLine(" public async Task> GetLookList(SoulPage<"+ baseConfigModel.FileConfig.EntityName + "> pagination,string keyword = \"\","+idType+" id=\"\")"); sb.AppendLine(" {"); sb.AppendLine(" //获取数据权限"); sb.AppendLine(" var list = GetDataPrivilege(\"u\", className.Substring(0, className.Length - 7));"); @@ -224,7 +243,18 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" //此处需修改"); sb.AppendLine(" list = list.Where(u => u.F_FullName.Contains(keyword) || u.F_EnCode.Contains(keyword));"); sb.AppendLine(" }"); - sb.AppendLine(" list = list.Where(u => u.F_DeleteMark==false);"); + sb.AppendLine($" list = list.Where(u => u.{deleteMarkField}==false);"); + if (idType == "int" || idType == "long") + { + sb.AppendLine(" if(id==0)"); + } + else + { + sb.AppendLine(" if(string.IsNullOrEmpty(id))"); + } + sb.AppendLine(" {"); + sb.AppendLine(" list= list.Where(u=>u." + idColumn + "==id);"); + sb.AppendLine(" }"); sb.AppendLine(" return GetFieldsFilterData(await repository.OrderList(list, pagination),className.Substring(0, className.Length - 7));"); sb.AppendLine(" }"); sb.AppendLine(); @@ -235,7 +265,7 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" }"); sb.AppendLine(" #endregion"); sb.AppendLine(); - sb.AppendLine(" public async Task<" + baseConfigModel.FileConfig.EntityName + "> GetLookForm(string keyValue)"); + sb.AppendLine(" public async Task<" + baseConfigModel.FileConfig.EntityName + "> GetLookForm(object keyValue)"); sb.AppendLine(" {"); sb.AppendLine(" var cachedata = await repository.CheckCache(cacheKey, keyValue);"); sb.AppendLine(" return GetFieldsFilterData(cachedata,className.Substring(0, className.Length - 7));"); @@ -247,10 +277,36 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" if (string.IsNullOrEmpty(keyValue))"); sb.AppendLine(" {"); sb.AppendLine(" //此处需修改"); - sb.AppendLine(" entity.F_DeleteMark = false;"); + sb.AppendLine($" entity.{deleteMarkField} = false;"); + sb.AppendLine($" entity.{createTimeField} = DateTime.Now;"); + foreach (DataRow dr in dt.Rows) + { + string column = dr["TableColumn"].ToString(); + if (column != idColumn) + { + if (!baseConfigModel.PageForm.FieldList.Keys.Contains(column)) + { + if (column != deleteMarkField && column != createTimeField) + { + sb.AppendLine($" entity.{column} = //添写初始化参数;"); + } + } + } + } if (string.IsNullOrEmpty(baseEntity)) { - sb.AppendLine(" entity."+ idColumn + "=Utils.GuId();"); + if (idType == "int") + { + sb.AppendLine(" entity." + idColumn + "=0;"); + } + else if (idType == "long") + { + sb.AppendLine(" entity." + idColumn + "=0;"); + } + else + { + sb.AppendLine(" entity." + idColumn + "=Utils.GuId();"); + } } else { @@ -264,7 +320,18 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" //此处需修改"); if (string.IsNullOrEmpty(baseEntity)) { - sb.AppendLine(" entity." + idColumn + "=keyValue;"); + if (idType == "int") + { + sb.AppendLine(" entity." + idColumn + "=Convert.ToInt32(keyValue);"); + } + else if (idType == "long") + { + sb.AppendLine(" entity." + idColumn + "=Convert.ToInt64(keyValue);"); + } + else + { + sb.AppendLine(" entity." + idColumn + "=keyValue;"); + } } else { @@ -279,7 +346,7 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" public async Task DeleteForm(string keyValue)"); sb.AppendLine(" {"); sb.AppendLine(" var ids = keyValue.Split(',');"); - sb.AppendLine(" await repository.Delete(t => ids.Contains(t." + idColumn + "));"); + sb.AppendLine(" await repository.Delete(t => ids.Contains(t." + idColumn + ".ToString()));"); sb.AppendLine(" foreach (var item in ids)"); sb.AppendLine(" {"); sb.AppendLine(" await CacheHelper.Remove(cacheKey + item);"); @@ -296,7 +363,7 @@ namespace WaterCloud.CodeGenerator #endregion #region BuildController - public string BuildController(BaseConfigModel baseConfigModel, string idColumn="F_Id") + public string BuildController(BaseConfigModel baseConfigModel, string idColumn="F_Id",string idType="string",string createTimeField="AddTime") { StringBuilder sb = new StringBuilder(); sb.AppendLine("using System;"); @@ -364,7 +431,7 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(" {"); sb.AppendLine(" if (string.IsNullOrEmpty(pagination.field))"); sb.AppendLine(" {"); - sb.AppendLine(" pagination.field = \"F_CreatorTime\";"); + sb.AppendLine($" pagination.field = \"{createTimeField}\";"); sb.AppendLine(" pagination.order = \"desc\";"); sb.AppendLine(" }"); sb.AppendLine(" var data = await _service.GetLookList(pagination,keyword);"); @@ -382,7 +449,7 @@ namespace WaterCloud.CodeGenerator sb.AppendLine(); sb.AppendLine(" [HttpGet]"); sb.AppendLine(" [HandlerAjaxOnly]"); - sb.AppendLine(" public async Task GetFormJson(string keyValue)"); + sb.AppendLine($" public async Task GetFormJson({idType} keyValue)"); sb.AppendLine(" {"); sb.AppendLine(" var data = await _service.GetLookForm(keyValue);"); sb.AppendLine(" return Content(data.ToJson());"); @@ -1254,7 +1321,7 @@ namespace WaterCloud.CodeGenerator } #endregion - private string GetBaseEntity(string EntityName, DataTable dt,string idColumn="F_Id") + private string GetBaseEntity(string EntityName, DataTable dt,string idColumn="F_Id",string deleteMarkField="IsDelete",string AddTime="AddTime") { string entity = string.Empty; var columnList = dt.AsEnumerable().Select(p => p["TableColumn"].ParseToString()).ToList(); diff --git a/WaterCloud.Data/Repository/IRepositoryBase.T.cs b/WaterCloud.Data/Repository/IRepositoryBase.T.cs index 11aa3fe2..03f32d81 100644 --- a/WaterCloud.Data/Repository/IRepositoryBase.T.cs +++ b/WaterCloud.Data/Repository/IRepositoryBase.T.cs @@ -1,4 +1,4 @@ -/******************************************************************************* +/******************************************************************************* * Copyright © 2020 WaterCloud.Framework 版权所有 * Author: WaterCloud * Description: WaterCloud快速开发平台 @@ -43,6 +43,6 @@ namespace WaterCloud.DataBase /// /// Task> CheckCacheList(string cacheKey, long old = 0); - Task CheckCache(string cacheKey, string keyValue, long old = 0); + Task CheckCache(string cacheKey, object keyValue, long old = 0); } } diff --git a/WaterCloud.Data/Repository/IRepositoryBase.cs b/WaterCloud.Data/Repository/IRepositoryBase.cs index a2e3546c..28de158b 100644 --- a/WaterCloud.Data/Repository/IRepositoryBase.cs +++ b/WaterCloud.Data/Repository/IRepositoryBase.cs @@ -141,7 +141,7 @@ namespace WaterCloud.DataBase /// /// /// - Task CheckCache(string cacheKey, string keyValue, long old = 0) where TEntity : class; + Task CheckCache(string cacheKey, object keyValue, long old = 0) where TEntity : class; /// /// 缓存查询列表(大数据表谨慎使用) /// diff --git a/WaterCloud.Data/Repository/RepositoryBase.T.cs b/WaterCloud.Data/Repository/RepositoryBase.T.cs index 9fd8a570..f89f46bd 100644 --- a/WaterCloud.Data/Repository/RepositoryBase.T.cs +++ b/WaterCloud.Data/Repository/RepositoryBase.T.cs @@ -156,7 +156,7 @@ namespace WaterCloud.DataBase } return cachedata; } - public async Task CheckCache(string cacheKey, string keyValue, long old = 0) + public async Task CheckCache(string cacheKey, object keyValue, long old = 0) { var cachedata = await CacheHelper.Get(cacheKey + keyValue); if (cachedata == null) diff --git a/WaterCloud.Data/Repository/RepositoryBase.cs b/WaterCloud.Data/Repository/RepositoryBase.cs index 32c6a01d..05cf2b03 100644 --- a/WaterCloud.Data/Repository/RepositoryBase.cs +++ b/WaterCloud.Data/Repository/RepositoryBase.cs @@ -247,7 +247,7 @@ namespace WaterCloud.DataBase return cachedata; } - public async Task CheckCache(string cacheKey, string keyValue, long old = 0) where TEntity : class + public async Task CheckCache(string cacheKey, object keyValue, long old = 0) where TEntity : class { var cachedata = await CacheHelper.Get(cacheKey + keyValue); if (cachedata == null) diff --git a/WaterCloud.Web/Areas/SystemManage/Controllers/CodeGeneratorController.cs b/WaterCloud.Web/Areas/SystemManage/Controllers/CodeGeneratorController.cs index 1b2e581e..32726cca 100644 --- a/WaterCloud.Web/Areas/SystemManage/Controllers/CodeGeneratorController.cs +++ b/WaterCloud.Web/Areas/SystemManage/Controllers/CodeGeneratorController.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Web; using System.Data; using Microsoft.AspNetCore.Mvc; @@ -137,20 +137,59 @@ namespace WaterCloud.Web.Areas.SystemManage.Controllers baseConfig.PageIndex.ButtonList=ExtList.removeNull(baseConfig.PageIndex.ButtonList); baseConfig.PageIndex.ColumnList.Remove(""); baseConfig.PageForm.FieldList.Remove(""); + string idType = "string"; + //扩展删除字段和创建时间字段 + string[] isDeleteMarkFieldNames = new[] { "F_DeleteMark", "IsDelete" }; + string[] createTimeFieldNames = new[] { "F_CreatorTime", "AddTime" }; + + string isDeleteMarkField = "F_DeleteMark"; + string createTimeField = "F_CreatorTime"; foreach (DataRow dr in dt.Rows) { + if (dr["TableIdentity"].ToString() == "Y") { idcolumn = dr["TableColumn"].ToString(); + string datatype = dr["Datatype"].ToString(); + datatype = TableMappingHelper.GetPropertyDatatype(datatype); + if (datatype == "int?") + { + idType = "int"; + } + else if (datatype == "long?") + { + idType = "long"; + } + else + { + idType = "string"; + } + } + string columnName = dr["TableColumn"].ToString(); + foreach(var isDeleteMarkFieldName in isDeleteMarkFieldNames) + { + if (string.Compare(isDeleteMarkFieldName, columnName, true) == 0) + { + isDeleteMarkField = columnName; + } + } + foreach (var createTimeFieldName in createTimeFieldNames) + { + if (string.Compare(createTimeFieldName, columnName, true) == 0) + { + createTimeField = columnName; + } } } + + string codeEntity = template.BuildEntity(baseConfig, dt, idcolumn); - string codeService = template.BuildService(baseConfig,dt, idcolumn); - string codeController = template.BuildController(baseConfig, idcolumn); + string codeService = template.BuildService(baseConfig,dt, idcolumn,idType,isDeleteMarkField,createTimeField); + string codeController = template.BuildController(baseConfig, idcolumn,idType, createTimeField); string codeIndex = template.BuildIndex(baseConfig, idcolumn); string codeForm = template.BuildForm(baseConfig); string codeDetails = template.BuildDetails(baseConfig); - string codeMenu = template.BuildMenu(baseConfig); + string codeMenu = template.BuildMenu(baseConfig,idcolumn); var json = new { CodeEntity = HttpUtility.HtmlEncode(codeEntity), diff --git a/WaterCloud.WebApi/Filter/AuthorizeFilterAttribute.cs b/WaterCloud.WebApi/Filter/AuthorizeFilterAttribute.cs index c4fe1a67..4092124c 100644 --- a/WaterCloud.WebApi/Filter/AuthorizeFilterAttribute.cs +++ b/WaterCloud.WebApi/Filter/AuthorizeFilterAttribute.cs @@ -1,15 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; +using System.Diagnostics; using System.Linq; -using System.Net.Http; -using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using System.Reflection; using Microsoft.AspNetCore.Mvc.Filters; -using Newtonsoft.Json; using WaterCloud.Code; +using Microsoft.AspNetCore.Authorization; namespace WaterCloud.WebApi { @@ -36,6 +32,13 @@ namespace WaterCloud.WebApi string token = context.HttpContext.Request.Headers[GlobalContext.SystemConfig.TokenName].ParseToString(); OperatorModel user = OperatorProvider.Provider.GetCurrent(); + var description = + (Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)context.ActionDescriptor; + + //添加有允许匿名的Action,可以不用登录访问,如Login/Index + //控制器整体忽略或者单独方法忽略 + var anonymous = description.ControllerTypeInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute)); + var methodanonymous = description.MethodInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute)); if (user != null) { // 根据传入的Token,添加token和客户参数 @@ -61,7 +64,7 @@ namespace WaterCloud.WebApi } } } - else + else if (anonymous == null && methodanonymous == null) { AjaxResult obj = new AjaxResult(); obj.message = "抱歉,没有操作权限"; -- Gitee