fix: align backend APIs and upload flow

This commit is contained in:
2026-09-15 14:10:55 +08:00
parent 32177a7293
commit 53e6195938
149 changed files with 4791 additions and 435 deletions
@@ -1,8 +1,9 @@
using AutoMapper;
using AutoMapper;
using ContactService.Domain;
using ContactService.WebApi.Application.Dtos;
using ContactService.WebApi.Application.IntegrationServices;
using IM.Commons;
using Microsoft.EntityFrameworkCore;
namespace ContactService.WebApi.Application.FriendRequest
{
@@ -11,15 +12,15 @@ namespace ContactService.WebApi.Application.FriendRequest
private readonly IFriendRequestReposity reposity;
private readonly FriendRequestDomainService service;
private readonly IMapper mapper;
private readonly IIdentityIntegrationService identityService;
private readonly IIdentityIntegrationService identityService; private readonly IM.InitCommon.Management.RuntimePolicy runtime; private readonly ContactService.Infrastructure.ContactDbContext db;
public FriendRequestService(IFriendRequestReposity reposity, FriendRequestDomainService service,
IMapper mapper, IIdentityIntegrationService identityService)
IMapper mapper, IIdentityIntegrationService identityService, IM.InitCommon.Management.RuntimePolicy runtime, ContactService.Infrastructure.ContactDbContext db)
{
this.reposity = reposity;
this.service = service;
this.mapper = mapper;
this.identityService = identityService;
this.identityService = identityService; this.runtime = runtime; this.db = db;
}
public async Task<Result<FriendRequestResponse>> CreateAsync(CreateFriendRequestCommand command)
@@ -50,6 +51,9 @@ namespace ContactService.WebApi.Application.FriendRequest
switch (command.Action)
{
case FriendRequestAction.Accpet:
var limit = runtime.Current.FriendLimit;
if (limit > 0 && (await db.Friends.CountAsync(x => x.Owner.Id == request.OwnerId) >= limit || await db.Friends.CountAsync(x => x.Owner.Id == request.TargetId) >= limit))
return Result<FriendRequestResponse>.Fail(ResultCode.PERMISSION_DENIED, "好友数量已达到平台上限");
request.Accept(command.RemarkName);
break;
case FriendRequestAction.Block:
@@ -0,0 +1,11 @@
using ContactService.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace ContactService.WebApi.Controllers;
[ApiController, Route("internal/management")]
public sealed class ManagementController(ContactDbContext db) : ControllerBase
{
[HttpGet("relation/{owner:guid}/{target:guid}")]
public async Task<object> Relation(Guid owner, Guid target) => new { related = await db.Friends.AnyAsync(x => x.Owner.Id == owner && x.Target.Id == target) };
}
+3
View File
@@ -1,3 +1,4 @@
using IM.InitCommon.Management;
using IM.InitCommon;
@@ -23,6 +24,7 @@ namespace ContactService.WebApi
builder.Services.AddAllGrpcServer();
var app = builder.Build();
if (app.ApplyMigrationsIfRequested(args)) return;
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
@@ -32,6 +34,7 @@ namespace ContactService.WebApi
}
app.UseAppDefault();
app.MapManagementHealth();
app.MapControllers();