Files
ZYZ/gm-server/app/controller/login.ts
2020-12-15 16:02:59 +08:00

47 lines
1.1 KiB
TypeScript

import { Controller } from 'egg';
import { STATUS } from '@consts';
export default class LoginController extends Controller {
public async login() {
const { ctx } = this;
const {username, password} = ctx.request.body;
ctx.body = await ctx.service.gmUser.login(username, password);
}
public async currentUser() {
const { ctx } = this;
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, {
"user": ctx.user
});
}
public async changeMyPass() {
const { ctx } = this;
const {uid, password} = ctx.request.body;
ctx.body = await ctx.service.gmUser.changeMyPass(uid, password);
}
public async getMenu() {
const { ctx } = this;
ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, {
"list": [
{
path: '/test',
authority: ['admin'],
routes: [
{
path: '/test/create-role',
authority: ['admin'],
},
{
path: '/test/create-data',
authority: ['admin'],
}
],
}
]
});
}
}