feat: 新增统一模型网关与模型管理工作区

- 新增 OpenAI 兼容统一模型调用链路、模型发布配置与批量发布能力

- 重构模型管理页面入口与统一网关工作区,更新服务商 logo 资源与模型 ID 文案

- 收口全新库初始化脚本,仅保留服务商种子并整理统一网关 migration
This commit is contained in:
2026-03-26 20:48:18 +08:00
parent b777cb3641
commit aaf4c61ff8
80 changed files with 4786 additions and 362 deletions

View File

@@ -14,6 +14,7 @@ import tech.easyflow.system.service.SysApiKeyService;
import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -34,21 +35,36 @@ public class SysApiKeyServiceImpl extends ServiceImpl<SysApiKeyMapper, SysApiKey
@Override
public void checkApikeyPermission(String apiKey, String requestURI) {
SysApiKey sysApiKey = getSysApiKey(apiKey);
List<String> candidateRequestUris = getCandidateRequestUris(requestURI);
QueryWrapper w = QueryWrapper.create();
w.eq(SysApiKeyResource::getRequestInterface, requestURI);
SysApiKeyResource resource = resourceService.getOne(w);
if (resource == null) {
w.in(SysApiKeyResource::getRequestInterface, candidateRequestUris);
List<SysApiKeyResource> resources = resourceService.list(w);
if (resources == null || resources.isEmpty()) {
throw new BusinessException("该接口不存在");
}
List<BigInteger> resourceIds = resources.stream()
.map(SysApiKeyResource::getId)
.toList();
QueryWrapper wm = QueryWrapper.create();
wm.eq(SysApiKeyResourceMapping::getApiKeyId, sysApiKey.getId());
wm.eq(SysApiKeyResourceMapping::getApiKeyResourceId, resource.getId());
wm.in(SysApiKeyResourceMapping::getApiKeyResourceId, resourceIds);
long count = mappingService.count(wm);
if (count == 0) {
throw new BusinessException("该apiKey无权限访问该接口");
}
}
private List<String> getCandidateRequestUris(String requestURI) {
List<String> uris = new ArrayList<>();
uris.add(requestURI);
if ("/v1/chat/completions".equals(requestURI)) {
uris.add("/public-api/openai/v1/chat/completions");
} else if ("/public-api/openai/v1/chat/completions".equals(requestURI)) {
uris.add("/v1/chat/completions");
}
return uris;
}
@Override
public SysApiKey getSysApiKey(String apiKey) {
QueryWrapper w = QueryWrapper.create();