template-saas/apps/backend/dist/modules/tenants/tenants.controller.js
rckrdmrd 50a821a415
Some checks failed
CI / Backend CI (push) Has been cancelled
CI / Frontend CI (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / CI Summary (push) Has been cancelled
[SIMCO-V38] feat: Actualizar a SIMCO v3.8.0
- HERENCIA-SIMCO.md actualizado con directivas v3.7 y v3.8
- Actualizaciones de configuracion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 08:53:08 -06:00

98 lines
5.1 KiB
JavaScript

"use strict";
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); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TenantsController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const tenants_service_1 = require("./tenants.service");
const dto_1 = require("./dto");
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
const permissions_guard_1 = require("../rbac/guards/permissions.guard");
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
const public_decorator_1 = require("../auth/decorators/public.decorator");
let TenantsController = class TenantsController {
constructor(tenantsService) {
this.tenantsService = tenantsService;
}
async create(createTenantDto) {
return this.tenantsService.create(createTenantDto);
}
async getCurrent(user) {
return this.tenantsService.findOne(user.tenant_id);
}
async updateCurrent(user, updateTenantDto) {
return this.tenantsService.update(user.tenant_id, updateTenantDto);
}
async findOne(id) {
return this.tenantsService.findOne(id);
}
};
exports.TenantsController = TenantsController;
__decorate([
(0, common_1.Post)(),
(0, public_decorator_1.Public)(),
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
(0, swagger_1.ApiOperation)({ summary: 'Create a new tenant' }),
(0, swagger_1.ApiBody)({ type: dto_1.CreateTenantDto }),
(0, swagger_1.ApiResponse)({ status: 201, description: 'Tenant created successfully' }),
(0, swagger_1.ApiResponse)({ status: 400, description: 'Invalid input data' }),
(0, swagger_1.ApiResponse)({ status: 409, description: 'Tenant with this slug already exists' }),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [dto_1.CreateTenantDto]),
__metadata("design:returntype", Promise)
], TenantsController.prototype, "create", null);
__decorate([
(0, common_1.Get)('current'),
(0, swagger_1.ApiOperation)({ summary: 'Get current user tenant' }),
(0, swagger_1.ApiResponse)({ status: 200, description: 'Returns the current tenant' }),
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
__param(0, (0, current_user_decorator_1.CurrentUser)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], TenantsController.prototype, "getCurrent", null);
__decorate([
(0, common_1.Patch)('current'),
(0, common_1.UseGuards)(permissions_guard_1.PermissionsGuard),
(0, permissions_guard_1.RequirePermissions)('tenants:write'),
(0, swagger_1.ApiOperation)({ summary: 'Update current tenant' }),
(0, swagger_1.ApiBody)({ type: dto_1.UpdateTenantDto }),
(0, swagger_1.ApiResponse)({ status: 200, description: 'Tenant updated successfully' }),
(0, swagger_1.ApiResponse)({ status: 403, description: 'Insufficient permissions' }),
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
__param(0, (0, current_user_decorator_1.CurrentUser)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, dto_1.UpdateTenantDto]),
__metadata("design:returntype", Promise)
], TenantsController.prototype, "updateCurrent", null);
__decorate([
(0, common_1.Get)(':id'),
(0, swagger_1.ApiOperation)({ summary: 'Get tenant by ID' }),
(0, swagger_1.ApiResponse)({ status: 200, description: 'Returns the tenant' }),
(0, swagger_1.ApiResponse)({ status: 404, description: 'Tenant not found' }),
__param(0, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], TenantsController.prototype, "findOne", null);
exports.TenantsController = TenantsController = __decorate([
(0, swagger_1.ApiTags)('tenants'),
(0, common_1.Controller)('tenants'),
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
(0, swagger_1.ApiBearerAuth)(),
__metadata("design:paramtypes", [tenants_service_1.TenantsService])
], TenantsController);
//# sourceMappingURL=tenants.controller.js.map