fix: align backend APIs and upload flow
This commit is contained in:
@@ -27,11 +27,11 @@ namespace GroupService.WebApi.Application.Group
|
||||
|
||||
public async Task<Result<List<GroupResponse>>> GetAllAsync(Guid userId)
|
||||
{
|
||||
var groups = await reposity.FindByMasterIdAsync(userId);
|
||||
var groups = await reposity.FindByMemberIdAsync(userId);
|
||||
return Result<List<GroupResponse>>.Success(mapper.Map<List<GroupResponse>>(groups));
|
||||
}
|
||||
|
||||
public async Task<Result<GroupResponse>> GetByIdAsync(Guid groupId)
|
||||
public async Task<Result<GroupResponse>> GetByIdAsync(Guid groupId, Guid userId)
|
||||
{
|
||||
var group = await reposity.FindByIdAsync(groupId);
|
||||
if (group is null)
|
||||
@@ -39,9 +39,36 @@ namespace GroupService.WebApi.Application.Group
|
||||
return Result<GroupResponse>.Fail(ResultCode.GROUP_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!await memberReposity.CheckMemberExistAsync(groupId, userId))
|
||||
{
|
||||
return Result<GroupResponse>.Fail(ResultCode.PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
return Result<GroupResponse>.Success(mapper.Map<GroupResponse>(group));
|
||||
}
|
||||
|
||||
public async Task<Result<object>> DissolveAsync(Guid groupId, Guid userId)
|
||||
{
|
||||
var group = await reposity.FindByIdAsync(groupId);
|
||||
if (group is null)
|
||||
{
|
||||
return Result.Fail(ResultCode.GROUP_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (group.GroupMaster != userId)
|
||||
{
|
||||
return Result.Fail(ResultCode.PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
var members = await memberReposity.FindByGroupIdAsync(groupId);
|
||||
foreach (var member in members)
|
||||
{
|
||||
member.Leave();
|
||||
}
|
||||
group.SoftDelete();
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
public async Task<Result<GroupResponse>> UpdateAsync(GroupUpdateCommand command)
|
||||
{
|
||||
var group = await reposity.FindByIdAsync(command.GroupId);
|
||||
|
||||
Reference in New Issue
Block a user