diff --git a/.gitignore b/.gitignore index be46788..6fd12c3 100644 --- a/.gitignore +++ b/.gitignore @@ -267,3 +267,5 @@ __pycache__/ /ZR.Admin.WebApi/wwwroot/export /ZR.Vue/src/views/business/Gendemo.vue /ZR.Admin.WebApi/Properties/launchSettings.json +/ZR.Admin.WebApi/ZRAdmin.xml +/ZR.Admin.WebApi/DataProtection diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs index 591d78f..d331494 100644 --- a/ZR.Admin.WebApi/Controllers/CommonController.cs +++ b/ZR.Admin.WebApi/Controllers/CommonController.cs @@ -37,7 +37,7 @@ namespace ZR.Admin.WebApi.Controllers /// 心跳 /// /// - [HttpGet, Route("health/index")] + [HttpGet] public IActionResult Health() { return SUCCESS(true); diff --git a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs index 6c993d3..c6f9ce9 100644 --- a/ZR.Admin.WebApi/Controllers/System/ArticleController.cs +++ b/ZR.Admin.WebApi/Controllers/System/ArticleController.cs @@ -16,7 +16,7 @@ using System; namespace ZR.Admin.WebApi.Controllers { /// - /// T4代码自动生成 + /// 文章管理 /// [Verify] [Route("article")] diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs index 6687616..1e07704 100644 --- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs +++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs @@ -143,17 +143,19 @@ namespace ZR.Admin.WebApi.Controllers.System string uuid = Guid.NewGuid().ToString().Replace("-", ""); SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff"); + var captchaOff = sysConfig?.ConfigValue ?? "0"; + var code = SecurityCodeHelper.GetRandomEnDigitalText(4); byte[] imgByte; - if (sysConfig.ConfigValue == "1") + if (captchaOff == "1") { imgByte = SecurityCodeHelper.GetGifEnDigitalCodeByte(code);//动态gif数字字母 } - else if (sysConfig.ConfigValue == "2") + else if (captchaOff == "2") { imgByte = SecurityCodeHelper.GetGifBubbleCodeByte(code);//动态gif泡泡 } - else if (sysConfig.ConfigValue == "3") + else if (captchaOff == "3") { imgByte = SecurityCodeHelper.GetBubbleCodeByte(code);//泡泡 } diff --git a/ZR.Admin.WebApi/DataProtection/key-b6498f45-218a-4853-a182-0e86942ab496.xml b/ZR.Admin.WebApi/DataProtection/key-b6498f45-218a-4853-a182-0e86942ab496.xml deleted file mode 100644 index 71c92b8..0000000 --- a/ZR.Admin.WebApi/DataProtection/key-b6498f45-218a-4853-a182-0e86942ab496.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 2021-08-02T06:58:41.3050198Z - 2021-08-02T06:58:41.2698484Z - 2021-10-31T06:58:41.2698484Z - - - - - - - gmFBOJQxBXoKTqyvLeEnS6IDsf61vG/s0krHG1MfcZwQlu/D2XUaCms+xzpFc2c2JGdaJh5LiLIyJuoRR20Mug== - - - - \ No newline at end of file diff --git a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs index 40f9d49..31042e7 100644 --- a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs +++ b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs @@ -27,11 +27,16 @@ namespace ZR.Admin.WebApi.Extensions Version = "v1", Description = "", }); - //if (CurrentEnvironment.IsDevelopment()) - //{ - //添加文档注释 - c.IncludeXmlComments(Path.Combine(hostEnvironment.ContentRootPath, "ZRAdmin.xml"), true); - //} + try + { + //添加文档注释 + c.IncludeXmlComments(Path.Combine(hostEnvironment.ContentRootPath, "ZRAdmin.xml"), true); + } + catch (Exception ex) + { + Console.WriteLine("swagger 文档加载失败" + ex.Message); + } + //参考文章:http://www.zyiz.net/tech/detail-134965.html //需要安装包Swashbuckle.AspNetCore.Filters // 开启权限小锁 需要在对应的Action上添加[Authorize]才能看到 diff --git a/ZR.Admin.WebApi/Startup.cs b/ZR.Admin.WebApi/Startup.cs index 7e334ba..e8b4b86 100644 --- a/ZR.Admin.WebApi/Startup.cs +++ b/ZR.Admin.WebApi/Startup.cs @@ -32,7 +32,7 @@ namespace ZR.Admin.WebApi Configuration = configuration; CurrentEnvironment = hostEnvironment; } - + private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); private IWebHostEnvironment CurrentEnvironment { get; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) @@ -167,13 +167,14 @@ namespace ZR.Admin.WebApi }); //ʽ ӡSQL - DbScoped.SugarScope.GetConnection("0").Aop.OnLogExecuting = (sql, pars) => + DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuting = (sql, pars) => { - Console.WriteLine("SQL䡿" + sql.ToLower() + "\r\n" - + DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); + var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)); + //Console.WriteLine("SQL䡿" + sql.ToLower() + "\r\n" + param); + logger.Info($"Sql䣺{sql}{param}"); }; //ӡ־ - DbScoped.SugarScope.GetConnection("0").Aop.OnError = (e) => + DbScoped.SugarScope.GetConnection(0).Aop.OnError = (e) => { Console.WriteLine($"[ִSql]{e.Message}SQL={e.Sql}"); Console.WriteLine(); @@ -182,14 +183,14 @@ namespace ZR.Admin.WebApi //ʽ ӡSQL DbScoped.SugarScope.GetConnection(1).Aop.OnLogExecuting = (sql, pars) => { - Console.WriteLine("SQLBus" + sql.ToLower() + "\r\n" - + DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); + var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)); + //Console.WriteLine("SQLBus" + sql.ToLower() + "\r\n" + param); + logger.Info($"Sql䣺{sql}, {param}"); }; //Bus Db־ DbScoped.SugarScope.GetConnection(1).Aop.OnError = (e) => { - Console.WriteLine($"[ִSqlBus]{e.Message}SQL={e.Sql}"); - Console.WriteLine(); + logger.Error($"ִSqlʧܣ{e.Sql}ԭ{e.Message}"); }; } } diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj index 07c5a31..0b71c00 100644 --- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj +++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj @@ -60,6 +60,9 @@ Always + + PreserveNewest + diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json index b8dcce0..bd00d8f 100644 --- a/ZR.Admin.WebApi/appsettings.json +++ b/ZR.Admin.WebApi/appsettings.json @@ -15,7 +15,7 @@ "urls": "http://localhost:8888", //Ŀurl "sysConfig": { "DBCommandTimeout": 10, - "cors": "http://localhost:8887" //ַ"," + "cors": "http://localhost:8887" //ַǰĿ"," }, "JwtSettings": { "Issuer": "https://localhost:8888", diff --git a/ZR.Admin.WebApi/build.bat b/ZR.Admin.WebApi/build.bat index f3d0008..5aa4fb6 100644 --- a/ZR.Admin.WebApi/build.bat +++ b/ZR.Admin.WebApi/build.bat @@ -1,6 +1,6 @@ @echo off -docker build -t ZRAdmin:latest -f ./Dockerfile . +docker build -t ZRAdmin.NET:latest -f ./Dockerfile . echo "==============鿴===========" docker images diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt index 8d53e48..91f9590 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt @@ -52,7 +52,7 @@ namespace ${options.ApiControllerNamespace}.Controllers //搜索条件查询语法参考Sqlsugar ${QueryCondition} -$if(genTable.SortField != "") +$if(genTable.SortField != "" && genTable.SortField != null) var response = _${replaceDto.ModelTypeName}Service.GetPages(predicate.ToExpression(), parm, x => x.${genTable.SortField}, "${genTable.SortType}"); $else var response = _${replaceDto.ModelTypeName}Service.GetPages(predicate.ToExpression(), parm); @@ -160,25 +160,23 @@ ${end} string sFileName = ExportExcel(list, "${replaceDto.ModelTypeName}", "${genTable.FunctionName}"); return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); } - -$if(genTable.SortField != "") - /// - /// 保存排序 - /// - /// - /// - /// - [ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:update")] - [HttpGet("ChangeSort")] - [Log(Title = "保存排序", BusinessType = BusinessType.UPDATE)] - public IActionResult ChangeSort(int id = 0, int orderNum = 0) - { - if (id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); } - - bool result = _${replaceDto.ModelTypeName}Service.Update(w => w.${replaceDto.PKName} == id, it => new ${replaceDto.ModelTypeName}() { ${genTable.SortField} = orderNum });; +$if(genTable.SortField != "" && genTable.SortField != null) + ////// + ////// 代码自动生成(不用可删除) 保存排序 + ////// + ////// + ////// + ////// + /////[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:update")] + //////[HttpGet("ChangeSort")] + /////[Log(Title = "保存排序", BusinessType = BusinessType.UPDATE)] + //public IActionResult ChangeSort(int id = 0, int orderNum = 0) + //{ + // if (id <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); } + // bool result = _${replaceDto.ModelTypeName}Service.Update(w => w.${replaceDto.PKName} == id, it => new ${replaceDto.ModelTypeName}() { ${genTable.SortField} = orderNum });; - return SUCCESS(result); - } + // return SUCCESS(result); + //} $end } } \ No newline at end of file diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt index 52b05d7..68c509a 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt @@ -23,12 +23,12 @@ ${end} public class ${replaceDto.ModelTypeName}QueryDto : PagerInfo { $foreach(item in genTable.Columns) -$if(item.IsQuery) +$if(item.IsQuery && item.htmlType == "datetime") + public DateTime? Begin$item.CsharpField { get; set; } + public DateTime? End$item.CsharpField { get; set; } +$elseif(item.IsQuery) public $item.CsharpType $item.CsharpField { get; set; } $end ${end} - - public DateTime? BeginTime { get; set; } - public DateTime? EndTime { get; set; } } } diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt index 32197e9..8f42fec 100644 --- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt +++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVue.txt @@ -20,7 +20,10 @@ ${vueQueryFormHtml} 删除 -$if(genTable.SortField != "") + + 导出 + +$if(genTable.SortField != "" && 1 == 2) 修改排序 @@ -30,7 +33,7 @@ $end - + ${VueViewListContent}