From 71ca916df8f5ed4e9c4a55fc71ae2618ec8b5994 Mon Sep 17 00:00:00 2001 From: liu liang Date: Fri, 28 Jul 2023 23:29:28 +0800 Subject: [PATCH 1/2] update datainit,linkchange with bind value, api controller return 403 when no right --- src/WalkingTec.Mvvm.Core/DataContext.cs | 1 + .../Filters/PrivilegeFilter.cs | 12 +++- src/WalkingTec.Mvvm.Mvc/framework_layui.js | 66 +++++++++++++------ .../Form/CheckBoxTagHelper.cs | 30 ++------- .../Form/RadioTagHelper.cs | 6 +- 5 files changed, 68 insertions(+), 47 deletions(-) diff --git a/src/WalkingTec.Mvvm.Core/DataContext.cs b/src/WalkingTec.Mvvm.Core/DataContext.cs index f28298788..aa59c8c92 100644 --- a/src/WalkingTec.Mvvm.Core/DataContext.cs +++ b/src/WalkingTec.Mvvm.Core/DataContext.cs @@ -197,6 +197,7 @@ public async override Task DataInit(object allModules, bool IsSpa) if (item != null) { item.ModuleName += "Api"; + item.ShowOnMenu = false; apifolder.Children.Add(item); } diff --git a/src/WalkingTec.Mvvm.Mvc/Filters/PrivilegeFilter.cs b/src/WalkingTec.Mvvm.Mvc/Filters/PrivilegeFilter.cs index 732fe6929..ccba8ce82 100644 --- a/src/WalkingTec.Mvvm.Mvc/Filters/PrivilegeFilter.cs +++ b/src/WalkingTec.Mvvm.Mvc/Filters/PrivilegeFilter.cs @@ -194,6 +194,10 @@ public override void OnActionExecuting(ActionExecutingContext context) { context.Result = ctrl.Forbid(JwtBearerDefaults.AuthenticationScheme); } + else if(controller is BaseApiController bac) + { + context.Result = bac.Forbid(); + } else { ContentResult cr = new ContentResult() @@ -234,8 +238,12 @@ public override void OnActionExecuting(ActionExecutingContext context) { context.Result = ctrl.Forbid(JwtBearerDefaults.AuthenticationScheme); } - else - { + else if (controller is BaseApiController bac) + { + context.Result = bac.Forbid(); + } + else + { ContentResult cr = new ContentResult() { Content = MvcProgram._localizer["Sys.NoPrivilege"], diff --git a/src/WalkingTec.Mvvm.Mvc/framework_layui.js b/src/WalkingTec.Mvvm.Mvc/framework_layui.js index 8334b1a0b..195158800 100644 --- a/src/WalkingTec.Mvvm.Mvc/framework_layui.js +++ b/src/WalkingTec.Mvvm.Mvc/framework_layui.js @@ -678,16 +678,28 @@ window.ff = { if (usedefaultvalue == true) { df = eval(comboid + "defaultvalues"); } - window[comboid].update({ data: ff.getComboItems(data.Data,df) }); + window[comboid].update({ data: ff.getComboItems(data.Data, df, usedefaultvalue) }); } if (controltype === "checkbox") { for (i = 0; i < data.Data.length; i++) { item = data.Data[i]; - if (item.Selected === true) { - target.append(""); - } + if (usedefaultvalue == true) { + var df = []; + df = eval(comboid + "defaultvalues"); + if (df.indexOf(item.Value) > -1) { + target.append(""); + } + else { + target.append(""); + } + } else { - target.append(""); + if (item.Selected === true) { + target.append(""); + } + else { + target.append(""); + } } } form.render('checkbox', targetfilter); @@ -695,11 +707,23 @@ window.ff = { if (controltype === "radio") { for (i = 0; i < data.Data.length; i++) { item = data.Data[i]; - if (item.Selected === true) { - target.append(""); - } + if (usedefaultvalue == true) { + var df = []; + df = eval(comboid + "defaultvalues"); + if (df.indexOf(item.Value) > -1) { + target.append(""); + } + else { + target.append(""); + } + } else { - target.append(""); + if (item.Selected === true) { + target.append(""); + } + else { + target.append(""); + } } } form.render('radio', targetfilter); @@ -1224,22 +1248,24 @@ window.ff = { return rv; }, - getComboItems: function (data, svals) { + getComboItems: function (data, svals, useDefaultvalue) { var rv = []; if (svals == undefined || svals == null) { svals = []; } - for (var i = 0; i < data.length; i++) { - var item = {}; - item.value = data[i].Value; - item.name = data[i].Text; - item.disabled = data[i].Disabled; - item.selected = data[i].Selected || svals.indexOf(data[i].Value) > -1; - item.icon = data[i].Icon; - if (data[i].Children != null && data[i].Children.length > 0) { - item.children = this.getTreeItems(data[i].Children, svals); + if (data != null) { + for (var i = 0; i < data.length; i++) { + var item = {}; + item.value = data[i].Value; + item.name = data[i].Text; + item.disabled = data[i].Disabled; + item.selected = useDefaultvalue == true ? svals.indexOf(data[i].Value) > -1 : data[i].Selected; + item.icon = data[i].Icon; + if (data[i].Children != null && data[i].Children.length > 0) { + item.children = this.getTreeItems(data[i].Children, svals); + } + rv.push(item); } - rv.push(item); } return rv; }, diff --git a/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/CheckBoxTagHelper.cs b/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/CheckBoxTagHelper.cs index 1cfeeb43a..bda054ef8 100644 --- a/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/CheckBoxTagHelper.cs +++ b/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/CheckBoxTagHelper.cs @@ -137,29 +137,6 @@ public override void Process(TagHelperContext context, TagHelperOutput output) }); } } - try - { - List checkvalue = null; - //如果是Entity.xxList[0].xxxid的格式,使用GetPropertySiblingValues方法获取Entity.xxxList.Select(x=>x.xxxid).ToList()的结果 - if (Field.Name.Contains("[")) - { - //默认多对多不必填 - if (Required == null) - { - Required = false; - } - } - else if (Field.Model is IList == false && Field.Model != null) - { - checkvalue = new List { Field.Model.ToString() }; - } - else - { - } - } - catch - { - } } SetSelected(listItems, values); } @@ -181,7 +158,12 @@ public override void Process(TagHelperContext context, TagHelperOutput output) output.PostContent.AppendHtml($@" "); } - output.PostElement.AppendHtml($@""); + output.PostElement.AppendHtml($@" + + +"); base.Process(context, output); } diff --git a/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/RadioTagHelper.cs b/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/RadioTagHelper.cs index 8290d1bb3..74f9206f4 100644 --- a/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/RadioTagHelper.cs +++ b/src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/RadioTagHelper.cs @@ -131,7 +131,11 @@ public override void Process(TagHelperContext context, TagHelperOutput output) var item = listItems[i]; var selected = item.Selected ? " checked" : " "; output.PostContent.AppendHtml($@" - "); + + +"); } base.Process(context, output); From d95eeafea318f27ee98ccd7ddaf012f875da4b62 Mon Sep 17 00:00:00 2001 From: liu liang Date: Fri, 28 Jul 2023 23:33:20 +0800 Subject: [PATCH 2/2] 5.10.30 --- CHANGELOG.md | 11 +++++++++++ version.props | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a22bcc2ce..8ba48c277 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## v6.x.x +##6.3.30(2023-7-28) +* **修改:** 修复创建默认数据库时,默认菜单Api方法的菜单显示为false +* **修改:** 修复了LayUI模式联动会覆盖初始绑定的数据的问题 +* **修改:** 继承BaseApiController的控制器没有权限的时候会返回403错误 + ##6.3.29(2023-6-29) * **修改:** 默认的Json序列化,数字类型仍然会被输出为字符串,这是因为很多前端控件都需要对比字符串 * **修改:** 修复了LayUI模式下导出之后搜索的问题 @@ -187,6 +192,12 @@ ## v5.x.x +##5.10.30(2023-7-28) +* **修改:** 修复创建默认数据库时,默认菜单Api方法的菜单显示为false +* **修改:** 修复了LayUI模式联动会覆盖初始绑定的数据的问题 +* **修改:** 继承BaseApiController的控制器没有权限的时候会返回403错误 + + ##5.10.29(2023-6-29) * **修改:** 默认的Json序列化,数字类型仍然会被输出为字符串,这是因为很多前端控件都需要对比字符串 * **修改:** 修复了LayUI模式下导出之后搜索的问题 diff --git a/version.props b/version.props index 62c7adfd9..3b3494020 100644 --- a/version.props +++ b/version.props @@ -1,6 +1,6 @@ - 5.10.29 + 5.10.30