core: 自动转换pid

This commit is contained in:
undefined committed 2021-05-14 12:42:09 +08:00
1 parent af345d78de
commit 9b3ceb82de
4 files changed
+10 -6

No files matched your search

+2 -2
View File
@@ -15,7 +15,7 @@ import { PERM } from '../model/builtin';
import {
Route, Handler, Types, post,
} from '../service/server';
import { isPid } from '../lib/validator';
import { isPid, parsePid } from '../lib/validator';
import download from '../lib/download';
const RE_SYZOJ = /(https?):\/\/([^/]+)\/(problem|p)\/([0-9]+)\/?/i;
@@ -221,7 +221,7 @@ class ProblemImportSYZOJHandler extends Handler {
}
@post('url', Types.Content, true)
@post('pid', Types.Name, true, isPid)
@post('pid', Types.Name, true, isPid, parsePid)
@post('hidden', Types.Boolean)
@post('prefix', Types.Name, true)
@post('start', Types.UnsignedInt, true)
+3 -3
View File
@@ -11,7 +11,7 @@ import {
ProblemDoc, User, RecordDoc, PathComponent, ProblemStatusDoc,
} from '../interface';
import paginate from '../lib/paginate';
import { isPid } from '../lib/validator';
import { isPid, parsePid as convertPid } from '../lib/validator';
import difficultyAlgorithm from '../lib/difficulty';
import { parseConfig } from '../lib/testdataConfig';
import * as system from '../model/system';
@@ -358,7 +358,7 @@ export class ProblemEditHandler extends ProblemManageHandler {
@route('pid', Types.Name, null, parsePid)
@post('title', Types.Title)
@post('content', Types.Content)
@post('pid', Types.Name, isPid, true)
@post('pid', Types.Name, isPid, convertPid, true)
@post('hidden', Types.Boolean)
@post('tag', Types.Content, true, null, parseCategory)
async post(
@@ -600,7 +600,7 @@ export class ProblemCreateHandler extends Handler {
@post('title', Types.Title)
@post('content', Types.Content)
@post('pid', Types.Name, true, isPid)
@post('pid', Types.Name, true, isPid, convertPid)
@post('hidden', Types.Boolean)
@post('tag', Types.Content, true, null, parseCategory)
async post(domainId: string, title: string, content: string, pid: string, hidden = false, tag: string[] = []) {