北斗应用技术培训考试管理系统

This commit is contained in:
2026-03-27 17:54:10 +08:00
commit 359dff3cad
106 changed files with 9510 additions and 0 deletions

167
app/controller/Search.js Normal file
View File

@@ -0,0 +1,167 @@
const Controller = require('../core/base_controller');
const fileName = "Search";
class SearchController extends Controller {
// 管理系统检索考生姓名
async searchUserName() {
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.search.searchUserName(uid, body);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
let userName = [];
result.forEach(element => {
userName.push({ value: element.dataValues.user_name });
});
this.setResponse(ctx, 200, '操作成功', "polymerization", userName);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "searchUserName";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 管理系统检索考生身份证号
async searchIdentityCard() {
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.search.searchIdentityCard(uid, body);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
let identityCard = [];
result.forEach(element => {
identityCard.push({ value: element.dataValues.identity_card });
});
this.setResponse(ctx, 200, '操作成功', "polymerization", identityCard);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "searchIdentityCard";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 管理系统检索考试uid
async searchExamUid() {
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.search.searchExamUid(uid, body);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
let examUid = [];
result.forEach(element => {
examUid.push({ value: element.dataValues.uid });
});
this.setResponse(ctx, 200, '操作成功', "polymerization", examUid);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "searchExamUid";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 管理系统检索工作单位
async searchWorkplace() {
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.search.searchWorkplace(uid, body);
if (result == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (result) {
let workplace = [];
result.forEach(element => {
workplace.push({ value: element.dataValues.workplace });
});
this.setResponse(ctx, 200, '操作成功', "polymerization", workplace);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "searchWorkplace";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
// 管理系统检索报名结果说明
async searchResult() {
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 results = await ctx.service.search.searchResult(uid, body);
if (results == "error") {
this.setResponse(ctx, 500, '服务器错误', "none");
return;
}
if (results) {
let result = [];
results.forEach(element => {
result.push({ value: element.dataValues.result });
});
this.setResponse(ctx, 200, '操作成功', "polymerization", result);
} else {
this.setResponse(ctx, 404, '操作失败', "none");
}
} catch (error) {
const blockName = fileName + "--" + "searchResult";
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
this.setResponse(ctx, 500, '服务器错误', "none");
}
}
}
module.exports = SearchController;