2025-08-21 15:24:40 +09:00
|
|
|
import { Controller, Get, Patch, Body, UseGuards, Req } from "@nestjs/common";
|
|
|
|
|
import { UsersService } from "./users.service";
|
|
|
|
|
import { JwtAuthGuard } from "../auth/guards/jwt-auth.guard";
|
|
|
|
|
import { ApiTags, ApiOperation } from "@nestjs/swagger";
|
2025-08-20 18:02:50 +09:00
|
|
|
|
2025-08-21 15:24:40 +09:00
|
|
|
@ApiTags("users")
|
|
|
|
|
@Controller("me")
|
2025-08-20 18:02:50 +09:00
|
|
|
@UseGuards(JwtAuthGuard)
|
|
|
|
|
export class UsersController {
|
|
|
|
|
constructor(private usersService: UsersService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
2025-08-21 15:24:40 +09:00
|
|
|
@ApiOperation({ summary: "Get current user profile" })
|
2025-08-20 18:02:50 +09:00
|
|
|
async getProfile(@Req() req: any) {
|
|
|
|
|
return this.usersService.findById(req.user.id);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-21 15:24:40 +09:00
|
|
|
@Get("summary")
|
|
|
|
|
@ApiOperation({ summary: "Get user dashboard summary" })
|
2025-08-20 18:02:50 +09:00
|
|
|
async getSummary(@Req() req: any) {
|
|
|
|
|
return this.usersService.getUserSummary(req.user.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch()
|
2025-08-21 15:24:40 +09:00
|
|
|
@ApiOperation({ summary: "Update user profile" })
|
2025-08-20 18:02:50 +09:00
|
|
|
async updateProfile(@Req() req: any, @Body() updateData: any) {
|
|
|
|
|
return this.usersService.update(req.user.id, updateData);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-21 15:24:40 +09:00
|
|
|
@Patch("billing")
|
|
|
|
|
@ApiOperation({ summary: "Update billing information" })
|
2025-08-20 18:02:50 +09:00
|
|
|
async updateBilling(@Req() req: any, @Body() billingData: any) {
|
|
|
|
|
// TODO: Sync to WHMCS custom fields
|
2025-08-21 15:24:40 +09:00
|
|
|
throw new Error("Not implemented");
|
2025-08-20 18:02:50 +09:00
|
|
|
}
|
|
|
|
|
}
|