mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui: add ProblemSelectAutoComplete
This commit is contained in:
1 parent
1c89596cb3
commit
90443546c8
7 files changed
+80
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type { Readable } from 'stream';
|
||||
import { ObjectID, FilterQuery } from 'mongodb';
|
||||
import { Dictionary, pick } from 'lodash';
|
||||
import { Dictionary, escapeRegExp, pick } from 'lodash';
|
||||
import { STATUS } from './builtin';
|
||||
import * as document from './document';
|
||||
import domain from './domain';
|
||||
@@ -208,6 +208,13 @@ export class ProblemModel {
|
||||
return Object.assign(r, l);
|
||||
}
|
||||
|
||||
static async getPrefixList(domainId: string, prefix: string) {
|
||||
prefix = prefix.toLowerCase();
|
||||
const $regex = new RegExp(`\\A${escapeRegExp(prefix)}`, 'gmi');
|
||||
const filter = { $or: [{ pid: { $regex } }, { title: { $regex } }] };
|
||||
return await document.getMulti(domainId, document.TYPE_PROBLEM, filter, ['domainId', 'docId', 'pid', 'title']).toArray();
|
||||
}
|
||||
|
||||
static async getListStatus(domainId: string, uid: number, pids: number[]) {
|
||||
const psdocs = await ProblemModel.getMultiStatus(
|
||||
domainId, { uid, docId: { $in: Array.from(new Set(pids)) } },
|
||||
|
||||
Reference in new issue
Block a user