From 696ce4fe53f10ec1dac772e6fb01283319e033bc Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Sun, 5 Feb 2023 15:28:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(cli):=20=E8=A7=86=E5=9B=BE=E9=A1=B5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BF=9D=E5=AD=98=E6=95=B0=E6=8D=AE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Cli/UI/Vben/VbenViewScriptGenerator.cs | 38 +++++++++++++++++-- .../Properties/launchSettings.json | 4 +- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs index 88797708c..a2474a5c3 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/LINGYUN/Abp/Cli/UI/Vben/VbenViewScriptGenerator.cs @@ -26,11 +26,30 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen .Select(module => module.Value) .FirstOrDefault(); + var updateAction = controllerModel.Actions + .Where(action => action.Value.Name.Contains("UpdateAsync")) + .Select(action => action.Value) + .FirstOrDefault(); + var createAction = controllerModel.Actions + .Where(action => action.Value.Name.Contains("CreateAsync")) + .Select(action => action.Value) + .FirstOrDefault(); + var getAction = controllerModel.Actions + .Where(action => action.Value.Name.Contains("GetAsync")) + .Select(action => action.Value) + .FirstOrDefault(); + var modalContent = await _templateRenderer.RenderAsync( "VbenModalView", new { Key = "id", + HasCreate = createAction != null, + GetAction = getAction?.UniqueName ?? "GetAsyncById", + CreateAction = createAction?.UniqueName ?? "CreateAsyncByInput", + HasUpdate = updateAction != null, + UpdateAction = updateAction?.UniqueName ?? "UpdateAsyncByIdAndInput", + HasSubmit = createAction != null || updateAction != null, Application = controllerModel.ControllerName, ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}", RemoteService = moduleDefinition.RemoteServiceName, @@ -62,6 +81,10 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen .Where(action => action.Value.Name.Contains("UpdateAsync")) .Select(action => action.Value) .FirstOrDefault(); + var createAction = controllerModel.Actions + .Where(action => action.Value.Name.Contains("CreateAsync")) + .Select(action => action.Value) + .FirstOrDefault(); var tableContent = await _templateRenderer.RenderAsync( "VbenTableView", @@ -69,10 +92,17 @@ public class VbenViewScriptGenerator : IVbenViewScriptGenerator, ISingletonDepen { Key = "id", PagedRequest = pagedResultAction != null, - UpdatePermission = updateAction != null && updateAction.AllowAnonymous != null && updateAction.AllowAnonymous != true, - UpdatePermissionName = $"{moduleDefinition.RemoteServiceName.ToKebabCase()}.{controllerModel.ControllerName.ToKebabCase()}.Update", - DeletePermission = deleteAction != null && deleteAction.AllowAnonymous != null && deleteAction.AllowAnonymous != true, - DeletePermissionName = $"{moduleDefinition.RemoteServiceName.ToKebabCase()}.{controllerModel.ControllerName.ToKebabCase()}.Delete", + GetListAction = pagedResultAction?.UniqueName ?? "GetListAsyncByInput", + HasCreate = createAction != null, + CreatePermission = true, + CreatePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Create", + HasUpdate = updateAction != null, + UpdatePermission = true, + UpdatePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Update", + HasDelete = deleteAction != null, + DeleteAction = deleteAction?.UniqueName ?? "DeleteAsyncById", + DeletePermission = true, + DeletePermissionName = $"{moduleDefinition.RemoteServiceName.ToPascalCase()}.{controllerModel.ControllerName.ToPascalCase()}.Delete", Application = controllerModel.ControllerName, ModalName = $"{controllerModel.ControllerName.ToPascalCase()}Modal", ApiPath = $"/@/api/{moduleDefinition.RemoteServiceName.ToKebabCase()}/{controllerModel.ControllerName.ToKebabCase()}", diff --git a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json index c80a9844a..bd56229eb 100644 --- a/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json +++ b/aspnet-core/modules/cli/LINGYUN.Abp.Cli/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "LINGYUN.Abp.Cli": { "commandName": "Project", - "commandLineArgs": "generate-view -t vben-view -m auditing -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/" - //"commandLineArgs": "generate-proxy -t ts -asp uni-app-axios -u http://127.0.0.1:30025 -m Platform -o D:\\Projects\\Development\\type-script" + "commandLineArgs": "generate-view -t vben-view -m task-management -o D:\\Projects\\Development\\view-script -url http://127.0.0.1:30000/" + // "commandLineArgs": "generate-proxy -t ts -asp vben-dynamic -u http://127.0.0.1:30000 -m task-management -o D:\\Projects\\Development\\type-script" } } } \ No newline at end of file