一些微小的贡献
This commit is contained in:
@@ -4,13 +4,14 @@ import config from "@/config";
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
if (req.method === "POST") {
|
||||
if (req.headers.token !== config.token) {
|
||||
console.log("wrong token", req.headers.token, config.token);
|
||||
console.log("api::config: wrong token", req.headers.token, config.token);
|
||||
res.status(403).json({ error: "wrong token" });
|
||||
return;
|
||||
}
|
||||
// update config
|
||||
config.begin = req.body.begin ?? config.begin;
|
||||
config.limit = req.body.limit ?? config.limit;
|
||||
console.log("api::config: update config", config);
|
||||
}
|
||||
res.status(200).json(config);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import config from "@/config";
|
||||
|
||||
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const store = storeProxy.get();
|
||||
// console.log("api::store.null()", store);
|
||||
if (req.method === "POST") {
|
||||
if (!config.begin) {
|
||||
res.status(400).json({
|
||||
@@ -13,7 +14,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
return;
|
||||
}
|
||||
const json = req.body;
|
||||
console.log("request", json);
|
||||
console.log("api::request: new request", json);
|
||||
if (json.checked) {
|
||||
let count = 0;
|
||||
for (const name in store) {
|
||||
@@ -21,13 +22,13 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
count += 1;
|
||||
if (count >= config.limit) {
|
||||
res.status(403).json({
|
||||
error: `超过选择数量限制: ${config.limit}`,
|
||||
error: `超过选择数量限制,您至多选 ${config.limit} 个班.`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check whether it is alreadly occupied
|
||||
// check whether it is already occupied
|
||||
if (store[json.name] !== undefined) {
|
||||
res.status(403).json({
|
||||
error: `当前位置已被他人占用`,
|
||||
@@ -46,8 +47,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
delete store[json.name];
|
||||
}
|
||||
}
|
||||
console.log("query", req.query);
|
||||
const resp = {
|
||||
const resp: { occupied: string[], myselect: string[] } = { // try to fix
|
||||
occupied: [],
|
||||
myselect: [],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user