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

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

63
app/controller/Bind.js Normal file
View File

@@ -0,0 +1,63 @@
const Controller = require('../core/base_controller');
const fileName = "Bind";
class BindController extends Controller {
// 绑定北斗卡
async bindCard() {
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 { card_id, card_imsi } = ctx.request.body;
const result = await ctx.service.bind.bindCard(uid, card_id, card_imsi);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
this.setResponse(ctx, 200, '操作成功', "deconstruction", result);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "bindCard";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 解绑北斗卡
async unBindCard() {
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 { card_id, card_imsi } = ctx.request.body;
const result = await ctx.service.bind.unBindCard(uid, card_id, card_imsi);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
this.setResponse(ctx, 200, '操作成功', "deconstruction", result);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "unBindCard";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = BindController;

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;

67
app/controller/Contest.js Normal file
View File

@@ -0,0 +1,67 @@
const Controller = require('../core/base_controller');
const fileName = "Contest";
class ContestController extends Controller {
// 系统获取竞赛基本信息
async contestMsg() {
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.contest.contestMsg(uid);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
const data = {
contestMsg: result.dataValues
}
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "contestMsg";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 系统获取排名信息
async ranking() {
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.contest.ranking(uid);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
const data = {
rankList: result
}
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "ranking";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = ContestController;

133
app/controller/Exam.js Normal file
View File

@@ -0,0 +1,133 @@
const Controller = require('../core/base_controller');
const fileName = "Exam";
class ExamController extends Controller {
// 学生获取历史消息
async getHistoryMsg() {
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 body = ctx.request.body;
const result = await ctx.service.exam.getHistoryMsg(uid, body);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
let historyMsg = [];
result.rows.forEach(element => {
historyMsg.push(element.dataValues);
});
const data = {
historyMsg: historyMsg,
count: result.count
};
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "getHistoryMsg";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 学生删除历史消息
async delHistoryMsg() {
const ctx = this.ctx;
try {
let rdmcode = await checkUid(ctx);
if (!rdmcode) {
setResponse(ctx, 401, 'token过期或错误', "none");
return;
}
const uid = JSON.parse(rdmcode).uid;
const body = ctx.request.body;
const model = decryptRequest(body.model);
const password = decryptRequest(body.password);
const requestMsg = body.userMsg;
const resetList = await ctx.service.exam.delHistoryMsg(uid, model, password, requestMsg);
if (resetList == "error") {
setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (resetList) {
setResponse(ctx, 200, '删除历史消息成功', "none");
} else {
setResponse(ctx, 404, '删除历史消息失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "delHistoryMsg";
ctx.app.middleware.utils.log('../../../controllerLog', blockName + ">>>>" + error);
setResponse(ctx, 500, '服务器错误', "none");
}
}
// 学生完成答题
async answer() {
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 body = ctx.request.body;
const result = await ctx.service.exam.answer(uid, body);
// await ctx.service.bind.unBindCard(uid);
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 + "--" + "answer";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 学生查看成绩信息
async grades() {
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.exam.grades(uid);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
const data = {
grades: result.dataValues
};
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "grades";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = ExamController;

74
app/controller/Topic.js Normal file
View File

@@ -0,0 +1,74 @@
const Controller = require('../core/base_controller');
const fileName = "Topic";
class TopicController extends Controller {
// 学生抽取/读取题目
async topic() {
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 bind = await ctx.service.check.checkUser(uid);
if (!bind) {
this.setResponse(ctx, 333, '未绑定北斗卡', "none");
return;
}
const { answerId } = ctx.request.body;
const result = await ctx.service.topic.topic(uid, answerId);
if (bind == "error" || result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result.code == 200) {
const data = {
examination: result.examination,
shortMsg: result.shortMsg,
};
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "topic";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 系统读取单选题
async radio() {
const { ctx } = this;
try {
let rdmcode = await this.checkUid(ctx);
if (!rdmcode) {
this.setResponse(ctx, 401, 'token过期或错误', "none");
return;
}
const { radioArr } = ctx.request.body;
const result = await ctx.service.topic.radio(radioArr);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
const data = {
radioTopic: result,
}
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "radio";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = TopicController;