登录用户信息完成
This commit is contained in:
18
server/app/controller/user.js
Normal file
18
server/app/controller/user.js
Normal 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
|
||||
Reference in New Issue
Block a user