const router = require('koa-router')() const UserDao = require('../dao/UserDao') const crypto = require('crypto') router.get('/', async (ctx, next) => { await ctx.render('index', { title: 'Hello Koa 2!' }) ctx.body = { code: 0, msg: 'Hello' } }) router.get('/string', async (ctx, next) => { ctx.body = 'koa2 string' }) router.get('/json', async (ctx, next) => { ctx.body = { title: 'koa2 json' } }) router.get('/test', async (ctx, next) => { // let user = await UserDao.selectById(1) // let dataString = JSON.stringify(user) // let data = JSON.parse(dataString) // console.log(data[0].user_name) ctx.body = crypto.createHash('md5').update('123').digest('hex') // 对密码进行md5 数据库中保存的是md5后的密码 }) module.exports = router