chore: 提交现有修改
This commit is contained in:
@@ -17,21 +17,16 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 管理后台认证接口
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="authService"></param>
|
||||
[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;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="authService"></param>
|
||||
public AuthController(IAdminAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录获取 Token
|
||||
@@ -41,7 +36,7 @@ public sealed class AuthController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<TokenResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<TokenResponse>> Login([FromBody] AdminLoginRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _authService.LoginAsync(request, cancellationToken);
|
||||
var response = await authService.LoginAsync(request, cancellationToken);
|
||||
return ApiResponse<TokenResponse>.Ok(response);
|
||||
}
|
||||
|
||||
@@ -53,7 +48,7 @@ public sealed class AuthController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<TokenResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<TokenResponse>> RefreshToken([FromBody] RefreshTokenRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _authService.RefreshTokenAsync(request, cancellationToken);
|
||||
var response = await authService.RefreshTokenAsync(request, cancellationToken);
|
||||
return ApiResponse<TokenResponse>.Ok(response);
|
||||
}
|
||||
|
||||
@@ -72,7 +67,7 @@ public sealed class AuthController : BaseApiController
|
||||
return ApiResponse<CurrentUserProfile>.Error(ErrorCodes.Unauthorized, "Token 缺少有效的用户标识");
|
||||
}
|
||||
|
||||
var profile = await _authService.GetProfileAsync(userId, cancellationToken);
|
||||
var profile = await authService.GetProfileAsync(userId, cancellationToken);
|
||||
return ApiResponse<CurrentUserProfile>.Ok(profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,21 +12,16 @@ namespace TakeoutSaaS.AdminApi.Controllers;
|
||||
/// <summary>
|
||||
/// 参数字典管理。
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 初始化字典控制器。
|
||||
/// </remarks>
|
||||
/// <param name="dictionaryAppService">字典服务</param>
|
||||
[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;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化字典控制器。
|
||||
/// </summary>
|
||||
/// <param name="dictionaryAppService">字典服务</param>
|
||||
public DictionaryController(IDictionaryAppService dictionaryAppService)
|
||||
{
|
||||
_dictionaryAppService = dictionaryAppService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字典分组。
|
||||
@@ -36,7 +31,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<DictionaryGroupDto>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyList<DictionaryGroupDto>>> GetGroups([FromQuery] DictionaryGroupQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var groups = await _dictionaryAppService.SearchGroupsAsync(query, cancellationToken);
|
||||
var groups = await dictionaryAppService.SearchGroupsAsync(query, cancellationToken);
|
||||
return ApiResponse<IReadOnlyList<DictionaryGroupDto>>.Ok(groups);
|
||||
}
|
||||
|
||||
@@ -48,7 +43,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<DictionaryGroupDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<DictionaryGroupDto>> CreateGroup([FromBody] CreateDictionaryGroupRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var group = await _dictionaryAppService.CreateGroupAsync(request, cancellationToken);
|
||||
var group = await dictionaryAppService.CreateGroupAsync(request, cancellationToken);
|
||||
return ApiResponse<DictionaryGroupDto>.Ok(group);
|
||||
}
|
||||
|
||||
@@ -60,7 +55,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<DictionaryGroupDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<DictionaryGroupDto>> 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<DictionaryGroupDto>.Ok(group);
|
||||
}
|
||||
|
||||
@@ -72,7 +67,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<object>> DeleteGroup(long groupId, CancellationToken cancellationToken)
|
||||
{
|
||||
await _dictionaryAppService.DeleteGroupAsync(groupId, cancellationToken);
|
||||
await dictionaryAppService.DeleteGroupAsync(groupId, cancellationToken);
|
||||
return ApiResponse.Success();
|
||||
}
|
||||
|
||||
@@ -85,7 +80,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
public async Task<ApiResponse<DictionaryItemDto>> CreateItem(long groupId, [FromBody] CreateDictionaryItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
request.GroupId = groupId;
|
||||
var item = await _dictionaryAppService.CreateItemAsync(request, cancellationToken);
|
||||
var item = await dictionaryAppService.CreateItemAsync(request, cancellationToken);
|
||||
return ApiResponse<DictionaryItemDto>.Ok(item);
|
||||
}
|
||||
|
||||
@@ -97,7 +92,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<DictionaryItemDto>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<DictionaryItemDto>> UpdateItem(long itemId, [FromBody] UpdateDictionaryItemRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var item = await _dictionaryAppService.UpdateItemAsync(itemId, request, cancellationToken);
|
||||
var item = await dictionaryAppService.UpdateItemAsync(itemId, request, cancellationToken);
|
||||
return ApiResponse<DictionaryItemDto>.Ok(item);
|
||||
}
|
||||
|
||||
@@ -109,7 +104,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<object>> DeleteItem(long itemId, CancellationToken cancellationToken)
|
||||
{
|
||||
await _dictionaryAppService.DeleteItemAsync(itemId, cancellationToken);
|
||||
await dictionaryAppService.DeleteItemAsync(itemId, cancellationToken);
|
||||
return ApiResponse.Success();
|
||||
}
|
||||
|
||||
@@ -120,7 +115,7 @@ public sealed class DictionaryController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<IReadOnlyDictionary<string, IReadOnlyList<DictionaryItemDto>>>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<IReadOnlyDictionary<string, IReadOnlyList<DictionaryItemDto>>>> BatchGet([FromBody] DictionaryBatchQueryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var dictionaries = await _dictionaryAppService.GetCachedItemsAsync(request, cancellationToken);
|
||||
var dictionaries = await dictionaryAppService.GetCachedItemsAsync(request, cancellationToken);
|
||||
return ApiResponse<IReadOnlyDictionary<string, IReadOnlyList<DictionaryItemDto>>>.Ok(dictionaries);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,21 +10,16 @@ namespace TakeoutSaaS.MiniApi.Controllers;
|
||||
/// <summary>
|
||||
/// 小程序登录认证
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 小程序登录认证
|
||||
/// </remarks>
|
||||
/// <param name="authService"></param>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/mini/v{version:apiVersion}/auth")]
|
||||
public sealed class AuthController : BaseApiController
|
||||
public sealed class AuthController(IMiniAuthService authService) : BaseApiController
|
||||
{
|
||||
private readonly IMiniAuthService _authService;
|
||||
|
||||
/// <summary>
|
||||
/// 小程序登录认证
|
||||
/// </summary>
|
||||
/// <param name="authService"></param>
|
||||
public AuthController(IMiniAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 微信登录
|
||||
@@ -34,7 +29,7 @@ public sealed class AuthController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<TokenResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<TokenResponse>> LoginWithWeChat([FromBody] WeChatLoginRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _authService.LoginWithWeChatAsync(request, cancellationToken);
|
||||
var response = await authService.LoginWithWeChatAsync(request, cancellationToken);
|
||||
return ApiResponse<TokenResponse>.Ok(response);
|
||||
}
|
||||
|
||||
@@ -46,7 +41,7 @@ public sealed class AuthController : BaseApiController
|
||||
[ProducesResponseType(typeof(ApiResponse<TokenResponse>), StatusCodes.Status200OK)]
|
||||
public async Task<ApiResponse<TokenResponse>> RefreshToken([FromBody] RefreshTokenRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await _authService.RefreshTokenAsync(request, cancellationToken);
|
||||
var response = await authService.RefreshTokenAsync(request, cancellationToken);
|
||||
return ApiResponse<TokenResponse>.Ok(response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,16 @@ namespace TakeoutSaaS.MiniApi.Controllers;
|
||||
/// <summary>
|
||||
/// 当前用户信息
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="authService"></param>
|
||||
[ApiVersion("1.0")]
|
||||
[Authorize]
|
||||
[Route("api/mini/v{version:apiVersion}/me")]
|
||||
public sealed class MeController : BaseApiController
|
||||
public sealed class MeController(IMiniAuthService authService) : BaseApiController
|
||||
{
|
||||
private readonly IMiniAuthService _authService;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="authService"></param>
|
||||
public MeController(IMiniAuthService authService)
|
||||
{
|
||||
_authService = authService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户档案
|
||||
@@ -46,7 +41,7 @@ public sealed class MeController : BaseApiController
|
||||
return ApiResponse<CurrentUserProfile>.Error(ErrorCodes.Unauthorized, "Token 缺少有效的用户标识");
|
||||
}
|
||||
|
||||
var profile = await _authService.GetProfileAsync(userId, cancellationToken);
|
||||
var profile = await authService.GetProfileAsync(userId, cancellationToken);
|
||||
return ApiResponse<CurrentUserProfile>.Ok(profile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user