43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using GroupService.Infrastructure;
|
|
using GroupService.WebApi.Application.GroupMember;
|
|
using IM.ASPNETCore;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Security.Claims;
|
|
|
|
namespace GroupService.WebApi.Controllers.GroupMember
|
|
{
|
|
[Route("api/[controller]/[action]")]
|
|
[ApiController]
|
|
public class GroupMemberController : ControllerBase
|
|
{
|
|
private readonly GroupMemberService service;
|
|
|
|
public GroupMemberController(GroupMemberService service)
|
|
{
|
|
this.service = service;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> CheckMember(Guid userId, Guid groupId)
|
|
{
|
|
return Ok(await service.CheckMemberAsync(groupId, userId));
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> List(Guid groupId)
|
|
{
|
|
return Ok(await service.GetByGroupIdAsync(groupId));
|
|
}
|
|
|
|
[HttpPost]
|
|
[UnitOfWork(typeof(GroupDbContext))]
|
|
public async Task<IActionResult> Delete([FromQuery] Guid memberId)
|
|
{
|
|
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
return Ok(await service.DeleteAsync(memberId, Guid.Parse(userId)));
|
|
}
|
|
|
|
|
|
}
|
|
}
|