新增功能
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "BSide";
|
||||
|
||||
class BSideController extends Controller {
|
||||
@@ -144,6 +146,58 @@ class BSideController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出B端用户
|
||||
async downloadBside() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.bSide.downloadBside(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadBside";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BSideController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "BdCard";
|
||||
|
||||
class BdCardController extends Controller {
|
||||
@@ -58,11 +60,11 @@ class BdCardController extends Controller {
|
||||
if (result) {
|
||||
let bdCardMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
bdCardMsg.push(element.dataValues);
|
||||
bdCardMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
bdCardMsg: bdCardMsg,
|
||||
count: result.count
|
||||
bdCardMsg: bdCardMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索北斗卡成功', "deconstruction", data);
|
||||
} else {
|
||||
@@ -136,6 +138,58 @@ class BdCardController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出北斗卡
|
||||
async downloadBDCard() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.bdCard.downloadBDCard(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadBDCard";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BdCardController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "BindRecord";
|
||||
|
||||
class BindRecordController extends Controller {
|
||||
@@ -70,6 +72,58 @@ class BindRecordController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出北斗卡绑定记录绑定记录
|
||||
async downloadBindRecord() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.bindRecord.downloadBindRecord(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadBindRecord";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BindRecordController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "BindSNRecord";
|
||||
|
||||
class BindSNRecordController extends Controller {
|
||||
@@ -70,6 +72,58 @@ class BindSNRecordController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出SN号绑定记录
|
||||
async downloadBindSNRecord() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.bindSNRecord.downloadBindSNRecord(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadBindSNRecord";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BindSNRecordController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "Business";
|
||||
|
||||
class BusinessController extends Controller {
|
||||
@@ -84,40 +86,40 @@ class BusinessController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// 远程搜索公司业务
|
||||
async SearchBusiness() {
|
||||
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.business.SearchBusiness(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let business = [];
|
||||
result.forEach(element => {
|
||||
business.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
business: business,
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索公司业务信息成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索公司业务信息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showBSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
// 远程搜索公司业务
|
||||
async SearchBusiness() {
|
||||
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.business.SearchBusiness(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let business = [];
|
||||
result.forEach(element => {
|
||||
business.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
business: business,
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索公司业务信息成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索公司业务信息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showBSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑公司业务
|
||||
async editBusiness() {
|
||||
@@ -202,6 +204,58 @@ class BusinessController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出公司业务
|
||||
async downloadBusiness() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.business.downloadBusiness(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadBusiness";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BusinessController;
|
||||
@@ -2,105 +2,159 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "CSide";
|
||||
|
||||
class CSideController extends Controller {
|
||||
// 查看C端用户
|
||||
async showCSide() {
|
||||
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.cSide.showCSide(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let CSideMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
CSideMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
CSideMsg: CSideMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索C端用户成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索C端用户失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
// 查看C端用户
|
||||
async showCSide() {
|
||||
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.cSide.showCSide(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let CSideMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
CSideMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
CSideMsg: CSideMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索C端用户成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索C端用户失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑C端用户
|
||||
async editCSide() {
|
||||
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.cSide.editCSide(uid, modelType, updateMsg, requestMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '编辑C端用户信息成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '编辑C端用户信息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "editCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
// 编辑C端用户
|
||||
async editCSide() {
|
||||
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.cSide.editCSide(uid, modelType, updateMsg, requestMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '编辑C端用户信息成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '编辑C端用户信息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "editCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除C端用户
|
||||
async deleteCSide() {
|
||||
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.cSide.deleteCSide(uid, modelType, deCodePassword, requestMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '删除C端用户成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '删除C端用户失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "deleteCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
// 删除C端用户
|
||||
async deleteCSide() {
|
||||
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.cSide.deleteCSide(uid, modelType, deCodePassword, requestMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '删除C端用户成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '删除C端用户失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "deleteCSide";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出C端用户
|
||||
async downloadCside() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.cSide.downloadCside(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadCside";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CSideController;
|
||||
@@ -1,5 +1,7 @@
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "ContestAccount";
|
||||
|
||||
class ContestAccountController extends Controller {
|
||||
@@ -204,6 +206,58 @@ class ContestAccountController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出竞赛账号信息
|
||||
async downloadAccount() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.contestAccount.downloadAccount(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadAccount";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContestAccountController;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "ContestExamination";
|
||||
|
||||
class ContestExaminationController extends Controller {
|
||||
@@ -109,14 +111,38 @@ class ContestExaminationController extends Controller {
|
||||
return;
|
||||
}
|
||||
const uid = JSON.parse(rdmcode).uid;
|
||||
const body = ctx.request.body;
|
||||
const result = await ctx.service.contestExamination.downloadExamination(uid, body);
|
||||
const { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.contestExamination.downloadExamination(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '操作成功', "none");
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "ContestMsg";
|
||||
|
||||
class ContestMsgController extends Controller {
|
||||
@@ -95,11 +97,11 @@ class ContestMsgController extends Controller {
|
||||
if (result) {
|
||||
let contestMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
contestMsg.push(element.dataValues);
|
||||
contestMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
contestMsg,
|
||||
count: result.count
|
||||
contestMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
|
||||
} else {
|
||||
@@ -148,8 +150,8 @@ class ContestMsgController extends Controller {
|
||||
try {
|
||||
let rdmcode = await this.checkUid(ctx);
|
||||
if (!rdmcode) {
|
||||
this.setResponse(ctx, 401, 'token过期或错误', "none");
|
||||
return;
|
||||
this.setResponse(ctx, 401, 'token过期或错误', "none");
|
||||
return;
|
||||
}
|
||||
const uid = JSON.parse(rdmcode).uid;
|
||||
const body = ctx.request.body;
|
||||
@@ -158,13 +160,13 @@ class ContestMsgController extends Controller {
|
||||
const deCodePassword = this.decryptRequest(password);
|
||||
const result = await ctx.service.contestMsg.delContest(uid, modelType, deCodePassword, requestMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
this.setResponse(ctx, 200, '操作成功', "none");
|
||||
this.setResponse(ctx, 200, '操作成功', "none");
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "delContest";
|
||||
@@ -172,6 +174,58 @@ class ContestMsgController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出竞赛信息
|
||||
async downloadContest() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.contestMsg.downloadContest(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadContest";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContestMsgController;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "ContestTopic";
|
||||
|
||||
class ContestTopicController extends Controller {
|
||||
@@ -91,11 +93,11 @@ class ContestTopicController extends Controller {
|
||||
if (result) {
|
||||
let choiceTopicMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
choiceTopicMsg.push(element.dataValues);
|
||||
choiceTopicMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
choiceTopicMsg,
|
||||
count: result.count
|
||||
choiceTopicMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '操作成功', "deconstruction", data);
|
||||
} else {
|
||||
@@ -168,6 +170,58 @@ class ContestTopicController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出选择题
|
||||
async downloadChoiceTopic() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.contestTopic.downloadChoiceTopic(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadChoiceTopic";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContestTopicController;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "Insiders";
|
||||
|
||||
class InsidersController extends Controller {
|
||||
@@ -144,6 +146,58 @@ class InsidersController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出系统用户
|
||||
async downloadInsiders() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.insiders.downloadInsiders(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadInsiders";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = InsidersController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "Monitoring";
|
||||
|
||||
class MonitoringController extends Controller {
|
||||
@@ -70,6 +72,58 @@ class MonitoringController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出监控记录
|
||||
async downloadMonitoring() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.monitoring.downloadMonitoring(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadMonitoring";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MonitoringController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "Organization";
|
||||
|
||||
class OrganizationController extends Controller {
|
||||
@@ -175,6 +177,58 @@ class OrganizationController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出B端用户单位
|
||||
async downloadOrganization() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.organization.downloadOrganization(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadOrganization";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = OrganizationController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "SNAdmin";
|
||||
|
||||
class SNAdminController extends Controller {
|
||||
@@ -43,7 +45,8 @@ class SNAdminController extends Controller {
|
||||
this.setResponse(ctx, 401, 'token过期或错误', "none");
|
||||
return;
|
||||
}
|
||||
const result = await ctx.service.sNAdmin.searchAllocationUser();
|
||||
const body = ctx.request.body;
|
||||
const result = await ctx.service.sNAdmin.searchAllocationUser(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
@@ -156,6 +159,58 @@ class SNAdminController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出B端SN号分配记录
|
||||
async downloadAllocationSNRecord() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.sNAdmin.downloadAllocationSNRecord(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadAllocationSNRecord";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SNAdminController;
|
||||
98
app/controller/SNContest.js
Normal file
98
app/controller/SNContest.js
Normal file
@@ -0,0 +1,98 @@
|
||||
'use strict';
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "SNContest";
|
||||
|
||||
class SNContestController extends Controller {
|
||||
// 获取SN号竞赛消息
|
||||
async getSNContestMsg() {
|
||||
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.sNContest.getSNContestMsg(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let snContestMsg = [];
|
||||
result.rows.forEach(element => {
|
||||
snContestMsg.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
snContestMsg: snContestMsg,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '获取SN号竞赛消息成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '获取SN号竞赛消息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "getSNContestMsg";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出SN号竞赛消息
|
||||
async downloadSNConest() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.sNContest.downloadSNConest(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadSNConest";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SNContestController;
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "SN";
|
||||
|
||||
class SNController extends Controller {
|
||||
@@ -134,6 +136,58 @@ class SNController extends Controller {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出SN号
|
||||
async downloadSN() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.sn.downloadSN(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadSN";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SNController;
|
||||
129
app/controller/UnknownBDCard.js
Normal file
129
app/controller/UnknownBDCard.js
Normal file
@@ -0,0 +1,129 @@
|
||||
'use strict';
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "UnknownBDCard";
|
||||
|
||||
class UnknownBDCardController extends Controller {
|
||||
// 查看未知消息
|
||||
async showUnknownBDCard() {
|
||||
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.unknownBDCard.showUnknownBDCard(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let unknownBDCardRecord = [];
|
||||
result.rows.forEach(element => {
|
||||
unknownBDCardRecord.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
unknownBDCardRecord,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索未知消息成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索未知消息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showUnknownBDCard";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除未知消息
|
||||
async deleteUnknownBDCard() {
|
||||
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.unknownBDCard.deleteUnknownBDCard(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 + "--" + "deleteUnknownBDCard";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出竞赛账号信息
|
||||
async downloadUnknownBDCard() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.unknownBDCard.downloadUnknownBDCard(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadUnknownBDCard";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UnknownBDCardController;
|
||||
129
app/controller/UnknownSN.js
Normal file
129
app/controller/UnknownSN.js
Normal file
@@ -0,0 +1,129 @@
|
||||
'use strict';
|
||||
|
||||
const Controller = require('../core/base_controller');
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const fileName = "UnknownSN";
|
||||
|
||||
class UnknownSNController extends Controller {
|
||||
// 查看未知消息
|
||||
async showUnknownSN() {
|
||||
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.unknownSN.showUnknownSN(body);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result) {
|
||||
let unknownSNRecord = [];
|
||||
result.rows.forEach(element => {
|
||||
unknownSNRecord.push(element.dataValues);
|
||||
});
|
||||
const data = {
|
||||
unknownSNRecord,
|
||||
count: result.count
|
||||
};
|
||||
this.setResponse(ctx, 200, '搜索未知消息成功', "deconstruction", data);
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '搜索未知消息失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "showUnknownSN";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 删除未知消息
|
||||
async deleteUnknownSN() {
|
||||
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.unknownSN.deleteUnknownSN(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 + "--" + "deleteUnknownSN";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
|
||||
// 管理系统导出竞赛账号信息
|
||||
async downloadUnknownSN() {
|
||||
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 { form, searchMsg, dataHeaders } = ctx.request.body;
|
||||
const result = await ctx.service.unknownSN.downloadUnknownSN(uid, searchMsg);
|
||||
if (result == "error") {
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
}
|
||||
if (result.code) {
|
||||
const file = this.downloadData(form, result.data, dataHeaders);
|
||||
if (file) {
|
||||
const { filePath, completeName, buf } = file;
|
||||
try {
|
||||
fs.writeFileSync(filePath, Buffer.from(buf));
|
||||
const data = {
|
||||
// 本机服务器地址
|
||||
// 'http://127.0.0.1:8012'
|
||||
// 'http://192.168.31.28:8012'
|
||||
// 公司服务器地址
|
||||
// 'http://123.57.205.46:8012'
|
||||
// 'http://manager.bdrd.hwasmart.com//accountManager'
|
||||
fileUrl: 'http://127.0.0.1:8012' + `/public/${completeName}?time=${new Date().getTime()}`,
|
||||
fileName: completeName,
|
||||
}
|
||||
this.setResponse(ctx, 200, '文件已成功写入', "deconstruction", data);
|
||||
setTimeout(() => {
|
||||
fs.unlinkSync(filePath);
|
||||
}, 600000);
|
||||
} catch (error) {
|
||||
this.setResponse(ctx, 500, '写入文件时发生错误', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} else {
|
||||
this.setResponse(ctx, 404, '操作失败', "none");
|
||||
}
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "downloadUnknownSN";
|
||||
ctx.app.middleware.log('../../controllerLog', blockName + ">>>>" + error);
|
||||
this.setResponse(ctx, 500, '服务器错误', "none");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UnknownSNController;
|
||||
Reference in New Issue
Block a user