Merge branch 'master' of https://gitea.nxsir.cn/nanxun/IM_NEW
This commit is contained in:
@@ -28,11 +28,11 @@ namespace GroupService.WebApi.Controllers.Group
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return Ok(await service.GetAllAsync(Guid.Parse(userId)));
|
||||
}
|
||||
[HttpGet("~/api/[controller]/{userId}")]
|
||||
[HttpGet]
|
||||
[ProducesDefaultResponseType(typeof(Result<GroupResponse>))]
|
||||
public async Task<IActionResult> GetOne([FromRoute] Guid userId)
|
||||
public async Task<IActionResult> GetOne(Guid groupId)
|
||||
{
|
||||
return Ok(await service.GetByIdAsync(userId));
|
||||
return Ok(await service.GetByIdAsync(groupId));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -42,5 +42,12 @@ namespace GroupService.WebApi.Controllers.Group
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return Ok(await service.CreateAsync(new GroupCreateCommand(Guid.Parse(userId), request.Name)));
|
||||
}
|
||||
[HttpPost]
|
||||
[UnitOfWork(typeof(GroupDbContext))]
|
||||
public async Task<IActionResult> Update(GroupUpdateRequest request)
|
||||
{
|
||||
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
||||
return Ok(await service.UpdateAsync(new GroupUpdateCommand(Guid.Parse(userId), request.GroupId, request.Avatar, request.GroupName, request.Description)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace GroupService.WebApi.Controllers.Group
|
||||
{
|
||||
public class GroupUpdateRequest
|
||||
{
|
||||
public Guid GroupId { get; set; }
|
||||
public string? GroupName { get; set; }
|
||||
public string? Avatar { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class GroupUpDateRequestValidator : AbstractValidator<GroupUpdateRequest>
|
||||
{
|
||||
public GroupUpDateRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.GroupId)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user