feat: 完善渠道商管理

This commit is contained in:
ccnetcore
2026-01-05 00:11:06 +08:00
parent 88225a97b8
commit 69a8b47245
13 changed files with 63 additions and 5 deletions

View File

@@ -93,4 +93,9 @@ public class AiModelCreateInput
/// 是否为尊享模型 /// 是否为尊享模型
/// </summary> /// </summary>
public bool IsPremium { get; set; } public bool IsPremium { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; } = true;
} }

View File

@@ -81,4 +81,9 @@ public class AiModelDto
/// 是否为尊享模型 /// 是否为尊享模型
/// </summary> /// </summary>
public bool IsPremium { get; set; } public bool IsPremium { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
} }

View File

@@ -99,4 +99,9 @@ public class AiModelUpdateInput
/// 是否为尊享模型 /// 是否为尊享模型
/// </summary> /// </summary>
public bool IsPremium { get; set; } public bool IsPremium { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
} }

View File

@@ -181,6 +181,7 @@ public class ChannelService : ApplicationService, IChannelService
ProviderName = input.ProviderName, ProviderName = input.ProviderName,
IconUrl = input.IconUrl, IconUrl = input.IconUrl,
IsPremium = input.IsPremium, IsPremium = input.IsPremium,
IsEnabled = input.IsEnabled,
IsDeleted = false IsDeleted = false
}; };
@@ -222,6 +223,7 @@ public class ChannelService : ApplicationService, IChannelService
entity.ProviderName = input.ProviderName; entity.ProviderName = input.ProviderName;
entity.IconUrl = input.IconUrl; entity.IconUrl = input.IconUrl;
entity.IsPremium = input.IsPremium; entity.IsPremium = input.IsPremium;
entity.IsEnabled = input.IsEnabled;
await _modelRepository.UpdateAsync(entity); await _modelRepository.UpdateAsync(entity);
return entity.Adapt<AiModelDto>(); return entity.Adapt<AiModelDto>();

View File

@@ -35,8 +35,9 @@ public class ModelService : ApplicationService, IModelService
{ {
RefAsync<int> total = 0; RefAsync<int> total = 0;
// 查询所有未删除的模型使用WhereIF动态添加筛选条件 // 查询所有未删除且已启用的模型使用WhereIF动态添加筛选条件
var modelIds = (await _modelRepository._DbQueryable var modelIds = (await _modelRepository._DbQueryable
.Where(x => x.IsEnabled)
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x => .WhereIF(!string.IsNullOrWhiteSpace(input.SearchKey), x =>
x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey)) x.Name.Contains(input.SearchKey) || x.ModelId.Contains(input.SearchKey))
.WhereIF(input.ProviderNames is not null, x => .WhereIF(input.ProviderNames is not null, x =>
@@ -51,6 +52,7 @@ public class ModelService : ApplicationService, IModelService
.ToPageListAsync(input.SkipCount, input.MaxResultCount, total)); .ToPageListAsync(input.SkipCount, input.MaxResultCount, total));
var entities = await _modelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId)) var entities = await _modelRepository._DbQueryable.Where(x => modelIds.Contains(x.ModelId))
.Where(x => x.IsEnabled)
.OrderBy(x => x.OrderNum) .OrderBy(x => x.OrderNum)
.OrderBy(x => x.Name).ToListAsync(); .OrderBy(x => x.Name).ToListAsync();
@@ -77,7 +79,7 @@ public class ModelService : ApplicationService, IModelService
public async Task<List<string>> GetProviderListAsync() public async Task<List<string>> GetProviderListAsync()
{ {
var providers = await _modelRepository._DbQueryable var providers = await _modelRepository._DbQueryable
.Where(x => !x.IsDeleted) .Where(x => !x.IsDeleted && x.IsEnabled)
.Where(x => !string.IsNullOrEmpty(x.ProviderName)) .Where(x => !string.IsNullOrEmpty(x.ProviderName))
.GroupBy(x => x.ProviderName) .GroupBy(x => x.ProviderName)
.OrderBy(x => x.OrderNum) .OrderBy(x => x.OrderNum)

View File

@@ -85,4 +85,9 @@ public class AiModelEntity : Entity<Guid>, IOrderNum, ISoftDelete
/// 是否为尊享模型 /// 是否为尊享模型
/// </summary> /// </summary>
public bool IsPremium { get; set; } public bool IsPremium { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; } = true;
} }

View File

@@ -71,6 +71,7 @@ public class AiGateWayManager : DomainService
.LeftJoin<AiAppAggregateRoot>((model, app) => model.AiAppId == app.Id) .LeftJoin<AiAppAggregateRoot>((model, app) => model.AiAppId == app.Id)
.Where((model, app) => model.ModelId == modelId) .Where((model, app) => model.ModelId == modelId)
.Where((model, app) => model.ModelApiType == modelApiType) .Where((model, app) => model.ModelApiType == modelApiType)
.Where((model, app) => model.IsEnabled)
.Select((model, app) => .Select((model, app) =>
new AiModelDescribe new AiModelDescribe
{ {

View File

@@ -38,7 +38,7 @@ public class ModelManager : DomainService
{ {
// 从数据库查询 // 从数据库查询
var premiumModelIds = await _aiModelRepository._DbQueryable var premiumModelIds = await _aiModelRepository._DbQueryable
.Where(x => x.IsPremium) .Where(x => x.IsPremium && x.IsEnabled)
.Select(x => x.ModelId) .Select(x => x.ModelId)
.ToListAsync(); .ToListAsync();
return premiumModelIds; return premiumModelIds;

View File

@@ -360,7 +360,7 @@ namespace Yi.Abp.Web
var app = context.GetApplicationBuilder(); var app = context.GetApplicationBuilder();
app.UseRouting(); app.UseRouting();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<ImageStoreTaskAggregateRoot>(); //app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<AiModelEntity>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<ActivationCodeRecordAggregateRoot>(); // app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<ActivationCodeRecordAggregateRoot>();
// app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<UsageStatisticsAggregateRoot>(); // app.ApplicationServices.GetRequiredService<ISqlSugarDbContext>().SqlSugarClient.CodeFirst.InitTables<UsageStatisticsAggregateRoot>();

View File

@@ -98,3 +98,8 @@ export function updateModel(data: AiModelUpdateInput) {
export function deleteModel(id: string) { export function deleteModel(id: string) {
return del(`/channel/model/${id}`).json(); return del(`/channel/model/${id}`).json();
} }
// 清除尊享模型ID缓存
export function clearPremiumModelCache() {
return post('/model/clear-premium-cache').json();
}

View File

@@ -66,6 +66,7 @@ export interface AiModelDto {
providerName?: string; providerName?: string;
iconUrl?: string; iconUrl?: string;
isPremium: boolean; isPremium: boolean;
isEnabled: boolean;
} }
// 创建AI模型输入 // 创建AI模型输入
@@ -84,6 +85,7 @@ export interface AiModelCreateInput {
providerName?: string; providerName?: string;
iconUrl?: string; iconUrl?: string;
isPremium: boolean; isPremium: boolean;
isEnabled: boolean;
} }
// 更新AI模型输入 // 更新AI模型输入
@@ -103,6 +105,7 @@ export interface AiModelUpdateInput {
providerName?: string; providerName?: string;
iconUrl?: string; iconUrl?: string;
isPremium: boolean; isPremium: boolean;
isEnabled: boolean;
} }
// 获取AI模型列表输入 // 获取AI模型列表输入

View File

@@ -12,6 +12,7 @@ import {
createModel, createModel,
updateModel, updateModel,
deleteModel, deleteModel,
clearPremiumModelCache,
} from '@/api/channel'; } from '@/api/channel';
// ==================== 应用管理 ==================== // ==================== 应用管理 ====================
@@ -182,6 +183,7 @@ function openModelDialog(type: 'create' | 'edit', row?: AiModelDto) {
providerName: '', providerName: '',
iconUrl: '', iconUrl: '',
isPremium: false, isPremium: false,
isEnabled: true,
}; };
} }
else { else {
@@ -228,6 +230,17 @@ async function handleDeleteModel(row: AiModelDto) {
} }
} }
// 清理尊享模型缓存
async function handleClearCache() {
try {
await clearPremiumModelCache();
ElMessage.success('缓存清理成功');
}
catch (error: any) {
ElMessage.error(error.message || '缓存清理失败');
}
}
// 初始化 // 初始化
onMounted(() => { onMounted(() => {
fetchAppList(); fetchAppList();
@@ -306,6 +319,9 @@ onMounted(() => {
clearable clearable
@keyup.enter="fetchModelList" @keyup.enter="fetchModelList"
/> />
<el-button type="warning" size="small" @click="handleClearCache">
清理缓存
</el-button>
<el-button type="primary" size="small" :icon="Plus" @click="openModelDialog('create')"> <el-button type="primary" size="small" :icon="Plus" @click="openModelDialog('create')">
新建 新建
</el-button> </el-button>
@@ -338,6 +354,13 @@ onMounted(() => {
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="是否启用" width="100">
<template #default="{ row }">
<el-tag :type="row.isEnabled ? 'success' : 'danger'">
{{ row.isEnabled ? '启用' : '禁用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="multiplier" label="模型倍率" width="100" /> <el-table-column prop="multiplier" label="模型倍率" width="100" />
<el-table-column prop="multiplierShow" label="显示倍率" width="100" /> <el-table-column prop="multiplierShow" label="显示倍率" width="100" />
<el-table-column prop="orderNum" label="排序" width="80" /> <el-table-column prop="orderNum" label="排序" width="80" />
@@ -415,6 +438,9 @@ onMounted(() => {
<el-form-item label="是否尊享模型"> <el-form-item label="是否尊享模型">
<el-switch v-model="modelForm.isPremium" /> <el-switch v-model="modelForm.isPremium" />
</el-form-item> </el-form-item>
<el-form-item label="是否启用">
<el-switch v-model="modelForm.isEnabled" />
</el-form-item>
<el-form-item label="模型倍率"> <el-form-item label="模型倍率">
<el-input-number v-model="modelForm.multiplier" :min="0.01" :step="0.1" /> <el-input-number v-model="modelForm.multiplier" :min="0.01" :step="0.1" />
</el-form-item> </el-form-item>

View File

@@ -7,7 +7,6 @@ interface ImportMetaEnv {
readonly VITE_WEB_BASE_API: string; readonly VITE_WEB_BASE_API: string;
readonly VITE_API_URL: string; readonly VITE_API_URL: string;
readonly VITE_FILE_UPLOAD_API: string; readonly VITE_FILE_UPLOAD_API: string;
readonly VITE_BUILD_COMPRESS: string;
readonly VITE_SSO_SEVER_URL: string; readonly VITE_SSO_SEVER_URL: string;
readonly VITE_APP_VERSION: string; readonly VITE_APP_VERSION: string;
} }