北斗应用技术培训考试管理系统
This commit is contained in:
82
app/service/Find.js
Normal file
82
app/service/Find.js
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const Service = require('../core/base_service');
|
||||
|
||||
const { Op } = require('sequelize');
|
||||
|
||||
const fileName = "Find";
|
||||
|
||||
class FindService extends Service {
|
||||
// 管理系统检索考生姓名
|
||||
async findUserName(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model.Examinee.findOne({ where: { user_name: body.user_name } });
|
||||
return result || false;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "findUserName";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统检索考生身份证号
|
||||
async findIdentityCard(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model.Examinee.findOne({ where: { identity_card: body.identity_card } });
|
||||
if (!result) return { code: 404 };
|
||||
const user = await ctx.model.Examinee.findOne({ where: { user_name: body.user_name, identity_card: body.identity_card } });
|
||||
if (!user) return { code: 303 };
|
||||
return { code: 200 };
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "findIdentityCard";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统检索考生 uid
|
||||
async findUserUid(identity_card, user_name) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
let attributes = ['uid'],
|
||||
where = { identity_card, user_name },
|
||||
dbOptions = { attributes, where };
|
||||
const result = await ctx.model.Examinee.findOne(dbOptions);
|
||||
return result || false;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "findUserUid";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统检索考试 uid
|
||||
async findExamUid(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model.Examination.findOne({ where: { uid: body.exam_uid } });
|
||||
return result || false;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "findExamUid";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统查找指定工作单位
|
||||
async findWorkplace(uid, body) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model.Examinee.findOne({ where: { workplace: body.workplace } });
|
||||
return result || false;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "findWorkplace";
|
||||
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FindService;
|
||||
Reference in New Issue
Block a user