From 7fcdbadb84503dc17cc7d3207c09844032d4852e Mon Sep 17 00:00:00 2001 From: pan <1029559041@qq.com> Date: Sun, 18 Oct 2020 22:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE=E4=B8=80?= =?UTF-8?q?=E8=88=AC=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 3 ++- routes/project/info.js | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index c52c152..8871f7e 100644 --- a/app.js +++ b/app.js @@ -10,6 +10,7 @@ var mainRouter=require('./routes/main/main') var projectRouter=require('./routes/main/project') var dataRouter=require('./routes/main/data') var projectDetailRouter=require('./routes/project/project') +var infoRouter=require('./routes/project/info') const server = require("inspector"); var app = express(); @@ -31,7 +32,7 @@ app.use(cors({ app.use('/', indexRouter); app.use('/api/account',accountRouter) app.use('/api/main',mainRouter,projectRouter,dataRouter) -app.use('/api/project',projectDetailRouter) +app.use('/api/project',projectDetailRouter,infoRouter) // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/routes/project/info.js b/routes/project/info.js index ada051d..99c5cd9 100644 --- a/routes/project/info.js +++ b/routes/project/info.js @@ -2,7 +2,32 @@ var express = require('express'); var router = express.Router(); var mock = require('../../public/javascripts/mock') var Mock = require("mockjs") +var multipart = require('connect-multiparty'); +var multipartMiddleware = multipart(); +var moment = require("moment") +var util=require("../../public/javascripts/util") +//获取一般信息 +router.get('/info', function (req, res, next) { + var data={ + ...mock.ok('成功获取项目一般信息') + ,...{ + body: { + companyName: Mock.Random.name(), + device: Mock.Random.name(), + unit: Mock.Random.name(), + projectNumber: Mock.Random.guid(), + startDate: Mock.Random.date(), + endDate: Mock.Random.date(), + analyticalMethod: Mock.Random.name(), + note: Mock.Random.name() + } + }} + res.json(data) +}) - +//保存一般信息 +router.post('/info', multipartMiddleware,function (req, res, next) { + res.json(mock.ok(`数据自动保存成功,最后更新时间:${moment().format(util.dateFormat)}`)) +}) module.exports = router \ No newline at end of file