|
export type TaskListSectionFilter = Partial<TaskResource> & BaseTaskFilter; |
|
|
|
export abstract class TaskListSectionModel extends Stream<TaskListSection, TaskListSectionFilter>( |
|
ListModel |
|
) { |
|
baseURI = 'task/v2/sections'; |
|
|
|
/** |
|
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/section/list} |
|
*/ |
|
async *openStream({ |
|
resource_type = 'my_tasks', |
|
resource_id, |
|
user_id_type = 'union_id' |
|
}: TaskListSectionFilter) { |
|
const stream = createPageStream<Pick<TaskListSection, 'guid' | 'name' | 'is_default'>>( |
|
this.client, |
|
this.baseURI, |
|
total => (this.totalCount = total), |
|
{ |
|
resource_type, |
|
resource_id, |
|
user_id_type |
|
} |
|
); |
|
for await (const { guid } of stream) yield await this.getOne(guid); |
|
} |
|
|
|
/** |
|
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/section/get} |
|
*/ |
|
@toggle('downloading') |
|
async getOne(id: string) { |
|
const { body } = await this.client.get<LarkData<{ section: TaskListSection }>>( |
|
`${this.baseURI}/${id}` |
|
); |
|
|
|
return (this.currentOne = body!.data!.section); |
|
} |
|
|
|
/** |
|
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/section/create} |
|
* @see {@link https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/task-v2/section/patch} |
|
*/ |
|
@toggle('uploading') |
|
async updateOne( |
|
section: NewData<TaskListSection>, |
|
id?: string, |
|
user_id_type: UserIdType = 'union_id', |
|
[target]: Partial<TaskResource>[] = [] |
|
) { |
|
const path = `${this.baseURI}?${buildURLData({ user_id_type })}`; |
|
const { body } = id |
|
? await this.client.patch<LarkData<{ section: TaskListSection }>>(path, { |
|
section, |
|
update_fields: Object.keys(section) |
|
}) |
|
: await this.client.post<LarkData<{ section: TaskListSection }>>(path, { |
|
name: section.name, |
|
...target |
|
}); |
|
return body!.data!.section; |
|
} |
|
} |
Task description
接口文档
参考代码
MobX-Lark/src/module/Task/index.ts
Lines 134 to 197 in 800b390
Reward currency
TQT $
Reward amount
90
Reward payer
石垚 tech-query@idea2app.cn
Task source
https://idea2app.feishu.cn/record/GnFarpHEWeqPUHcaYgScCrIanpc