perf: 完善订单管理
This commit is contained in:
@@ -3,24 +3,28 @@ import {
|
||||
Get,
|
||||
Put,
|
||||
Body,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common'
|
||||
import { UserRole } from '@mp-pilates/shared'
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard'
|
||||
import { RolesGuard } from '../auth/roles.guard'
|
||||
import { Roles } from '../auth/roles.decorator'
|
||||
import { CurrentUser } from '../common/decorators/current-user.decorator'
|
||||
import { UserService } from './user.service'
|
||||
import { UpdateProfileDto } from './dto/update-profile.dto'
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Controller('user')
|
||||
@Controller()
|
||||
export class UserController {
|
||||
constructor(private readonly userService: UserService) {}
|
||||
|
||||
@Get('profile')
|
||||
@Get('user/profile')
|
||||
getProfile(@CurrentUser('sub') userId: string) {
|
||||
return this.userService.getProfile(userId)
|
||||
}
|
||||
|
||||
@Put('profile')
|
||||
@Put('user/profile')
|
||||
updateProfile(
|
||||
@CurrentUser('sub') userId: string,
|
||||
@Body() dto: UpdateProfileDto,
|
||||
@@ -28,8 +32,25 @@ export class UserController {
|
||||
return this.userService.updateProfile(userId, dto)
|
||||
}
|
||||
|
||||
@Get('stats')
|
||||
@Get('user/stats')
|
||||
getStats(@CurrentUser('sub') userId: string) {
|
||||
return this.userService.getStats(userId)
|
||||
}
|
||||
|
||||
// ─── Admin: Member Management ─────────────────────────────────────────────
|
||||
|
||||
@Get('admin/members')
|
||||
@UseGuards(RolesGuard)
|
||||
@Roles(UserRole.ADMIN)
|
||||
getMembers(
|
||||
@Query('page') page?: string,
|
||||
@Query('limit') limit?: string,
|
||||
@Query('search') search?: string,
|
||||
) {
|
||||
return this.userService.getMembers(
|
||||
page ? Number(page) : 1,
|
||||
limit ? Number(limit) : 20,
|
||||
search && search !== 'undefined' ? search : undefined,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user