Skip to content

Commit

Permalink
api.AppController 用注入的方式调用 Controller.AppController
Browse files Browse the repository at this point in the history
  • Loading branch information
harris2012 authored Sep 9, 2024
1 parent 12286f0 commit d178860
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/AgileConfig.Server.Apisite/Controllers/api/AppController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,23 @@ public class AppController : Controller
private readonly IPremissionService _premissionService;
private readonly IUserService _userService;

private readonly Controllers.AppController ctrl;

public AppController(IAppService appService,
IPremissionService premissionService,
IUserService userService,
IConfigService configService,
ITinyEventBus tinyEventBus)
ITinyEventBus tinyEventBus,

Controllers.AppController ctrl)
{
_appService = appService;
_premissionService = premissionService;
_userService = userService;
_configService = configService;
_tinyEventBus = tinyEventBus;

this.ctrl = ctrl;
}

/// <summary>
Expand Down Expand Up @@ -69,12 +75,6 @@ public async Task<ActionResult<IEnumerable<ApiAppVM>>> GetAll()
[HttpGet("{id}")]
public async Task<ActionResult<ApiAppVM>> GetById(string id)
{
var ctrl = new Controllers.AppController(
_appService,
_premissionService,
_userService,
_tinyEventBus
);
var result = (await ctrl.Get(id)) as JsonResult;
dynamic obj = result.Value;

Expand Down Expand Up @@ -121,12 +121,6 @@ public async Task<IActionResult> Add([FromBody] ApiAppVM model)
});
}

var ctrl = new Controllers.AppController(
_appService,
_premissionService,
_userService,
_tinyEventBus
);
ctrl.ControllerContext.HttpContext = HttpContext;

var result = (await ctrl.Add(new AppVM
Expand Down Expand Up @@ -174,12 +168,6 @@ public async Task<IActionResult> Edit(string id, [FromBody] ApiAppVM model)
});
}

var ctrl = new Controllers.AppController(
_appService,
_premissionService,
_userService,
_tinyEventBus
);
ctrl.ControllerContext.HttpContext = HttpContext;

model.Id = id;
Expand Down Expand Up @@ -215,12 +203,6 @@ public async Task<IActionResult> Edit(string id, [FromBody] ApiAppVM model)
[HttpDelete("{id}")]
public async Task<IActionResult> Delete(string id)
{
var ctrl = new Controllers.AppController(
_appService,
_premissionService,
_userService,
_tinyEventBus
);
ctrl.ControllerContext.HttpContext = HttpContext;

var result = (await ctrl.Delete(id)) as JsonResult;
Expand Down

0 comments on commit d178860

Please sign in to comment.