crud product
This commit is contained in:
@@ -22,12 +22,12 @@ export class UsersController {
|
||||
constructor(
|
||||
private readonly userService: UserService,
|
||||
private readonly walletService: WalletService,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get the current authenticated user profile' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@Get('public/user/me')
|
||||
async getUser(@UserId() userId: string) {
|
||||
const user = await this.userService.findById(userId);
|
||||
@@ -36,10 +36,10 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Update the authenticated user profile' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiBody({ type: UpdateUserDto })
|
||||
@Patch('public/user/update')
|
||||
async updateUser(@UserId() userId: string, @RestId() restId: string, @Body() dto: UpdateUserDto) {
|
||||
async updateUser(@UserId() userId: string, , @Body() dto: UpdateUserDto) {
|
||||
const user = await this.userService.updateUser(userId, restId, dto);
|
||||
return user;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get all addresses for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiOkResponse({ description: 'List of user addresses' })
|
||||
@Get('public/user/addresses')
|
||||
async getUserAddresses(@UserId() userId: string) {
|
||||
@@ -58,9 +58,9 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get User Wallet' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@Get('public/user/wallet/balance')
|
||||
async getUserWalletBalance(@UserId() userId: string, @RestId() restId: string) {
|
||||
async getUserWalletBalance(@UserId() userId: string,) {
|
||||
const wallet = await this.walletService.getUserCurrentWalletBalance(userId, restId);
|
||||
return wallet;
|
||||
}
|
||||
@@ -68,9 +68,9 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get User Wallet' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@Get('public/user/points/balance')
|
||||
async getUserWallet(@UserId() userId: string, @RestId() restId: string) {
|
||||
async getUserWallet(@UserId() userId: string,) {
|
||||
const wallet = await this.walletService.getUserCurrentPoinrBalance(userId, restId);
|
||||
return wallet;
|
||||
}
|
||||
@@ -78,11 +78,11 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get User Wallet Transactions' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@Get('public/user/wallet/transactions')
|
||||
async getUserWalletTransactions(
|
||||
@UserId() userId: string,
|
||||
@RestId() restId: string,
|
||||
,
|
||||
@Query(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
query: FindWalletTransactionsDto,
|
||||
) {
|
||||
@@ -93,7 +93,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Create a new address for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiBody({ type: CreateUserAddressDto })
|
||||
@ApiOkResponse({ description: 'Created user address' })
|
||||
@Post('public/user/addresses')
|
||||
@@ -108,7 +108,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Get a single address by ID for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiOkResponse({ description: 'User address details' })
|
||||
@Get('public/user/addresses/:addressId')
|
||||
async getUserAddress(@UserId() userId: string, @Param('addressId') addressId: string) {
|
||||
@@ -119,7 +119,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Update an address for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiBody({ type: UpdateUserAddressDto })
|
||||
@ApiOkResponse({ description: 'Updated user address' })
|
||||
@Patch('public/user/addresses/:addressId')
|
||||
@@ -135,7 +135,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Delete an address for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiOkResponse({ description: 'Address deleted successfully' })
|
||||
@Delete('public/user/addresses/:addressId')
|
||||
async deleteUserAddress(@UserId() userId: string, @Param('addressId') addressId: string) {
|
||||
@@ -146,7 +146,7 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Set an address as default for the authenticated user' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@ApiOkResponse({ description: 'Address set as default' })
|
||||
@Patch('public/user/addresses/:addressId/default')
|
||||
async setDefaultAddress(@UserId() userId: string, @Param('addressId') addressId: string) {
|
||||
@@ -157,9 +157,9 @@ export class UsersController {
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Convert user score (points) to wallet balance' })
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
|
||||
@Post('public/user/convert-score-to-wallet')
|
||||
async convertScoreToWallet(@UserId() userId: string, @RestId() restId: string) {
|
||||
async convertScoreToWallet(@UserId() userId: string,) {
|
||||
await this.userService.convertScoreToWallet(userId, restId);
|
||||
return {
|
||||
message: UserSuccessMessage.SCORE_CONVERTED_SUCCESS,
|
||||
@@ -176,7 +176,7 @@ export class UsersController {
|
||||
async findAllRestaurantUsers(
|
||||
@Query(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
query: FindUsersDto,
|
||||
@RestId() restId: string,
|
||||
,
|
||||
) {
|
||||
return this.userService.findAll(restId, query);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user