Files
buy-lite/server/app/controller/menu.js
2023-01-28 18:08:41 +08:00

26 lines
618 B
JavaScript

const Controller = require("egg").Controller
const table = "sys_menu";
class User extends Controller {
async list() {
const {ctx} = this
const result = await this.service.db.list("sys_menu", ctx.query)
this.ctx.status = 200
this.ctx.body = result
}
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