|
|
@ -107,7 +107,7 @@ app.get('/problems/tag/:tagIDs', async (req, res) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let paginate = syzoj.utils.paginate(await Problem.count(sql), req.query.page, syzoj.config.page.problem); |
|
|
|
let paginate = syzoj.utils.paginate(await Problem.count(sql), req.query.page, syzoj.config.page.problem); |
|
|
|
let problems = await Problem.query(sql); |
|
|
|
let problems = await Problem.query(sql + paginate.toSQL()); |
|
|
|
|
|
|
|
|
|
|
|
await problems.forEachAsync(async problem => { |
|
|
|
await problems.forEachAsync(async problem => { |
|
|
|
problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user); |
|
|
|
problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user); |
|
|
@ -256,6 +256,7 @@ app.post('/problem/:id/edit', async (req, res) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!req.body.trim()) throw new ErrorMessage('题目名不能为空。'); |
|
|
|
problem.title = req.body.title; |
|
|
|
problem.title = req.body.title; |
|
|
|
problem.description = req.body.description; |
|
|
|
problem.description = req.body.description; |
|
|
|
problem.input_format = req.body.input_format; |
|
|
|
problem.input_format = req.body.input_format; |
|
|
@ -344,6 +345,7 @@ app.post('/problem/:id/import', async (req, res) => { |
|
|
|
|
|
|
|
|
|
|
|
if (!json.success) throw new ErrorMessage('题目加载失败。', null, json.error); |
|
|
|
if (!json.success) throw new ErrorMessage('题目加载失败。', null, json.error); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!json.obj.trim()) throw new ErrorMessage('题目名不能为空。'); |
|
|
|
problem.title = json.obj.title; |
|
|
|
problem.title = json.obj.title; |
|
|
|
problem.description = json.obj.description; |
|
|
|
problem.description = json.obj.description; |
|
|
|
problem.input_format = json.obj.input_format; |
|
|
|
problem.input_format = json.obj.input_format; |
|
|
|