"use strict"; const Board = require('./sysBoard.model'); module.exports = { async publish (req, res) { const { data = {} } = req.body; new Board(data).save().then(anno => { return res.json({ code: 0, data: anno }); }).catch(err => { mylog.error(err); return res.json({ code: 1, error: JSON.stringify(err) }); }); }, async getList (req, res) { const { config } = req.query; return Board.find(config, 'id title short url option createdAt').then(data => { return res.json({ code: 0, data }); }).catch(err => { mylog.error(err); return res.json({ code: 1, error: JSON.stringify(err) }); }); }, async getOne (req, res) { const { id } = req.query; return Board.findById(id, 'id title url option body author').then(data => { return res.json({ code: 0, data }).catch(err => { mylog.error(err); return res.json({ code: 1, error: JSON.stringify(err) }); }); }); }, async updateOne (req, res) { const { id, data } = req.body; return Board.findByIdAndUpdate(id, data).then(data => { return res.json({ code: 0, data }).catch(err => { mylog.error(err); return res.json({ code: 1, error: JSON.stringify(err) }); }); }); }, async deleteOne (req, res) { const { id, data } = req.body; return Board.findByIdAndDelete(id).then(data => { return res.json({ code: 0, data }).catch(err => { mylog.error(err); return res.json({ code: 1, error: JSON.stringify(err) }); }); }); }, };