template into ui

This commit is contained in:
undefined committed 2020-07-31 13:09:08 +08:00
1 parent 43ee86d34b
commit 8bb389eedd
13 files changed
+70 -206

No files matched your search

+3 -2
View File
@@ -6,7 +6,6 @@ import * as problem from './problem';
import {
Rdoc, TestCase, PretestConfig, ContestInfo, ProblemConfig,
} from '../interface';
import { RecordNotFoundError } from '../error';
import * as db from '../service/db';
const coll = db.collection('record');
@@ -48,7 +47,9 @@ export interface JudgeTask {
}
export async function get(domainId: string, _id: ObjectID): Promise<Rdoc | null> {
return await coll.findOne({ domainId, _id });
const res = await coll.findOne({ _id });
if (res && res.domainId === domainId) return res;
return null;
}
export async function judge(domainId: string, rid: ObjectID) {
+8 -6
View File
@@ -1,3 +1,4 @@
import { TokenDoc } from '../interface';
import * as db from '../service/db';
const coll = db.collection('token');
@@ -16,7 +17,9 @@ function ensureIndexes() {
]);
}
export async function add(tokenType: number, expireSeconds: number, data: any) {
export async function add(
tokenType: number, expireSeconds: number, data: any,
): Promise<[string, TokenDoc]> {
const now = new Date();
const str = String.random(32);
const res = await coll.insertOne({
@@ -30,9 +33,8 @@ export async function add(tokenType: number, expireSeconds: number, data: any) {
return [str, res.ops[0]];
}
export async function get(tokenId: string, tokenType: number) {
const res = await coll.findOne({ _id: tokenId, tokenType });
return res;
export async function get(tokenId: string, tokenType: number): Promise<TokenDoc | null> {
return await coll.findOne({ _id: tokenId, tokenType });
}
export async function update(
@@ -73,11 +75,11 @@ export async function createOrUpdate(
}
export function getSessionListByUid(uid: number) {
return coll.find({ uid, tokenType: this.TYPE_SESSION }).sort('updateAt', -1).toArray();
return coll.find({ uid, tokenType: TYPE_SESSION }).sort('updateAt', -1).toArray();
}
export function getMostRecentSessionByUid(uid: number) {
return coll.findOne({ uid, tokenType: this.TYPE_SESSION }, { sort: { updateAt: -1 } });
return coll.findOne({ uid, tokenType: TYPE_SESSION }, { sort: { updateAt: -1 } });
}
export function delByUid(uid: number) {
+2 -2
View File
@@ -199,7 +199,7 @@ export async function create(
return uid;
}
export function getMulti(params) {
export function getMulti(params: any) {
return coll.find(params);
}
@@ -210,7 +210,7 @@ export async function getPrefixList(prefix: string, limit = 50) {
return udocs;
}
export async function setPriv(uid: number, priv: number) {
export async function setPriv(uid: number, priv: number): Promise<Udoc | null> {
const udoc = await coll.findOneAndUpdate(
{ _id: uid },
{ $set: { priv } },