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) => {
|
router.get('/', async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
const result = await ZpText.find({})
|
const result = await ZpText.find({})
|
||||||
console.log(result)
|
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
@ -21,9 +20,11 @@ router.post('/', async (req, res, next) => {
|
|||||||
try {
|
try {
|
||||||
const body = req.body
|
const body = req.body
|
||||||
const title = body.title
|
const title = body.title
|
||||||
|
const tip = body.tip
|
||||||
const text = body.text
|
const text = body.text
|
||||||
const newText = new ZpText({
|
const newText = new ZpText({
|
||||||
title,
|
title,
|
||||||
|
tip,
|
||||||
text,
|
text,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ router.put('/', async (req, res, next) => {
|
|||||||
const body = req.body
|
const body = req.body
|
||||||
const _id = body._id
|
const _id = body._id
|
||||||
const title = body.title
|
const title = body.title
|
||||||
|
const tip = body.tip
|
||||||
const text = body.text
|
const text = body.text
|
||||||
|
|
||||||
const result = await ZpText.updateOne(
|
const result = await ZpText.updateOne(
|
||||||
@ -49,6 +51,7 @@ router.put('/', async (req, res, next) => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title,
|
title,
|
||||||
|
tip,
|
||||||
text,
|
text,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -34,10 +34,12 @@ router.get('/text', async (req, res, next) => {
|
|||||||
|
|
||||||
let result = []
|
let result = []
|
||||||
let title = ''
|
let title = ''
|
||||||
|
let tip = ''
|
||||||
|
|
||||||
if (_id) {
|
if (_id) {
|
||||||
const search = await ZpText.findOne({_id: _id})
|
const search = await ZpText.findOne({_id: _id})
|
||||||
title = search.title
|
title = search.title
|
||||||
|
tip = search.tip
|
||||||
result = parseText(search.text)
|
result = parseText(search.text)
|
||||||
} else {
|
} else {
|
||||||
result = await ZpText.find({}).select('_id title')
|
result = await ZpText.find({}).select('_id title')
|
||||||
@ -46,6 +48,7 @@ router.get('/text', async (req, res, next) => {
|
|||||||
res.send({
|
res.send({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
title: title,
|
title: title,
|
||||||
|
tip: tip,
|
||||||
result: result,
|
result: result,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -7,6 +7,7 @@ import mongoose from 'mongoose'
|
|||||||
const ZpText = new mongoose.Schema(
|
const ZpText = new mongoose.Schema(
|
||||||
{
|
{
|
||||||
title: {type: String},
|
title: {type: String},
|
||||||
|
tip: {type: String},
|
||||||
text: {type: String},
|
text: {type: String},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user