mp_zp 增加导语
This commit is contained in:
parent
8fb10889b8
commit
689eede79a
@ -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,
|
||||
}
|
||||
)
|
||||
|
@ -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) {
|
||||
|
@ -7,6 +7,7 @@ import mongoose from 'mongoose'
|
||||
const ZpText = new mongoose.Schema(
|
||||
{
|
||||
title: {type: String},
|
||||
tip: {type: String},
|
||||
text: {type: String},
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user