From 689eede79aed3d45f99c56cf949abea8cb6a0828 Mon Sep 17 00:00:00 2001 From: yulixing Date: Tue, 29 Oct 2019 16:17:47 +0800 Subject: [PATCH] =?UTF-8?q?mp=5Fzp=20=E5=A2=9E=E5=8A=A0=E5=AF=BC=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/mp_zp/text.js | 5 ++++- src/controllers/open/zp.js | 3 +++ src/models/mp_zp/ZpText.js | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/mp_zp/text.js b/src/controllers/mp_zp/text.js index be617a1..4a757e6 100644 --- a/src/controllers/mp_zp/text.js +++ b/src/controllers/mp_zp/text.js @@ -6,7 +6,6 @@ const router = new Router() router.get('/', async (req, res, next) => { try { const result = await ZpText.find({}) - console.log(result) res.send({ errcode: 0, @@ -21,9 +20,11 @@ router.post('/', async (req, res, next) => { try { const body = req.body const title = body.title + const tip = body.tip const text = body.text const newText = new ZpText({ title, + tip, text, }) @@ -41,6 +42,7 @@ router.put('/', async (req, res, next) => { const body = req.body const _id = body._id const title = body.title + const tip = body.tip const text = body.text const result = await ZpText.updateOne( @@ -49,6 +51,7 @@ router.put('/', async (req, res, next) => { }, { title, + tip, text, } ) diff --git a/src/controllers/open/zp.js b/src/controllers/open/zp.js index ccdaa8f..ee6bdb3 100644 --- a/src/controllers/open/zp.js +++ b/src/controllers/open/zp.js @@ -34,10 +34,12 @@ router.get('/text', async (req, res, next) => { let result = [] let title = '' + let tip = '' if (_id) { const search = await ZpText.findOne({_id: _id}) title = search.title + tip = search.tip result = parseText(search.text) } else { result = await ZpText.find({}).select('_id title') @@ -46,6 +48,7 @@ router.get('/text', async (req, res, next) => { res.send({ errcode: 0, title: title, + tip: tip, result: result, }) } catch (err) { diff --git a/src/models/mp_zp/ZpText.js b/src/models/mp_zp/ZpText.js index ac1e7ac..f191a73 100644 --- a/src/models/mp_zp/ZpText.js +++ b/src/models/mp_zp/ZpText.js @@ -7,6 +7,7 @@ import mongoose from 'mongoose' const ZpText = new mongoose.Schema( { title: {type: String}, + tip: {type: String}, text: {type: String}, }, {