| 627 | @post('tag', Types.Content, true, null, parseCategory) |
| 628 | @post('difficulty', Types.PositiveInt, (i) => +i <= 10, true) |
| 629 | async post( |
| 630 | domainId: string, pid: string | number, title: string, content: string, |
| 631 | newPid: string | number = '', hidden = false, tag: string[] = [], difficulty = 0, |
| 632 | ) { |
| 633 | if (typeof newPid !== 'string') newPid = `P${newPid}`; |
| 634 | if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new ProblemAlreadyExistError(newPid); |
| 635 | const $update: Partial<ProblemDoc> = { |
| 636 | title, content, pid: newPid, hidden, tag: tag ?? [], difficulty, html: false, |
| 637 | }; |
| 638 | const pdoc = await problem.edit(domainId, this.pdoc.docId, $update); |
| 639 | this.response.redirect = this.url('problem_detail', { pid: newPid || pdoc.docId }); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | export class ProblemConfigHandler extends ProblemManageHandler { |