188 lines
4.3 KiB
TypeScript
188 lines
4.3 KiB
TypeScript
import { get, post, type PageParams } from '@/lib/request'
|
|
import type { SystemOss } from './system'
|
|
|
|
// ==================== 百科分类 ====================
|
|
|
|
export interface WikiClass {
|
|
id: string
|
|
name: string
|
|
ossId?: string
|
|
image?: SystemOss
|
|
createdAt?: string
|
|
updatedAt?: string
|
|
}
|
|
|
|
export interface CreateWikiClassParams {
|
|
name: string
|
|
ossId?: string
|
|
}
|
|
|
|
export interface UpdateWikiClassParams {
|
|
id: string
|
|
name?: string
|
|
ossId?: string
|
|
}
|
|
|
|
// 分类列表
|
|
export function getWikiClassList() {
|
|
return get<{ data: WikiClass[] }>('/wiki-class/list')
|
|
}
|
|
|
|
// 分类分页
|
|
export function getWikiClassPage(data: PageParams) {
|
|
return post<{ data: { list: WikiClass[]; total: number } }>('/wiki-class/page', data)
|
|
}
|
|
|
|
// 分类详情
|
|
export function getWikiClassDetail(id: string) {
|
|
return get<{ data: WikiClass }>('/wiki-class/detail', { id })
|
|
}
|
|
|
|
// 添加分类
|
|
export function addWikiClass(data: CreateWikiClassParams) {
|
|
return post<{ msg: string }>('/wiki-class/add', data)
|
|
}
|
|
|
|
// 修改分类
|
|
export function updateWikiClass(data: UpdateWikiClassParams) {
|
|
return post<{ msg: string }>('/wiki-class/update', data)
|
|
}
|
|
|
|
// 删除分类
|
|
export function deleteWikiClass(ids: string[]) {
|
|
return post<{ msg: string }>('/wiki-class/delete', { ids })
|
|
}
|
|
|
|
// ==================== 百科/植物 ====================
|
|
|
|
export interface Wiki {
|
|
id: string
|
|
name: string
|
|
latinName?: string
|
|
aliases?: string
|
|
classIds?: string[]
|
|
classes?: WikiClass[]
|
|
imgList?: SystemOss[] // 后端返回的图片列表
|
|
ossIds?: string[]
|
|
|
|
// 基本信息
|
|
genus?: string
|
|
distributionArea?: string
|
|
lifeCycle?: string
|
|
height?: number
|
|
|
|
// 叶子信息
|
|
foliageType?: string
|
|
foliageColor?: string
|
|
foliageShape?: string
|
|
|
|
// 花信息
|
|
floweringPeriod?: string
|
|
floweringColor?: string
|
|
floweringShape?: string
|
|
flowerDiameter?: number
|
|
|
|
// 果信息
|
|
fruit?: string
|
|
stem?: string
|
|
|
|
// 养护信息
|
|
growthHabit?: string
|
|
lightType?: string
|
|
lightIntensity?: string
|
|
optimalTempPeriod?: string
|
|
reproductionMethod?: string
|
|
pestsDiseases?: string
|
|
|
|
// 其他
|
|
difficulty?: number // 1-5级
|
|
isHot?: number // 0否 1是
|
|
isVectorSynced?: number // 0否 1是
|
|
relatedWikiIds?: string[]
|
|
relatedWikis?: Wiki[]
|
|
|
|
createdAt?: string
|
|
updatedAt?: string
|
|
}
|
|
|
|
export interface WikiPageParams extends PageParams {
|
|
name?: string
|
|
classId?: string[]
|
|
isHot?: number
|
|
}
|
|
|
|
export interface CreateWikiParams {
|
|
name: string
|
|
latinName?: string
|
|
aliases?: string
|
|
classIds?: string[]
|
|
ossIds?: string[]
|
|
genus?: string
|
|
distributionArea?: string
|
|
lifeCycle?: string
|
|
height?: number
|
|
foliageType?: string
|
|
foliageColor?: string
|
|
foliageShape?: string
|
|
floweringPeriod?: string
|
|
floweringColor?: string
|
|
floweringShape?: string
|
|
flowerDiameter?: number
|
|
fruit?: string
|
|
stem?: string
|
|
growthHabit?: string
|
|
lightType?: string
|
|
lightIntensity?: string
|
|
optimalTempPeriod?: string
|
|
reproductionMethod?: string
|
|
pestsDiseases?: string
|
|
difficulty?: number
|
|
isHot?: number
|
|
relatedWikiIds?: string[]
|
|
}
|
|
|
|
export interface UpdateWikiParams extends CreateWikiParams {
|
|
id: string
|
|
}
|
|
|
|
// 百科分页
|
|
export function getWikiPage(data: WikiPageParams) {
|
|
return post<{ data: { list: Wiki[]; total: number } }>('/wiki/page', data)
|
|
}
|
|
|
|
// 百科详情
|
|
export function getWikiDetail(id: string) {
|
|
return get<{ data: Wiki }>('/wiki/detail', { id })
|
|
}
|
|
|
|
// 添加百科
|
|
export function addWiki(data: CreateWikiParams) {
|
|
return post<{ msg: string }>('/wiki/add', data)
|
|
}
|
|
|
|
|
|
// 修改百科
|
|
export function updateWiki(data: UpdateWikiParams) {
|
|
return post<{ msg: string }>('/wiki/update', data)
|
|
}
|
|
|
|
// 上传百科图片 (列表页快捷上传)
|
|
export function uploadWikiImg(data: { id: string; ossIds: string[] }) {
|
|
return post<{ msg: string }>('/wiki/uploadImg', data)
|
|
}
|
|
|
|
// 删除百科
|
|
export function deleteWiki(ids: string[]) {
|
|
return post<{ msg: string }>('/wiki/delete', { ids })
|
|
}
|
|
|
|
// 同步点位到 Qdrant
|
|
export function syncWikiQdrant(id: string) {
|
|
return post<{ msg: string }>('/wiki/sync-qdrant', { id })
|
|
}
|
|
|
|
// 从 Qdrant 删除点位
|
|
export function deleteWikiQdrant(id: string) {
|
|
return post<{ msg: string }>('/wiki/delete-qdrant', { id })
|
|
}
|