feat(server): add auth, user, and studio modules
Auth: WeChat login, JWT, roles guard (24 tests passing) User: profile CRUD, training stats with month/total calculations Studio: config management with auto-default creation
This commit is contained in:
35
packages/server/src/user/user.controller.ts
Normal file
35
packages/server/src/user/user.controller.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Put,
|
||||
Body,
|
||||
UseGuards,
|
||||
} from '@nestjs/common'
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard'
|
||||
import { CurrentUser } from '../common/decorators/current-user.decorator'
|
||||
import { UserService } from './user.service'
|
||||
import { UpdateProfileDto } from './dto/update-profile.dto'
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('user')
|
||||
export class UserController {
|
||||
constructor(private readonly userService: UserService) {}
|
||||
|
||||
@Get('profile')
|
||||
getProfile(@CurrentUser('sub') userId: string) {
|
||||
return this.userService.getProfile(userId)
|
||||
}
|
||||
|
||||
@Put('profile')
|
||||
updateProfile(
|
||||
@CurrentUser('sub') userId: string,
|
||||
@Body() dto: UpdateProfileDto,
|
||||
) {
|
||||
return this.userService.updateProfile(userId, dto)
|
||||
}
|
||||
|
||||
@Get('stats')
|
||||
getStats(@CurrentUser('sub') userId: string) {
|
||||
return this.userService.getStats(userId)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user