From 5b48cb28d135b501a478bcb9dd34c03246d9db9f Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Tue, 27 Jun 2023 14:58:10 +0800 Subject: [PATCH] update --- .../Identity/Controllers/UserController.cs | 6 ++++++ .../Identity/Entities/SystemManagement/User.cs | 1 + docs/demo/src/WTA.Shared/Domain/BaseEntity.cs | 1 + .../src/WTA.Shared/Extensions/JsonSchemaExtensions.cs | 11 ++++++++--- .../src/WTA/wwwroot/components/form/form-input.js | 3 +++ .../demo/src/WTA/wwwroot/components/form/form-item.js | 5 +++-- docs/demo/src/WTA/wwwroot/components/list/index.js | 2 +- 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/docs/demo/src/WTA.Application/Identity/Controllers/UserController.cs b/docs/demo/src/WTA.Application/Identity/Controllers/UserController.cs index ea2075b1..3e771c42 100644 --- a/docs/demo/src/WTA.Application/Identity/Controllers/UserController.cs +++ b/docs/demo/src/WTA.Application/Identity/Controllers/UserController.cs @@ -19,6 +19,12 @@ public class UserController : GenericController UserRoles { get; set; } = new List(); } diff --git a/docs/demo/src/WTA.Shared/Domain/BaseEntity.cs b/docs/demo/src/WTA.Shared/Domain/BaseEntity.cs index 1ae6adec..e969165b 100644 --- a/docs/demo/src/WTA.Shared/Domain/BaseEntity.cs +++ b/docs/demo/src/WTA.Shared/Domain/BaseEntity.cs @@ -59,5 +59,6 @@ public abstract class BaseEntity : IResource, IBaseEntity, ISoftDeleteEntity, IA [ScaffoldColumn(false)] public string? TenantId { get; set; } + [ScaffoldColumn(false)] public Dictionary Properties { get; set; } = new Dictionary(); } diff --git a/docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs b/docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs index c665006a..7e712780 100644 --- a/docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs +++ b/docs/demo/src/WTA.Shared/Extensions/JsonSchemaExtensions.cs @@ -66,7 +66,8 @@ public static class JsonSchemaExtensions if (modelType != meta.ElementMetadata!.ModelType.UnderlyingSystemType) { schema.Add("type", "array"); - //schema.Add("items", meta.ElementMetadata!.ModelType.GetMetadataForType(serviceProvider)); + schema.TryAdd("multiple", true); + schema.TryAdd("url", "url"); schema.Add("items", meta.ElementMetadata.GetSchema(serviceProvider, meta)); } } @@ -184,7 +185,12 @@ public static class JsonSchemaExtensions var actionContext = new ActionContext { HttpContext = serviceProvider.GetRequiredService().HttpContext! }; var provider = new EmptyModelMetadataProvider(); var modelValidationContextBase = new ModelValidationContextBase(actionContext, meta, new EmptyModelMetadataProvider()); - if (pm.IsRequired && !pm.IsNullableValueType && !pm.UnderlyingOrModelType.IsValueType && !pm.Attributes.Attributes.Any(o => o.GetType() == typeof(RequiredAttribute))) + if (pm.IsRequired && + !pm.IsNullableValueType && + !pm.UnderlyingOrModelType.IsValueType && + !pm.IsEnumerableType && + !pm.Attributes.Attributes.Any(o => o.GetType() == typeof(RequiredAttribute)) + ) { var message = string.Format(CultureInfo.InvariantCulture, localizer.GetString(nameof(RequiredAttribute)).Value, title); rules.Add(new Dictionary { { "required", true }, { "message", message } }); @@ -234,7 +240,6 @@ public static class JsonSchemaExtensions else if (attribute is RequiredAttribute) { rule.Add("required", true); - //message = string.Format(CultureInfo.InvariantCulture, localizer.GetString(nameof(RequiredAttribute)).Value, title); } else if (attribute is CompareAttribute compare)//?? { diff --git a/docs/demo/src/WTA/wwwroot/components/form/form-input.js b/docs/demo/src/WTA/wwwroot/components/form/form-input.js index 02911edf..5a83e378 100644 --- a/docs/demo/src/WTA/wwwroot/components/form/form-input.js +++ b/docs/demo/src/WTA/wwwroot/components/form/form-input.js @@ -83,6 +83,9 @@ export default { return schema.input ?? schema.type; }; /*end*/ + // if (props.schema.url && !props.schema.options) { + // props.schema.options = (await post(props.schema.url)).map((o) => ({ label: o.name, value: o })); + // } return { model, getDisabled, diff --git a/docs/demo/src/WTA/wwwroot/components/form/form-item.js b/docs/demo/src/WTA/wwwroot/components/form/form-item.js index 3a2984a1..f4a12281 100644 --- a/docs/demo/src/WTA/wwwroot/components/form/form-item.js +++ b/docs/demo/src/WTA/wwwroot/components/form/form-item.js @@ -3,13 +3,14 @@ import { ref, reactive, watch } from "vue"; import AppFormInput from "./form-input.js"; export default { + name: "formItem", components: { AppFormInput }, template: html`