1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- /**
- * Created by zhang on 2019/12/3.
- */
- /**
- * Created by jimiz on 2017/4/9.
- */
- let logger = require("../../../logs/log_helper").logger;
- let pm_facade = require('../../pm/facade/pm_facade');
- const Project = require('../../main/models/project');
- const project_facade = require('../../main/facade/project_facade.js');
- let controller = {
- importProject:async function (req){
- let data = req.body;
- return await pm_facade.downLoadProjectFile(data);
- },
- exportProject:async function(req){
- let result={
- error:0
- };
- let data = JSON.parse(req.body.dataString);
- result.data = await pm_facade.exportProject(req.body.userID, data);
- return result
- },
- copyProject:async function(req){
- let result={
- error:0
- };
- let data = JSON.parse(req.body.dataString);
- result.data = await pm_facade.copyProject(req.body.userID,req.body.compilationID,data);
- return result
- },
- async importInterface (req) {
- const result = {
- error: 0
- };
- result.data = await pm_facade.importInterface(req.body.key, req.body.session.sessionUser.id, req.body.session.sessionCompilation._id);
- return result;
- },
- async getDataForInterface (req) {
- const result = {
- error: 0
- };
- result.data = await Project.getDataSync(req.body.project_id);
- return result;
- },
- async loadSEIProjectData (req) {
- const result = {
- error: 0
- };
- result.data = await project_facade.loadSEIProjectData(req.body.projectID);
- return result;
- }
- };
- module.exports = {
- action:async function(req,res){//自动跳转到URL对应的controller方法
- let result={
- error:0
- };
- try {
- let functionName = req.url.replace(/\//g,"");
- result = controller[functionName]?await controller[functionName](req):"";
- }catch (err){
- logger.err(err);
- if(typeof err == "string"){
- result.error=2;
- result.msg = err;
- }else {
- result.error=1;
- result.msg = "导入失败请检查文件!"
- }
- }
- res.json(result);
- }
- };
|