const Controller = require('../core/base_controller'); const fileName = "ContestExamination"; class ContestExaminationController extends Controller { // 管理系统查看账号答题情况 async showExamination() { const { ctx } = this; try { let rdmcode = await this.checkUid(ctx); if (!rdmcode) { this.setResponse(ctx, 401, 'token过期或错误', "none"); return; } const body = ctx.request.body; const result = await ctx.service.contestExamination.showExamination(body); if (result == "error") { this.setResponse(ctx, 500, '服务器错误', "none"); return; } if (result) { let examinationMsg = []; result.rows.forEach(element => { examinationMsg.push(element.dataValues); }); const data = { examinationMsg, count: result.count }; this.setResponse(ctx, 200, '操作成功', "deconstruction", data); } else { this.setResponse(ctx, 404, '操作失败', "none"); } } catch (error) { const blockName = fileName + "--" + "showExamination"; ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error); this.setResponse(ctx, 500, '服务器错误', "none"); } } // 管理系统编辑账号答题情况 async editExamination() { 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 { model, updateMsg, requestMsg } = body const modelType = this.decryptRequest(model); const result = await ctx.service.contestExamination.editExamination(uid, modelType, updateMsg, requestMsg); 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 + "--" + "editExamination"; ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error); this.setResponse(ctx, 500, '服务器错误', "none"); } } // 管理系统删除账号答题情况 async delExamination() { 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 { model, password, requestMsg } = body const modelType = this.decryptRequest(model); const deCodePassword = this.decryptRequest(password); const result = await ctx.service.contestExamination.delExamination(uid, modelType, deCodePassword, requestMsg); 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 + "--" + "delExamination"; ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error); this.setResponse(ctx, 500, '服务器错误', "none"); } } // 管理系统导出账号答题情况 async downloadExamination() { 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.contestExamination.downloadExamination(uid, body); 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 + "--" + "downloadExamination"; ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error); this.setResponse(ctx, 500, '服务器错误', "none"); } } } module.exports = ContestExaminationController;