fix: add collector role to API endpoints for mobile dashboard access

Collector users were blocked from ticket, payment, invoice, and client
endpoints requiring 'technician' role. Added 'collector' to @Roles
decorators and the COLLECTOR role to the shared role hierarchy.
This commit is contained in:
kevin-asprec
2026-05-06 02:15:20 +08:00
parent 83ad0cb8d5
commit c14521a41d
5 changed files with 15 additions and 13 deletions

View File

@@ -23,7 +23,7 @@ export class ClientController {
constructor(private readonly clientService: ClientService) {}
@Get()
@Roles('technician')
@Roles('technician', 'collector')
async findAll(
@CurrentUser() user: CurrentUserPayload,
@Query('areaId') areaId?: string,
@@ -36,7 +36,7 @@ export class ClientController {
}
@Get(':id')
@Roles('technician')
@Roles('technician', 'collector')
async findById(
@CurrentUser() user: CurrentUserPayload,
@Param('id') id: string,

View File

@@ -20,7 +20,7 @@ export class InvoiceController {
constructor(private readonly invoiceService: InvoiceService) {}
@Get()
@Roles('technician')
@Roles('technician', 'collector')
async findAll(
@CurrentUser() user: CurrentUserPayload,
@Query('clientId') clientId?: string,
@@ -30,7 +30,7 @@ export class InvoiceController {
}
@Get(':id')
@Roles('technician')
@Roles('technician', 'collector')
async findById(
@CurrentUser() user: CurrentUserPayload,
@Param('id') id: string,

View File

@@ -23,7 +23,7 @@ export class PaymentController {
constructor(private readonly paymentService: PaymentService) {}
@Get()
@Roles('technician')
@Roles('technician', 'collector')
async findAll(
@CurrentUser() user: CurrentUserPayload,
@Query('clientId') clientId?: string,
@@ -32,7 +32,7 @@ export class PaymentController {
}
@Post()
@Roles('technician')
@Roles('technician', 'collector')
async record(
@CurrentUser() user: CurrentUserPayload,
@Body() dto: RecordPaymentDto,
@@ -41,19 +41,19 @@ export class PaymentController {
}
@Get('unremitted')
@Roles('technician')
@Roles('technician', 'collector')
async getUnremitted(@CurrentUser() user: CurrentUserPayload, @Query('collectorId') collectorId?: string) {
return this.paymentService.getUnremittedPayments(user.tenantId, collectorId || user.sub);
}
@Get('remittances')
@Roles('technician')
@Roles('technician', 'collector')
async findRemittances(@CurrentUser() user: CurrentUserPayload) {
return this.paymentService.findRemittances(user.tenantId);
}
@Post('remittances')
@Roles('technician')
@Roles('technician', 'collector')
async submitRemittance(
@CurrentUser() user: CurrentUserPayload,
@Body() dto: CreateRemittanceDto,

View File

@@ -23,7 +23,7 @@ export class TicketController {
constructor(private readonly ticketService: TicketService) {}
@Get()
@Roles('technician')
@Roles('technician', 'collector')
async findAll(
@CurrentUser() user: CurrentUserPayload,
@Query('clientId') clientId?: string,
@@ -34,7 +34,7 @@ export class TicketController {
}
@Get(':id')
@Roles('technician')
@Roles('technician', 'collector')
async findById(
@CurrentUser() user: CurrentUserPayload,
@Param('id') id: string,
@@ -52,7 +52,7 @@ export class TicketController {
}
@Patch(':id')
@Roles('technician')
@Roles('technician', 'collector')
async update(
@CurrentUser() user: CurrentUserPayload,
@Param('id') id: string,
@@ -62,7 +62,7 @@ export class TicketController {
}
@Patch(':id/resolve')
@Roles('technician')
@Roles('technician', 'collector')
async resolve(
@CurrentUser() user: CurrentUserPayload,
@Param('id') id: string,