feat(admin): Phase 4 行业配置管理页面 + 账号行业授权
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- 新增 Industries.tsx: 行业列表(ProTable) + 编辑弹窗(关键词/prompt/痛点种子) + 新建弹窗 - 新增 services/industries.ts: 行业 API 服务层(list/create/update/fullConfig/accountIndustries) - 增强 Accounts.tsx: 编辑弹窗添加行业授权多选, 自动获取/同步用户行业 - 注册 /industries 路由 + 侧边栏导航(ShopOutlined)
This commit is contained in:
104
admin-v2/src/services/industries.ts
Normal file
104
admin-v2/src/services/industries.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
// ============================================================
|
||||
// 行业配置 API 服务层
|
||||
// ============================================================
|
||||
|
||||
import request, { withSignal } from './request'
|
||||
import type { PaginatedResponse } from '@/types'
|
||||
import type { IndustryInfo, AccountIndustryItem } from '@/types'
|
||||
|
||||
/** 行业列表项(列表接口返回) */
|
||||
export interface IndustryListItem {
|
||||
id: string
|
||||
name: string
|
||||
icon: string
|
||||
description: string
|
||||
status: string
|
||||
source: string
|
||||
keywords_count: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 行业完整配置(含关键词、prompt 等) */
|
||||
export interface IndustryFullConfig {
|
||||
id: string
|
||||
name: string
|
||||
icon: string
|
||||
description: string
|
||||
status: string
|
||||
source: string
|
||||
keywords: string[]
|
||||
system_prompt: string
|
||||
cold_start_template: string
|
||||
pain_seed_categories: string[]
|
||||
skill_priorities: Array<{ skill_id: string; priority: number }>
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 创建行业请求 */
|
||||
export interface CreateIndustryRequest {
|
||||
name: string
|
||||
icon: string
|
||||
description: string
|
||||
keywords?: string[]
|
||||
system_prompt?: string
|
||||
cold_start_template?: string
|
||||
pain_seed_categories?: string[]
|
||||
}
|
||||
|
||||
/** 更新行业请求 */
|
||||
export interface UpdateIndustryRequest {
|
||||
name?: string
|
||||
icon?: string
|
||||
description?: string
|
||||
status?: string
|
||||
keywords?: string[]
|
||||
system_prompt?: string
|
||||
cold_start_template?: string
|
||||
pain_seed_categories?: string[]
|
||||
skill_priorities?: Array<{ skill_id: string; priority: number }>
|
||||
}
|
||||
|
||||
/** 设置用户行业请求 */
|
||||
export interface SetAccountIndustriesRequest {
|
||||
industries: Array<{
|
||||
industry_id: string
|
||||
is_primary: boolean
|
||||
}>
|
||||
}
|
||||
|
||||
export const industryService = {
|
||||
/** 行业列表 */
|
||||
list: (params?: { page?: number; page_size?: number; status?: string }, signal?: AbortSignal) =>
|
||||
request.get<PaginatedResponse<IndustryListItem>>('/industries', withSignal({ params }, signal))
|
||||
.then((r) => r.data),
|
||||
|
||||
/** 行业详情 */
|
||||
get: (id: string, signal?: AbortSignal) =>
|
||||
request.get<IndustryInfo>(`/industries/${id}`, withSignal({}, signal))
|
||||
.then((r) => r.data),
|
||||
|
||||
/** 行业完整配置 */
|
||||
getFullConfig: (id: string, signal?: AbortSignal) =>
|
||||
request.get<IndustryFullConfig>(`/industries/${id}/full-config`, withSignal({}, signal))
|
||||
.then((r) => r.data),
|
||||
|
||||
/** 创建行业 */
|
||||
create: (data: CreateIndustryRequest) =>
|
||||
request.post<IndustryInfo>('/industries', data).then((r) => r.data),
|
||||
|
||||
/** 更新行业 */
|
||||
update: (id: string, data: UpdateIndustryRequest) =>
|
||||
request.patch<IndustryInfo>(`/industries/${id}`, data).then((r) => r.data),
|
||||
|
||||
/** 获取用户授权行业 */
|
||||
getAccountIndustries: (accountId: string, signal?: AbortSignal) =>
|
||||
request.get<AccountIndustryItem[]>(`/accounts/${accountId}/industries`, withSignal({}, signal))
|
||||
.then((r) => r.data),
|
||||
|
||||
/** 设置用户授权行业 */
|
||||
setAccountIndustries: (accountId: string, data: SetAccountIndustriesRequest) =>
|
||||
request.put<AccountIndustryItem[]>(`/accounts/${accountId}/industries`, data)
|
||||
.then((r) => r.data),
|
||||
}
|
||||
Reference in New Issue
Block a user