mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: api: get contest
This commit is contained in:
1 parent
89424ec9cd
commit
5272a35b09
6 files changed
+33
-6
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.1.14",
|
||||
"version": "3.1.15",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -18,6 +18,33 @@ import user from '../model/user';
|
||||
import {
|
||||
Handler, param, Route, Types,
|
||||
} from '../service/server';
|
||||
import { registerResolver, registerValue } from './api';
|
||||
|
||||
registerValue('Contest', [
|
||||
['_id', 'ObjectID!'],
|
||||
['domainId', 'String!'],
|
||||
['docId', 'ObjectID!'],
|
||||
['owner', 'Int!'],
|
||||
['beginAt', 'Date!'],
|
||||
['title', 'String!'],
|
||||
['content', 'String!'],
|
||||
['beginAt', 'Date!'],
|
||||
['endAt', 'Date!'],
|
||||
['attend', 'Int!'],
|
||||
['pids', '[Int]!'],
|
||||
['rated', 'Boolean!'],
|
||||
]);
|
||||
|
||||
registerResolver(
|
||||
'Query', 'contest(id: ObjectID!)', 'Contest',
|
||||
async (arg, ctx) => {
|
||||
arg.id = new ObjectID(arg.id);
|
||||
ctx.tdoc = await contest.get(ctx.domainId, new ObjectID(arg.id));
|
||||
if (!ctx.tdoc) throw new ContestNotFoundError(ctx.domainId, arg.id);
|
||||
return ctx.tdoc;
|
||||
},
|
||||
'Get a contest by ID',
|
||||
);
|
||||
|
||||
export class ContestListHandler extends Handler {
|
||||
@param('rule', Types.Range(contest.RULES), true)
|
||||
|
||||
@@ -106,7 +106,7 @@ export class FSDownloadHandler extends Handler {
|
||||
this.response.etag = file.etag;
|
||||
this.response.body = await storage.get(target);
|
||||
this.response.type = file['Content-Type'] || type;
|
||||
this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
if (!noDisposition) this.response.disposition = `attachment; filename=${encodeURIComponent(filename)}`;
|
||||
} else {
|
||||
this.response.redirect = await storage.signDownloadLink(
|
||||
target, noDisposition ? undefined : filename, false, 'user',
|
||||
|
||||
@@ -23,8 +23,8 @@ console.log(
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
window.UiContext = JSON.parse(window.UiContext);
|
||||
|
||||
// eslint-disable-next-line
|
||||
try { __webpack_public_path__ = UiContext.cdn_prefix } catch (e) { }
|
||||
// eslint-disable-next-line camelcase
|
||||
try { __webpack_public_path__ = UiContext.cdn_prefix; } catch (e) { }
|
||||
|
||||
// Locale & langs
|
||||
const { version, payload } = JSON.parse(localStorage.getItem('hydro-constant') || '{}');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/ui-default",
|
||||
"version": "4.26.8",
|
||||
"version": "4.26.9",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "hydro.js",
|
||||
|
||||
@@ -26,7 +26,7 @@ const page = new NamedPage('api', async () => {
|
||||
defaultQuery={defaultQuery}
|
||||
fetcher={async (graphQLParams) => {
|
||||
const data = await fetch(
|
||||
'/api',
|
||||
'',
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in new issue
Block a user