北斗导航定位通信综合实践赛服务系统

This commit is contained in:
2026-03-27 17:50:54 +08:00
commit f1d7b4895c
44 changed files with 1810 additions and 0 deletions

64
app/controller/Check.js Normal file
View File

@@ -0,0 +1,64 @@
const Controller = require('../core/base_controller');
const fileName = "Check";
class CheckController extends Controller {
// 检查竞赛账号是否已经绑定北斗卡
async checkUser() {
const { ctx } = this;
try {
let rdmcode = await this.checkUid(ctx);
if (!rdmcode) {
this.setResponse(ctx, 401, 'token过期或错误', "none");
return;
}
const uid = JSON.parse(rdmcode).uid;
const result = await ctx.service.check.checkUser(uid);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
const data = {
card_id: result.dataValues.card_id,
};
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "checkUser";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 检查北斗卡是否已经被绑定
async checkBind() {
const { ctx } = this;
try {
let rdmcode = await this.checkUid(ctx);
if (!rdmcode) {
this.setResponse(ctx, 401, 'token过期或错误', "none");
return;
}
const { card_id } = ctx.request.body;
const result = await ctx.service.check.checkBind(card_id);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
this.setResponse(ctx, 200, '操作成功', "none");
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "checkBind";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = CheckController;