Initial Mento CRM: portal OTP, reports, SMS, and deploy for crm.montzar.ir.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { CurrentUser } from '../auth/current-user.decorator';
|
||||
import {
|
||||
CreateSalesGoalDto,
|
||||
ForecastQueryDto,
|
||||
ListGoalsQueryDto,
|
||||
UpdateSalesGoalDto,
|
||||
} from './dto';
|
||||
import { SalesService } from './sales.service';
|
||||
|
||||
@Controller('sales')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class SalesController {
|
||||
constructor(private readonly salesService: SalesService) {}
|
||||
|
||||
@Get('forecast')
|
||||
forecast(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Query() query: ForecastQueryDto,
|
||||
) {
|
||||
return this.salesService.forecast(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
{ from: query.from, to: query.to, userId: query.userId },
|
||||
);
|
||||
}
|
||||
|
||||
@Get('goals')
|
||||
listGoals(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Query() query: ListGoalsQueryDto,
|
||||
) {
|
||||
return this.salesService.listGoals(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
{ from: query.from, to: query.to, userId: query.userId },
|
||||
);
|
||||
}
|
||||
|
||||
@Get('goals/:id')
|
||||
getGoal(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
return this.salesService.getGoal(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
id,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('goals')
|
||||
createGoal(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Body() dto: CreateSalesGoalDto,
|
||||
) {
|
||||
return this.salesService.createGoal(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
dto,
|
||||
);
|
||||
}
|
||||
|
||||
@Patch('goals/:id')
|
||||
updateGoal(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateSalesGoalDto,
|
||||
) {
|
||||
return this.salesService.updateGoal(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
id,
|
||||
dto,
|
||||
);
|
||||
}
|
||||
|
||||
@Delete('goals/:id')
|
||||
async removeGoal(
|
||||
@CurrentUser()
|
||||
user: { userId: string; organizationId: string; role: string },
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
await this.salesService.removeGoal(
|
||||
{
|
||||
userId: user.userId,
|
||||
organizationId: user.organizationId,
|
||||
role: user.role,
|
||||
},
|
||||
id,
|
||||
);
|
||||
return { ok: true };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user