添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,46 @@
using GroupService.Infrastructure;
using GroupService.WebApi.Application.Dtos;
using GroupService.WebApi.Application.Group;
using IM.ASPNETCore;
using IM.Commons;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
namespace GroupService.WebApi.Controllers.Group
{
[Route("api/[controller]/[action]")]
[Authorize]
[ApiController]
public class GroupController : ControllerBase
{
private readonly Application.Group.GroupService service;
public GroupController(Application.Group.GroupService service)
{
this.service = service;
}
[HttpGet]
[ProducesDefaultResponseType(typeof(Result<List<GroupResponse>>))]
public async Task<IActionResult> GetAll()
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.GetAllAsync(Guid.Parse(userId)));
}
[HttpGet("~/api/[controller]/{userId}")]
[ProducesDefaultResponseType(typeof(Result<GroupResponse>))]
public async Task<IActionResult> GetOne([FromRoute] Guid userId)
{
return Ok(await service.GetByIdAsync(userId));
}
[HttpPost]
[UnitOfWork(typeof(GroupDbContext))]
public async Task<IActionResult> Create(GroupCreateRequest request)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.CreateAsync(new GroupCreateCommand(Guid.Parse(userId), request.Name)));
}
}
}
@@ -0,0 +1,18 @@
using FluentValidation;
namespace GroupService.WebApi.Controllers.Group
{
public class GroupCreateRequest
{
public string? Name { get; set; }
}
public class GroupCreateRequestValidator : AbstractValidator<GroupCreateRequest>
{
public GroupCreateRequestValidator()
{
RuleFor(r => r.Name)
.MaximumLength(20);
}
}
}