| | |
| | | using Furion.DynamicApiController; |
| | | using Furion.FriendlyException; |
| | | using Furion.HttpRemote; |
| | | using Furion.Logging; |
| | | using Furion.Logging.Extensions; |
| | | using Mapster; |
| | | using MediatR; |
| | | using Microsoft.AspNetCore.Mvc; |
| | |
| | | var model = new ResourceModel(); |
| | | model.TraceId = traceId; |
| | | model.ApplicationName = resourceService.ApplicationName; |
| | | model.Controller = controller; |
| | | model.ControllerName = resourceController.ControllerName; |
| | | model.ControllerSummary = resourceControllers.GetDescription(controller); |
| | | model.ActionName = Regex.Replace(request.Name, @"(Command|Query)$", "", RegexOptions.None); |
| | | model.ActionSummary = requestXmlDoc?.Summary; |
| | | model.Service = resourceController.Service; |
| | | model.ServiceName = resourceService.ServiceName; |
| | | model.RouteArea = resourceService.RouteArea; |
| | | model.Route = $"/api/{resourceService.RouteArea ?? "main"}/{controller}/{model.ActionName}"; |
| | | model.Route = $"/api/{resourceService.RouteArea ?? "main"}/{model.ControllerName}/{model.ActionName}"; |
| | | model.Method = |
| | | resourceAttribute.Method.HasValue |
| | | ? resourceAttribute.Method.Value |
| | | resourceAttribute.Method != EnumResourceMethod.None |
| | | ? resourceAttribute.Method |
| | | : request.BaseType?.IsGenericType == true && request.BaseType.GetGenericTypeDefinition() == typeof(PagedListQuery<,>) |
| | | ? EnumResourceMethod.Post |
| | | : new List<string> { "Post", "Add", "Create", "Insert", "Submit" }.Any(it => request.Name.StartsWith(it, StringComparison.OrdinalIgnoreCase)) |
| | |
| | | .GroupBy(it => new |
| | | { |
| | | it.ApplicationName, |
| | | it.Controller, |
| | | it.ControllerName, |
| | | it.ControllerSummary, |
| | | it.RouteArea |
| | | }) |
| | |
| | | using System.ComponentModel; |
| | | |
| | | |
| | | namespace {controller.Key.ApplicationName}.{controller.Key.Controller} |
| | | namespace {controller.Key.ApplicationName}.{controller.Key.ControllerName} |
| | | {{ |
| | | /// <summary> |
| | | /// {controller.Key.ControllerSummary} |
| | | /// </summary> |
| | | [Route(""api/{controller.Key.RouteArea}/[controller]"")] |
| | | public class {controller.Key.Controller}AppService(IMediator mediator) : IDynamicApiController |
| | | public class {controller.Key.ControllerName}AppService(IMediator mediator) : IDynamicApiController |
| | | {{ |
| | | private readonly IMediator mediator = mediator;"; |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(code); |
| | | code.LogError(ex); |
| | | throw; |
| | | } |
| | | } |