Merge branch 'master' of https://gitea.nxsir.cn/nanxun/IM_NEW
This commit is contained in:
@@ -8,11 +8,13 @@ namespace GroupService.WebApi.Application.Group
|
||||
public class GroupService
|
||||
{
|
||||
private readonly IGroupReposity reposity;
|
||||
private readonly IGroupMemberReposity memberReposity;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public GroupService(IGroupReposity reposity, IMapper mapper)
|
||||
public GroupService(IGroupReposity reposity, IGroupMemberReposity memberReposity, IMapper mapper)
|
||||
{
|
||||
this.reposity = reposity;
|
||||
this.memberReposity = memberReposity;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@@ -39,5 +41,19 @@ namespace GroupService.WebApi.Application.Group
|
||||
|
||||
return Result<GroupResponse>.Success(mapper.Map<GroupResponse>(group));
|
||||
}
|
||||
|
||||
public async Task<Result<GroupResponse>> UpdateAsync(GroupUpdateCommand command)
|
||||
{
|
||||
var group = await reposity.FindByIdAsync(command.GroupId);
|
||||
if(group is null)
|
||||
return Result.Fail<GroupResponse>(ResultCode.GROUP_NOT_FOUND);
|
||||
|
||||
var isAdmin = await memberReposity.CheckMemberAdminAsync(group.Id ,command.UserId);
|
||||
if (!isAdmin)
|
||||
return Result.Fail<GroupResponse>(ResultCode.ADMIN_PERMISSION_DENIED);
|
||||
|
||||
group.Update(command.GroupName, null, command.Description, command.Avatar);
|
||||
return Result.Success(mapper.Map<GroupResponse>(group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace GroupService.WebApi.Application.Group
|
||||
{
|
||||
public record GroupUpdateCommand(Guid UserId, Guid GroupId, string? Avatar, string? GroupName, string? Description);
|
||||
}
|
||||
Reference in New Issue
Block a user