mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: problem_star builder
This commit is contained in:
7 files changed
+39
-52
No files matched your search
@@ -121,14 +121,12 @@ export class HomeHandler extends Handler {
|
||||
if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) return [[], {}];
|
||||
const psdocs = await ProblemModel.getMultiStatus(domainId, { uid: this.user._id, star: true })
|
||||
.sort('_id', 1).limit(limit).toArray();
|
||||
const psdict = {};
|
||||
for (const psdoc of psdocs) psdict[psdoc.docId] = psdoc;
|
||||
const pdict = await ProblemModel.getList(
|
||||
domainId, psdocs.map((pdoc) => pdoc.docId),
|
||||
this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id, false,
|
||||
);
|
||||
const pdocs = Object.keys(pdict).filter((i) => +i).map((i) => pdict[i]);
|
||||
return [pdocs, psdict];
|
||||
return [pdocs];
|
||||
}
|
||||
|
||||
async getRecentProblems(domainId: string, limit = 10) {
|
||||
|
||||
@@ -187,18 +187,6 @@ export class ProblemMainHandler extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
@param('pid', Types.UnsignedInt)
|
||||
async postStar(domainId: string, pid: number) {
|
||||
await problem.setStar(domainId, pid, this.user._id, true);
|
||||
this.back({ star: true });
|
||||
}
|
||||
|
||||
@param('pid', Types.UnsignedInt)
|
||||
async postUnstar(domainId: string, pid: number) {
|
||||
await problem.setStar(domainId, pid, this.user._id, false);
|
||||
this.back({ star: false });
|
||||
}
|
||||
|
||||
@param('pids', Types.NumericArray)
|
||||
@param('target', Types.String)
|
||||
async postCopy(domainId: string, pids: number[], target: string) {
|
||||
@@ -439,6 +427,12 @@ export class ProblemDetailHandler extends ContestDetailBaseHandler {
|
||||
await problem.del(this.pdoc.domainId, this.pdoc.docId);
|
||||
this.response.redirect = this.url('problem_main');
|
||||
}
|
||||
|
||||
@param('star', Types.Boolean)
|
||||
async postStar(domainId: string, star: boolean) {
|
||||
await problem.setStar(domainId, this.pdoc.docId, this.user._id, star);
|
||||
this.back({ star });
|
||||
}
|
||||
}
|
||||
|
||||
export class ProblemSubmitHandler extends ProblemDetailHandler {
|
||||
|
||||
Reference in new issue
Block a user