mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add contest/edit and contest/del hook
This commit is contained in:
7 files changed
+21
-16
No files matched your search
@@ -795,11 +795,14 @@ export async function edit(domainId: string, tid: ObjectId, $set: Partial<Tdoc>)
|
||||
const tdoc = await document.get(domainId, document.TYPE_CONTEST, tid);
|
||||
if (!tdoc) throw new ContestNotFoundError(domainId, tid);
|
||||
RULES[$set.rule || tdoc.rule].check(Object.assign(tdoc, $set));
|
||||
return await document.set(domainId, document.TYPE_CONTEST, tid, $set);
|
||||
const res = await document.set(domainId, document.TYPE_CONTEST, tid, $set);
|
||||
await bus.parallel('contest/edit', res);
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function del(domainId: string, tid: ObjectId) {
|
||||
await Promise.all([
|
||||
bus.parallel('contest/del', domainId, tid),
|
||||
document.deleteOne(domainId, document.TYPE_CONTEST, tid),
|
||||
document.deleteMultiStatus(domainId, document.TYPE_CONTEST, { docId: tid }),
|
||||
]);
|
||||
|
||||
@@ -83,9 +83,11 @@ export interface EventMap extends KnownHandlerEvents {
|
||||
|
||||
'contest/before-add': (payload: Partial<Tdoc>) => VoidReturn
|
||||
'contest/add': (payload: Partial<Tdoc>, id: ObjectId) => VoidReturn
|
||||
'contest/edit': (payload: Tdoc) => VoidReturn
|
||||
'contest/list': (query: Filter<Tdoc>, handler: any) => VoidReturn
|
||||
'contest/scoreboard': (tdoc: Tdoc, rows: ScoreboardRow[], udict: BaseUserDict, pdict: ProblemDict) => VoidReturn
|
||||
'contest/balloon': (domainId: string, tid: ObjectId, bdoc: ContestBalloonDoc) => VoidReturn
|
||||
'contest/del': (domainId: string, tid: ObjectId) => VoidReturn
|
||||
|
||||
'oplog/log': (type: string, handler: Handler, args: any, data: any) => VoidReturn;
|
||||
|
||||
|
||||
Reference in new issue
Block a user