addcomment.js 464 B

12345678910111213141516171819
  1. const { mysql } = require('../qcloud')
  2. module.exports = async (ctx) => {
  3. const {bookid, comment, openid, location, phone} = ctx.request.body
  4. console.log(bookid, comment, openid, location, phone)
  5. try {
  6. await mysql('comments').insert({bookid, comment, openid, location, phone})
  7. ctx.state.data = {
  8. msg: 'success'
  9. }
  10. } catch (e) {
  11. ctx.state = {
  12. code: -1,
  13. data: {
  14. msg: '评论失败' + e.sqlMessage
  15. }
  16. }
  17. }
  18. }