feat: 支持会员管理筛选

This commit is contained in:
richarjiang
2026-04-07 09:22:58 +08:00
parent 58c7588a96
commit 0ca93ec97e
6 changed files with 129 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ import {
Query,
UseGuards,
} from '@nestjs/common'
import { UserRole } from '@mp-pilates/shared'
import { UserRole, CardTypeCategory } from '@mp-pilates/shared'
import { JwtAuthGuard } from '../auth/jwt-auth.guard'
import { RolesGuard } from '../auth/roles.guard'
import { Roles } from '../auth/roles.decorator'
@@ -14,6 +14,8 @@ import { CurrentUser } from '../common/decorators/current-user.decorator'
import { UserService } from './user.service'
import { UpdateProfileDto } from './dto/update-profile.dto'
const VALID_CARD_TYPES = new Set<string>(Object.values(CardTypeCategory))
@UseGuards(JwtAuthGuard)
@Controller()
export class UserController {
@@ -46,11 +48,17 @@ export class UserController {
@Query('page') page?: string,
@Query('limit') limit?: string,
@Query('search') search?: string,
@Query('cardType') cardType?: string,
) {
const validCardType =
cardType && cardType !== 'undefined' && (VALID_CARD_TYPES.has(cardType) || cardType === 'NONE')
? cardType
: undefined
return this.userService.getMembers(
page ? Number(page) : 1,
limit ? Number(limit) : 20,
search && search !== 'undefined' ? search : undefined,
validCardType,
)
}
}