This document explains the implementation details of Controller generation.
When selecting an entity to generate a Controller, since Controller depends on DTO and Manager, both DTO and Manager are generated first.
Generated Controllers inherit from RestControllerBase<TManager>:
[ApiExplorerSettings(GroupName = "v1")] [Authorize(Policy = WebConst.User)] public class RestControllerBase<TManager>( Localizer localizer, TManager manager, IUserContext user, ILogger logger ) : RestControllerBase(localizer) where TManager : class { protected readonly TManager _manager = manager; protected readonly ILogger _logger = logger; protected readonly IUserContext _user = user; }
Tip
Controllers have one Manager generic parameter. When multiple Manager instances are needed, you can inject additional managers directly and use them in the Controller.
Controller generation requires the following information:
Entity through DbContextParseHelper to get the EntityInfo object.SystemMod is referenced (configurable) to determine management permissions.Interface generation primarily calls related methods of Manager according to REST API specifications. Generated interface methods include:
See the RestApiGenerate class for specific implementation details and TplContent.cs for template content.
ĺ 厚大纲