北斗应用技术培训考试管理系统
This commit is contained in:
79
app/controller/Diff.js
Normal file
79
app/controller/Diff.js
Normal file
@@ -0,0 +1,79 @@
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fileName = "Diff";
|
||||
|
||||
class DiffController extends Controller {
|
||||
// 比较身份证号
|
||||
async diffIdentityCard() {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const body = ctx.request.body;
|
||||
const { identity_card, type, data } = body;
|
||||
const uid = data == 'null' ? null : data.split('?')[0];
|
||||
const result = await ctx.service.diff.diffIdentityCard(identity_card, type, uid);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (!result) {
|
||||
this.setResponse(ctx, 404, '该身份证号已注册', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 200, '验证通过', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "diffIdentityCard";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 比较邮箱
|
||||
async diffEmail() {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const body = ctx.request.body;
|
||||
const { email, type, data } = body;
|
||||
const uid = data == 'null' ? null : data.split('?')[0];
|
||||
const result = await ctx.service.diff.diffEmail(email, type, uid);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (!result) {
|
||||
this.setResponse(ctx, 404, '该邮箱已经注册', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 200, '验证通过', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "diffEmail";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 比较电话号码
|
||||
async diffPhone() {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const body = ctx.request.body;
|
||||
const { phone, type, data } = body;
|
||||
const uid = data == 'null' ? null : data.split('?')[0];
|
||||
const result = await ctx.service.diff.diffPhone(phone, type, uid);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (!result) {
|
||||
this.setResponse(ctx, 404, '该手机号已注册', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 200, '验证通过', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "diffPhone";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DiffController;
|
||||
Reference in New Issue
Block a user