mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化结构
This commit is contained in:
1 parent
75ebc1a746
commit
2554cf660a
34 files changed
+401
-150
No files matched your search
@@ -1,4 +1,3 @@
|
||||
|
||||
const problem = require('../model/problem');
|
||||
const { Route, Handler } = require('../service/server');
|
||||
const { PERM_CREATE_PROBLEM } = require('../permission');
|
||||
@@ -23,8 +22,10 @@ class ProblemImportHandler extends Handler {
|
||||
async post({
|
||||
url, pid, hidden, remoteType,
|
||||
}) {
|
||||
if (remoteType !== 'syzoj') throw new ValidationError('remoteType');
|
||||
const [pdoc, testdata] = await this.syzoj(url);
|
||||
if (typeof this[`from_${remoteType}`] !== 'function') {
|
||||
throw new ValidationError('remoteType');
|
||||
}
|
||||
const [pdoc, testdata] = await this[`from_${remoteType}`](url);
|
||||
if (pid) pdoc.pid = pid;
|
||||
if (hidden) pdoc.hidden = true;
|
||||
const _id = await problem.add(pdoc);
|
||||
@@ -39,6 +40,6 @@ async function apply() {
|
||||
Route('/problem/import', module.exports.ProblemImportHandler);
|
||||
}
|
||||
|
||||
global.Hydro['handler.import'] = module.exports = {
|
||||
global.Hydro.handler.import = module.exports = {
|
||||
ProblemImportHandler, apply,
|
||||
};
|
||||
Reference in new issue
Block a user