登录用户信息完成

This commit is contained in:
2023-01-14 23:22:00 +08:00
parent 2a8ff1a3da
commit 0dfb2038d0
2 changed files with 28 additions and 13 deletions

View File

@@ -0,0 +1,18 @@
const Controller = require("egg").Controller
const table = "sys_user";
class User extends Controller {
async info() {
const {ctx, app} = this
if (!ctx.state.user?.id) {
this.ctx.body = {code: 1, msg: "找不到授权用户"}
return this.ctx.status = 401
}
const user = await app.mysql.get(table, {id: ctx.state.user?.id})
this.ctx.body = {code: 0, data: user}
this.ctx.status = 200
}
}
module.exports = User