mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: testdata(zip-> multi files)
This commit is contained in:
1 parent
c30fbe1e6b
commit
e7794090b2
17 files changed
+338
-335
No files matched your search
@@ -2,7 +2,6 @@ import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { PermissionError, RecordNotFoundError } from '../error';
|
||||
import { PERM, CONSTANT, STATUS } from '../model/builtin';
|
||||
import * as problem from '../model/problem';
|
||||
import * as file from '../model/file';
|
||||
import * as record from '../model/record';
|
||||
import * as contest from '../model/contest';
|
||||
import * as user from '../model/user';
|
||||
@@ -12,7 +11,6 @@ import {
|
||||
Route, Handler, Connection, ConnectionHandler, Types, param,
|
||||
} from '../service/server';
|
||||
import { Rdoc } from '../interface';
|
||||
import { streamToBuffer } from '../utils';
|
||||
|
||||
const RecordHandler = contest.ContestHandlerMixin(Handler);
|
||||
|
||||
@@ -132,35 +130,6 @@ class RecordDetailHandler extends RecordHandler {
|
||||
}
|
||||
}
|
||||
|
||||
class RecordHackHandler extends Handler {
|
||||
@param('rid', Types.ObjectID)
|
||||
@param('ufid', Types.ObjectID)
|
||||
async get(domainId: string, rid: ObjectID, ufid?: ObjectID) {
|
||||
if (ufid) {
|
||||
const stream = await file.get(ufid);
|
||||
const buf = await streamToBuffer(stream);
|
||||
const input = buf.toString();
|
||||
await this.post(domainId, rid, input);
|
||||
} else this.response.template = 'record_hack.html';
|
||||
}
|
||||
|
||||
@param('rid', Types.ObjectID)
|
||||
@param('input', Types.String)
|
||||
async post(domainId: string, rid: ObjectID, input: string) {
|
||||
const rdoc = await record.get(domainId, rid);
|
||||
if (!rdoc) throw new RecordNotFoundError(domainId, rid);
|
||||
const newRid = await record.add(
|
||||
domainId, rdoc.pid, this.user._id,
|
||||
rdoc.lang, rdoc.code, true,
|
||||
{ hack: input },
|
||||
);
|
||||
bus.boardcast('record/change', rdoc);
|
||||
this.response.body = { rid: newRid };
|
||||
this.response.redirect = this.url('record_detail', { rid: newRid });
|
||||
// TODO handle hack(modify testdata, rejudge problem)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* use RecordDetailHandler.postRejudge instead.
|
||||
@@ -261,7 +230,6 @@ class RecordDetailConnectionHandler extends contest.ContestHandlerMixin(Connecti
|
||||
export async function apply() {
|
||||
Route('record_main', '/record', RecordListHandler);
|
||||
Route('record_detail', '/record/:rid', RecordDetailHandler);
|
||||
Route('record_hack', '/record/:rid/hack', RecordHackHandler);
|
||||
Route('record_rejudge', '/record/:rid/rejudge', RecordRejudgeHandler);
|
||||
Connection('record_conn', '/record-conn', RecordMainConnectionHandler);
|
||||
Connection('record_detail_conn', '/record-detail-conn', RecordDetailConnectionHandler);
|
||||
|
||||
Reference in new issue
Block a user