新增: 三实体列表查询维度补全(status/关键词/排序/分页下沉后端)
任务/项目/灵感三实体新增 list_by_query 动态 WHERE(累积式 where_clauses
+params_vec 收口)+ order_by 白名单防注入 + limit/offset 钳制。命令层
list_{tasks,projects,ideas} 吃 Option<XxxQuery> 双参向后兼容(旧无参/单参
路径等价全量)。前端 Tasks/Ideas status/keyword 筛选下沉后端 query。
F-260621-02
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import type { IdeaRecord, CreateIdeaInput, PromotionResult, IdeaEvaluationRecord } from './types'
|
||||
import type { IdeaRecord, CreateIdeaInput, PromotionResult, IdeaEvaluationRecord, IdeaQuery } from './types'
|
||||
|
||||
export const ideaApi = {
|
||||
/** 列出灵感,可选按 status 过滤(draft/pending_review/promoted 等) */
|
||||
list(status?: string): Promise<IdeaRecord[]> {
|
||||
return invoke('list_ideas', { status: status ?? null })
|
||||
/**
|
||||
* 列出灵感。
|
||||
*
|
||||
* **双签名向后兼容**(F-260621-02):
|
||||
* - `list(status?)`:旧签名,仅状态过滤(等价 `list({ status })`)。
|
||||
* - `list(query?)`:新签名,多条件(status/keyword/order_by/limit/offset)走后端 WHERE。
|
||||
*
|
||||
* 参数为空 → 后端返回全量(created_at DESC,与旧 list_all 等价)。
|
||||
*/
|
||||
list(queryOrStatus?: IdeaQuery | string): Promise<IdeaRecord[]> {
|
||||
if (typeof queryOrStatus === 'string') {
|
||||
return invoke('list_ideas', { status: queryOrStatus ?? null, query: null })
|
||||
}
|
||||
return invoke('list_ideas', { status: null, query: queryOrStatus ?? null })
|
||||
},
|
||||
|
||||
create(input: CreateIdeaInput): Promise<IdeaRecord> {
|
||||
|
||||
@@ -46,9 +46,29 @@ export interface ImportBatchResult {
|
||||
items: ImportBatchItemResult[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目列表查询条件(F-260621-02 P2/P3)。
|
||||
* 全可选;不传(或全 undefined)= 当前全量行为(deleted_at IS NULL + created_at DESC)。
|
||||
* 对齐后端 df_storage::crud::ProjectQuery。
|
||||
*/
|
||||
export interface ProjectQuery {
|
||||
/** 关键词:name/description LIKE %kw%(trim 后空字符串视为无关键词) */
|
||||
keyword?: string
|
||||
/** 排序:格式 "col" / "col asc" / "col desc",默认 created_at desc(列名白名单) */
|
||||
order_by?: string
|
||||
/** 返回上限(后端钳制 [0,200],undefined = 不加 LIMIT 全量) */
|
||||
limit?: number
|
||||
/** 偏移量(undefined = 0,配合 limit 分页) */
|
||||
offset?: number
|
||||
}
|
||||
|
||||
export const projectApi = {
|
||||
list(): Promise<ProjectRecord[]> {
|
||||
return invoke('list_projects')
|
||||
/**
|
||||
* 列出未删除项目。
|
||||
* F-260621-02:可选 query(关键词/排序/分页)。不传 = 当前全量行为(向后兼容)。
|
||||
*/
|
||||
list(query?: ProjectQuery): Promise<ProjectRecord[]> {
|
||||
return invoke('list_projects', { query })
|
||||
},
|
||||
|
||||
create(input: CreateProjectInput): Promise<ProjectRecord> {
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import type { TaskRecord, CreateTaskInput } from './types'
|
||||
import type { TaskRecord, CreateTaskInput, TaskQuery } from './types'
|
||||
|
||||
export const taskApi = {
|
||||
list(projectId?: string): Promise<TaskRecord[]> {
|
||||
return invoke('list_tasks', { projectId: projectId ?? null })
|
||||
/**
|
||||
* 列出任务。
|
||||
*
|
||||
* **双签名向后兼容**(F-260621-02):
|
||||
* - `list(projectId?)`:旧签名,仅项目过滤(等价 `list({ project_id: projectId })`)。
|
||||
* - `list(query?)`:新签名,多条件(status/keyword/project_id/priority/assignee/...)走后端 WHERE。
|
||||
*
|
||||
* 参数为空 → 后端返回全量未删任务(created_at DESC,等价改造前 list_active)。
|
||||
*/
|
||||
list(queryOrProjectId?: TaskQuery | string): Promise<TaskRecord[]> {
|
||||
if (typeof queryOrProjectId === 'string') {
|
||||
return invoke('list_tasks', { projectId: queryOrProjectId ?? null, query: null })
|
||||
}
|
||||
return invoke('list_tasks', { projectId: null, query: queryOrProjectId ?? null })
|
||||
},
|
||||
|
||||
get(id: string): Promise<TaskRecord> {
|
||||
|
||||
@@ -34,6 +34,23 @@ export interface CreateIdeaInput {
|
||||
source?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 灵感多条件查询入参(F-260621-02,对齐后端 IdeaQuery)。
|
||||
*
|
||||
* 所有字段可选;全空 → 后端返回全量(created_at DESC)。
|
||||
* - `status`:状态精确匹配(后端 WHERE,取代前端 filter)
|
||||
* - `keyword`:title/description LIKE %kw%(后端 LIKE,取代前端 filter)
|
||||
* - `order_by`:白名单 created_at/updated_at/priority/status/score(后端白名单校验防注入)
|
||||
* - `limit`/`offset`:分页(limit 钳制上限 200)
|
||||
*/
|
||||
export interface IdeaQuery {
|
||||
status?: string | null
|
||||
keyword?: string | null
|
||||
order_by?: string | null
|
||||
limit?: number | null
|
||||
offset?: number | null
|
||||
}
|
||||
|
||||
/**
|
||||
* 灵感评估历史记录(后端 list_idea_evaluations 返回)。
|
||||
* 每次评估(启发式/LLM/降级)落一行,version 递增,按 version DESC 返回。
|
||||
@@ -152,6 +169,32 @@ export interface CreateTaskInput {
|
||||
idea_id?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务多条件查询入参(F-260621-02,对齐后端 TaskQuery)。
|
||||
*
|
||||
* 所有字段可选;全空 → 后端返回全量未删任务(created_at DESC,等价改造前 list_active)。
|
||||
* - `project_id`:项目精确匹配(命中 idx_tasks_project_id)
|
||||
* - `status`:状态精确匹配(P1 下沉,命中 idx_tasks_status,取代前端 filter)
|
||||
* - `priority`:优先级精确匹配(0=critical..3=low)
|
||||
* - `assignee`:负责人精确匹配
|
||||
* - `keyword`:title/description LIKE %kw%(P2,取代前端 filter)
|
||||
* - `order_by`:白名单 created_at/updated_at/priority/status(后端白名单校验防注入),恒 DESC
|
||||
* - `limit`/`offset`:分页(limit 钳制上限 500)
|
||||
*
|
||||
* 注:project_id/priority/assignee/order_by/limit/offset 为基建就绪,当前视图仅用
|
||||
* status(P1)+keyword(P2);P3 排序分页 UI 待数据量增长。
|
||||
*/
|
||||
export interface TaskQuery {
|
||||
project_id?: string | null
|
||||
status?: string | null
|
||||
priority?: number | null
|
||||
assignee?: string | null
|
||||
keyword?: string | null
|
||||
order_by?: string | null
|
||||
limit?: number | null
|
||||
offset?: number | null
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 工作流
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user