fix: align backend APIs and upload flow

This commit is contained in:
2026-09-11 18:18:59 +08:00
parent 32177a7293
commit 898cf5dba0
69 changed files with 1081 additions and 153 deletions
@@ -32,7 +32,8 @@ namespace GroupService.WebApi.Controllers.Group
[ProducesDefaultResponseType(typeof(Result<GroupResponse>))]
public async Task<IActionResult> GetOne(Guid groupId)
{
return Ok(await service.GetByIdAsync(groupId));
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.GetByIdAsync(groupId, Guid.Parse(userId)));
}
[HttpPost]
@@ -49,5 +50,13 @@ namespace GroupService.WebApi.Controllers.Group
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.UpdateAsync(new GroupUpdateCommand(Guid.Parse(userId), request.GroupId, request.Avatar, request.GroupName, request.Description)));
}
[HttpPost]
[UnitOfWork(typeof(GroupDbContext))]
public async Task<IActionResult> Dissolve([FromQuery] Guid groupId)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.DissolveAsync(groupId, Guid.Parse(userId)));
}
}
}
@@ -1,6 +1,8 @@
using GroupService.Infrastructure;
using GroupService.WebApi.Application.GroupMember;
using IM.ASPNETCore;
using IM.Commons;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
@@ -11,25 +13,36 @@ namespace GroupService.WebApi.Controllers.GroupMember
public class GroupMemberController : ControllerBase
{
private readonly GroupMemberService service;
private readonly IConfiguration configuration;
public GroupMemberController(GroupMemberService service)
public GroupMemberController(GroupMemberService service, IConfiguration configuration)
{
this.service = service;
this.configuration = configuration;
}
[HttpGet]
public async Task<IActionResult> CheckMember(Guid userId, Guid groupId)
{
var expectedKey = configuration["InternalApiKey"];
var suppliedKey = Request.Headers["X-Internal-Api-Key"].ToString();
if (string.IsNullOrWhiteSpace(expectedKey) || suppliedKey != expectedKey)
{
return Unauthorized(Result.Fail(ResultCode.AUTH_FAILED));
}
return Ok(await service.CheckMemberAsync(groupId, userId));
}
[HttpGet]
[Authorize]
public async Task<IActionResult> List(Guid groupId)
{
return Ok(await service.GetByGroupIdAsync(groupId));
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.GetByGroupIdAsync(groupId, Guid.Parse(userId)));
}
[HttpPost]
[Authorize]
[UnitOfWork(typeof(GroupDbContext))]
public async Task<IActionResult> Delete([FromQuery] Guid memberId)
{
@@ -37,6 +50,15 @@ namespace GroupService.WebApi.Controllers.GroupMember
return Ok(await service.DeleteAsync(memberId, Guid.Parse(userId)));
}
[HttpPost]
[Authorize]
[UnitOfWork(typeof(GroupDbContext))]
public async Task<IActionResult> Leave([FromQuery] Guid groupId)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.LeaveAsync(groupId, Guid.Parse(userId)));
}
}
}