You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

23 lines
560 B

import UserService from 'services/UserService.js';
import Router from 'utils/router.js';
class UserController {
static routes() {
let router = new Router({ prefix: '/api' });
router.get('/hello', UserController.hello);
router.get('/user/:id', UserController.getUser);
return router;
}
static async hello(ctx) {
ctx.body = 'Hello World';
}
static async getUser(ctx) {
// 调用 service 层获取用户
const user = await UserService.getUserById(ctx.params.id);
ctx.body = user;
}
}
export default UserController;