123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 |
- var express = require('express');
- import md5 from "./md5.min.js"
- var bcrypt = require('bcryptjs');
- var router = express.Router();
- var http = require('http');
- var qs = require('qs');
- const querystring = require('querystring');
- var mysql = require('./mysql');
- const _mysqlLabor = ["10.16.30.130", "ssti_cm"];
- var crypto = require('crypto');
- var https = require('https');
- router.use(async function(req, res, next) {
- await asynnext(req, res, next);
-
-
- });
- function asynnext(req, res, next) {
-
- return new Promise(async(resolve, reject) => {
- next();
-
- });
- }
- router.route('/a').all((req, res, next) => {
- var json = GetData(req);
- getmysql(req, res, "a");
- });
- router.post('/getTest', function(req, res, next) {
- const options = {
- hostname: 'apis.ssti.net.cn',
- port: 80,
- path: '/taskcenterapp/sys/taskCenter/taskReceive/pushTask.do',
- method: 'POST',
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'appId': '36dd21cde3b2f30a',
- 'accessToken': '463e95bdad1a9506bd1b271194f89383'
- }
- };
- const req1 = http.request(options, (item) => {
- console.log(`statusCode: ${item.statusCode}`);
- item.on('data', (data) => {
- console.log(data.toString());
- res.end(JSON.stringify(data.toString()));
- });
- });
- req1.on('error', (error) => {
- console.error(error);
- });
- const bodyData = qs.stringify({ appId: "36dd21cde3b2f30a", taskInfo: req.body[0].taskInfo });
- req1.write(bodyData);
- req1.end();
-
-
-
-
-
-
-
-
-
-
-
-
- })
- router.post("/CreateNewNotification", (req, res) => {
- QMysql(req, res, "insert_New")
- })
- router.get('/SelectNotification', (req, res) => {
- QMysql(req, res, 'select_NewByTitle')
- })
- router.post("/DeleteNotification", (req, res) => {
- QMysql(req, res, "update_NewStatusById");
- })
- router.get("/SelectNotificationDetail", (req, res) => {
- QMysql(req, res, "select_NewDetailById");
- })
- router.post("/SelectAllDepartment", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'selectUserIdentity', getUserid], (ret3) => {
- if (ret3[0][0].type == 0) {
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_AllDepartment");
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- } else {
- res.end(JSON.stringify({ a: "权限不足!" }));
- }
- })
- })
- router.get("/SelectAllProject", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_AllProject");
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.post('/DeleteProject', (req, res) => {
- const data = GetData(req);
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'update_ProjectDeleteById', md5(data['uid']), data['pid'], 1], result => res.end(JSON.stringify(result)));
- })
- router.get("/GetAllProjectName", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, 'select_AllProjectName');
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.get('/GetAllActivity', (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_AllActivity")
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.post("/UpdateActivityState", (req, res) => {
- QMysql(req, res, "update_ActivityState");
- })
- router.post("/UploadActivityFile", (req, res) => {
- QMysql(req, res, "update_ActivityReportFile")
- })
- router.post("/UploadProjectManageFile", (req, res) => {
- QMysql(req, res, "update_ProjectManageFile")
- })
-
- router.get("/SelectProjectManageFile", (req, res) => {
- QMysql(req, res, "select_ProjectManageFile")
- })
- router.post("/AddProjectManageFile", (req, res) => {
- QMysql(req, res, "update_EndProjectFile")
- })
- router.post('/UpdateSettlementEndProject', (req, res) => {
- QMysql(req, res, "update_SettlementEndProject");
- })
- router.post("/UpdateMakerFundState", (req, res) => {
- QMysql(req, res, "update_MakerFundState")
- })
- router.post("/UploadFirmFile", (req, res) => {
- QMysql(req, res, "insert_startups")
- })
- router.get("/GetFirmFile", (req, res) => {
- QMysql(req, res, "select_startupsByTitle");
- })
- router.post("/UpdateFirmFileState", (req, res) => {
- QMysql(req, res, "update_startupsState");
- })
- router.post('/GetProjectIsConclusion', (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'selectUserIdentity', getUserid], (ret3) => {
- if (ret3[0][0].type == 0) {
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_ProjectIsConclusion");
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- } else {
- res.end(JSON.stringify({ a: "权限不足!" }));
- }
- })
- })
- router.get("/GetProjectDetailIsConclusion", (req, res) => {
- QMysql(req, res, "select_ProjectResultDetail");
- })
- router.get("/GetActivityNoReportByPId", (req, res) => {
- QMysql(req, res, "select_ActivityNoReportById")
- })
- router.post('/UpdateProjectEndFile', (req, res) => {
- QMysql(req, res, 'update_ProjectEndFile')
- })
- router.get("/SelectResultDetailStudent", (req, res) => {
- QMysql(req, res, "select_resultDetail_student");
- })
- router.get("/SelectProjectWordMakerStudent", (req, res) => {
- QMysql(req, res, 'select_projectWord_makerStudent');
- })
- router.get("/SelectAllProjectManagement", (req, res) => {
- QMysql(req, res, 'select_AllProjectManagement');
- })
- router.get('/SelectAllProjectSettlement', (req, res) => {
- QMysql(req, res, 'select_AllProjectSettlement')
- })
- router.post("/updateIsupload", (req, res) => {
- QMysql(req, res, 'update_Isupload');
- })
- router.get('/getProjectNo', (req, res) => {
- QMysql(req, res, 'select_LastProjectNo')
- })
- router.get('/getActivityNo', (req, res) => {
- QMysql(req, res, 'select_LastActvityNo');
- })
- router.get('/getFundNo', (req, res) => {
- QMysql(req, res, 'select_LastFundNo')
- })
- router.post('/MakerSpaceWordApply', (req, res) => {
- QMysql(req, res, 'insert_Project_MakerSpaceWord');
- })
- router.get("/getMakerSpaceWordData", (req, res) => {
- QMysql(req, res, 'select_projectMakerSpaceWord')
- })
- router.post('/updateMakerSpaceWordData', (req, res) => {
- QMysql(req, res, 'update_projectMakerSpaceWord')
- })
- router.post('/studentProjectWordApply', (req, res) => {
- QMysql(req, res, 'insert_Project_studentProject');
- })
- router.get('/studentProjectData', (req, res) => {
- QMysql(req, res, 'select_Project_studentProjectData');
- })
- router.post('/updateStudentProjectData', (req, res) => {
- QMysql(req, res, 'update_Project_studentProjectData');
- })
- router.get('/getProjectFund', (req, res) => {
- QMysql(req, res, 'select_project_activityFund');
- })
- router.post("/ActivityApply", (req, res) => {
- QMysql(req, res, 'insert_activityWord')
- })
- router.get("/getActivityWordData", (req, res) => {
- QMysql(req, res, 'select_activityWord')
- })
- router.post('/UpdateActivityWordData', (req, res) => {
- QMysql(req, res, 'update_activityWord')
- })
- router.get('/selectMarkerFundData', (req, res) => {
- QMysql(req, res, 'select_MarkerFundData');
- })
- router.get("/SelectMakerFundSelects", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_MakerFundSelects")
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.post("/insertFundApply", (req, res) => {
- QMysql(req, res, "insert_fundApply")
- })
- router.get("/selectAllFundApply", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, "select_AllFundApply")
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.get("/selectActivityFundDetail", (req, res) => {
- QMysql(req, res, "select_activity_fundDetail")
- })
- router.post("/updateActivityFundDetail", (req, res) => {
- QMysql(req, res, "update_activity_fundDetail")
- })
- router.get("/getNoEndFundByActivity", (req, res) => {
- QMysql(req, res, 'select_fundNoEndByActivity')
- })
- router.get('/getProjectActivityFundIsUseDetail', (req, res) => {
- QMysql(req, res, 'select_projectIsUseFundDetail')
- })
- router.get('/getProjectActivityAllFund', (req, res) => {
- QMysql(req, res, 'select_projectActivityAllFund')
- })
- router.get('/getEchartsData', (req, res) => {
- QMysql(req, res, 'select_EchartsData')
- })
- router.get('/getSystemState', (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, 'select_systemState')
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.post('/setSystemState', (req, res) => {
- QMysql(req, res, 'update_systemState')
- })
- router.get("/SelectProjectEndData", (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (md5(data['uid']) == getUserid) {
- QMysql(req, res, 'select_PlanEndProject')
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.get("/selectPhrases", (req, res) => {
- QMysql(req, res, 'selectPhrases')
- })
- router.get("/insertPhrases", (req, res) => {
- QMysql(req, res, 'insertPhrases')
- })
- router.post("/insertSign", (req, res) => {
- QMysql(req, res, "insertSign")
- })
- router.get("/selectSign", (req, res) => {
- QMysql(req, res, 'selectSign')
- })
- router.get("/SelectProjectFile", (req, res) => {
- QMysql(req, res, "select_ProjectFile")
- })
-
- router.post("/AddProjectFile", (req, res) => {
- QMysql(req, res, "update_ProjectFile")
- })
- router.get("/getClosingstatementData", (req, res) => {
- QMysql(req, res, "select_ClosingstatementData")
- })
- router.post("/updateClosingstatementData", (req, res) => {
- QMysql(req, res, "update_ClosingstatementData")
- })
- router.get("/selectAmendFinish", (req, res) => {
- QMysql(req, res, "select_AmendFinish")
- })
- router.get("/getProjectBookData", (req, res) => {
- QMysql(req, res, "select_ProjectBookData")
- })
- function getUid(str) {
- const variables = str.split(";");
- const values = {}
- for (var i = 0; i < variables.length; i++) {
- const noSpace = variables[i].trim();
- const [key, value] = noSpace.split("=");
- values[key] = value;
- }
- return values['vue_admin_template_token'];
- }
- router.post('/userLogin', (req, res) => {
- let data = GetData(req);
- const str = req.headers.cookie ? req.headers.cookie : '';
- const getUserid = getUid(str);
- if (data['id'] == getUserid) {
-
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'select_UserByUserId', data['id']], function(ret) {
- if (ret[0].length == 0) {
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'select_UserMessageById', data['id']], (ret2) => {
- let userData = {};
-
- if (ret2[0].length) {
- userData = ret2[0][0];
- userData['type'] = 2
- }
- else if (ret2[1].length) {
- userData = ret2[1][0]
- userData['zymc'] = '';
- userData['type'] = 1;
- };
-
-
- let bm = '';
- if (userData['type'] == 1) bm = userData['bm']
- if (userData['type'] == 2) bm = userData['xy']
-
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'insert_User', userData['id'], userData['xm'], userData['type'], bm, userData['zymc']], (ret3) => {
- console.log(ret3);
- if (ret3 == 1) {
- res.end(JSON.stringify({ userid: userData['id'] }))
- } else {
- res.end('ERROR')
- }
- })
- })
- } else {
-
- res.end(JSON.stringify({...ret[0][0] }));
- }
- });
- } else {
- res.end(JSON.stringify({ a: "身份认证失败!" }));
- }
- })
- router.post('/userLogin2', (req, res) => {
- let data = GetData(req);
-
- mysql.usselect([_mysqlLabor[0], _mysqlLabor[1], 'select_UserByUserId1', data['id']], function(ret) {
- res.end(JSON.stringify(ret[0][0]));
- });
- })
- GetData = function(req) {
- var a = req.url.split("?");
- var json = querystring.parse(a[1])
- if (Object.keys(json).length != 0) {
- return json
- } else if (req.body) {
- return req.body
- } else if (req.body.mode) {
- return req.body.mode;
- }
- }
- QMysql = function(req, res, functionName) {
- if (GetData(req)) {
- p = Object.values(GetData(req));
-
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionName);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- } else {
- res.end("未获取参数")
- }
- }
- postmysql2 = function(req, res, functionname) {
-
- if (req.body) {
- p = Object.values(req.body)[0].split(",");
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- }
- }
- postmysql3 = function(req, res, functionname) {
-
- if (req.body) {
- p = Object.values(req.body);
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- }
- }
- getmysql = function(req, res, functionname, ...p) {
- p = p || [];
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- }
- userpostmysql = function(req, res, functionname) {
-
- if (req.body.mode) {
- p = req.body.mode.split(",");
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- }
- }
- usergetmysql = function(req, res, functionname, ...p) {
- p = p || [];
- p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
-
- mysql.usselect(p, function(ret) { res.end(JSON.stringify(ret)); });
- }
- module.exports = router;
|