This commit is contained in:
2025-12-13 12:30:38 +03:30
parent 5d872db4ad
commit 9d9de98c03
13 changed files with 142 additions and 91 deletions
@@ -9,7 +9,6 @@ import { UserId } from 'src/common/decorators/user-id.decorator';
import { RestId } from 'src/common/decorators';
import { FindUsersDto } from '../dto/find-user.dto';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { ConvertScoreToWalletDto } from '../dto/convert-score-to-wallet.dto';
@ApiTags('User')
@Controller()
@@ -45,11 +44,8 @@ export class UsersController {
})
@ApiBody({ type: UpdateUserDto })
@Patch('public/user/update')
async updateUser(
@UserId() userId: string,
@Body(new ValidationPipe({ transform: true, whitelist: true })) dto: UpdateUserDto,
) {
const user = await this.userService.updateUser(userId, dto);
async updateUser(@UserId() userId: string, @RestId() restId: string, @Body() dto: UpdateUserDto) {
const user = await this.userService.updateUser(userId, restId, dto);
return user;
}
@@ -71,6 +67,23 @@ export class UsersController {
return addresses;
}
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Get User Wallet' })
@ApiHeader({
name: 'X-Slug',
required: true,
schema: {
type: 'string',
default: 'zhivan',
},
})
@Get('public/user/wallet')
async getUserWallet(@UserId() userId: string, @RestId() restId: string) {
const wallet = await this.userService.getUserWallet(userId, restId);
return wallet;
}
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Create a new address for the authenticated user' })
@@ -194,14 +207,10 @@ export class UsersController {
default: 'zhivan',
},
})
@ApiBody({ type: ConvertScoreToWalletDto })
@Post('public/user/convert-score-to-wallet')
async convertScoreToWallet(@UserId() userId: string, @Body() dto: ConvertScoreToWalletDto, @RestId() restId: string) {
const user = await this.userService.convertScoreToWallet(userId, restId, dto);
async convertScoreToWallet(@UserId() userId: string, @RestId() restId: string) {
await this.userService.convertScoreToWallet(userId, restId);
return {
id: user.id,
wallet: user.wallet,
points: user.points,
message: 'Score converted to wallet successfully',
};
}