67 lines
3.1 KiB
JavaScript
67 lines
3.1 KiB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
};
|
|
import { Body, Controller, Get, Inject, Param, ParseIntPipe, Post, Query, UseGuards, ValidationPipe } from '@nestjs/common';
|
|
import { ok } from '../common/api-response.js';
|
|
import { CurrentUser } from '../common/current-user.decorator.js';
|
|
import { JwtAuthGuard } from '../common/jwt-auth.guard.js';
|
|
import { RolesGuard } from '../common/roles.guard.js';
|
|
import { CreateObjectiveDto } from './dto/create-objective.dto.js';
|
|
import { ObjectivesService } from './objectives.service.js';
|
|
let ObjectivesController = class ObjectivesController {
|
|
objectivesService;
|
|
constructor(objectivesService) {
|
|
this.objectivesService = objectivesService;
|
|
}
|
|
async list(user, quarter) {
|
|
const objectives = await this.objectivesService.list(user, quarter);
|
|
return ok(objectives, { total: objectives.length });
|
|
}
|
|
async get(id, user) {
|
|
return ok(await this.objectivesService.getById(id, user));
|
|
}
|
|
async create(dto, user) {
|
|
return ok(await this.objectivesService.create(dto, user));
|
|
}
|
|
};
|
|
__decorate([
|
|
Get(),
|
|
__param(0, CurrentUser()),
|
|
__param(1, Query('quarter')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String]),
|
|
__metadata("design:returntype", Promise)
|
|
], ObjectivesController.prototype, "list", null);
|
|
__decorate([
|
|
Get(':id'),
|
|
__param(0, Param('id', ParseIntPipe)),
|
|
__param(1, CurrentUser()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Number, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], ObjectivesController.prototype, "get", null);
|
|
__decorate([
|
|
Post(),
|
|
__param(0, Body(new ValidationPipe({ expectedType: CreateObjectiveDto, whitelist: true, forbidNonWhitelisted: true, transform: true }))),
|
|
__param(1, CurrentUser()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [CreateObjectiveDto, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], ObjectivesController.prototype, "create", null);
|
|
ObjectivesController = __decorate([
|
|
Controller('objectives'),
|
|
UseGuards(JwtAuthGuard, RolesGuard),
|
|
__param(0, Inject(ObjectivesService)),
|
|
__metadata("design:paramtypes", [ObjectivesService])
|
|
], ObjectivesController);
|
|
export { ObjectivesController };
|