diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
index 962ee57..b406c49 100644
--- a/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/AuthController.cs
@@ -17,21 +17,16 @@ namespace TakeoutSaaS.AdminApi.Controllers;
///
/// 管理后台认证接口
///
+///
+///
+///
+///
[ApiVersion("1.0")]
[Authorize]
[Route("api/admin/v{version:apiVersion}/auth")]
-public sealed class AuthController : BaseApiController
+public sealed class AuthController(IAdminAuthService authService) : BaseApiController
{
- private readonly IAdminAuthService _authService;
- ///
- ///
- ///
- ///
- public AuthController(IAdminAuthService authService)
- {
- _authService = authService;
- }
///
/// 登录获取 Token
@@ -41,7 +36,7 @@ public sealed class AuthController : BaseApiController
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
public async Task> Login([FromBody] AdminLoginRequest request, CancellationToken cancellationToken)
{
- var response = await _authService.LoginAsync(request, cancellationToken);
+ var response = await authService.LoginAsync(request, cancellationToken);
return ApiResponse.Ok(response);
}
@@ -53,7 +48,7 @@ public sealed class AuthController : BaseApiController
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
public async Task> RefreshToken([FromBody] RefreshTokenRequest request, CancellationToken cancellationToken)
{
- var response = await _authService.RefreshTokenAsync(request, cancellationToken);
+ var response = await authService.RefreshTokenAsync(request, cancellationToken);
return ApiResponse.Ok(response);
}
@@ -72,7 +67,7 @@ public sealed class AuthController : BaseApiController
return ApiResponse.Error(ErrorCodes.Unauthorized, "Token 缺少有效的用户标识");
}
- var profile = await _authService.GetProfileAsync(userId, cancellationToken);
+ var profile = await authService.GetProfileAsync(userId, cancellationToken);
return ApiResponse.Ok(profile);
}
}
diff --git a/src/Api/TakeoutSaaS.AdminApi/Controllers/DictionaryController.cs b/src/Api/TakeoutSaaS.AdminApi/Controllers/DictionaryController.cs
index f63c273..d98e420 100644
--- a/src/Api/TakeoutSaaS.AdminApi/Controllers/DictionaryController.cs
+++ b/src/Api/TakeoutSaaS.AdminApi/Controllers/DictionaryController.cs
@@ -12,21 +12,16 @@ namespace TakeoutSaaS.AdminApi.Controllers;
///
/// 参数字典管理。
///
+///
+/// 初始化字典控制器。
+///
+/// 字典服务
[ApiVersion("1.0")]
[Authorize]
[Route("api/admin/v{version:apiVersion}/dictionaries")]
-public sealed class DictionaryController : BaseApiController
+public sealed class DictionaryController(IDictionaryAppService dictionaryAppService) : BaseApiController
{
- private readonly IDictionaryAppService _dictionaryAppService;
- ///
- /// 初始化字典控制器。
- ///
- /// 字典服务
- public DictionaryController(IDictionaryAppService dictionaryAppService)
- {
- _dictionaryAppService = dictionaryAppService;
- }
///
/// 查询字典分组。
@@ -36,7 +31,7 @@ public sealed class DictionaryController : BaseApiController
[ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)]
public async Task>> GetGroups([FromQuery] DictionaryGroupQuery query, CancellationToken cancellationToken)
{
- var groups = await _dictionaryAppService.SearchGroupsAsync(query, cancellationToken);
+ var groups = await dictionaryAppService.SearchGroupsAsync(query, cancellationToken);
return ApiResponse>.Ok(groups);
}
@@ -48,7 +43,7 @@ public sealed class DictionaryController : BaseApiController
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
public async Task> CreateGroup([FromBody] CreateDictionaryGroupRequest request, CancellationToken cancellationToken)
{
- var group = await _dictionaryAppService.CreateGroupAsync(request, cancellationToken);
+ var group = await dictionaryAppService.CreateGroupAsync(request, cancellationToken);
return ApiResponse.Ok(group);
}
@@ -60,7 +55,7 @@ public sealed class DictionaryController : BaseApiController
[ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)]
public async Task> UpdateGroup(long groupId, [FromBody] UpdateDictionaryGroupRequest request, CancellationToken cancellationToken)
{
- var group = await _dictionaryAppService.UpdateGroupAsync(groupId, request, cancellationToken);
+ var group = await dictionaryAppService.UpdateGroupAsync(groupId, request, cancellationToken);
return ApiResponse.Ok(group);
}
@@ -72,7 +67,7 @@ public sealed class DictionaryController : BaseApiController
[ProducesResponseType(typeof(ApiResponse