booklist.js 527 B

123456789101112131415161718
  1. const { mysql } = require('../qcloud')
  2. module.exports = async (ctx) => {
  3. const books = await mysql('books')
  4. .select('books.*', 'cSessionInfo.user_info')
  5. .join('cSessionInfo', 'books.openid', 'cSessionInfo.open_id')
  6. .orderBy('books.id', 'desc')
  7. ctx.state.data = {
  8. list: books.map(v => {
  9. const info = JSON.parse(v.user_info)
  10. return Object.assign({}, v, {
  11. user_info: {
  12. nickName: info.nickName
  13. }
  14. })
  15. })
  16. }
  17. }