Files
tabungin/apps/api/dist/admin/admin-plans.service.js
dwindown 12850ab12d feat: complete admin backend controllers and services
- AdminPlansController & Service (CRUD, reorder)
- AdminPaymentMethodsController & Service (CRUD, reorder)
- AdminPaymentsController & Service (verify, reject, pending count)
- AdminUsersController & Service (search, suspend, grant pro access, stats)
- AdminConfigController & Service (dynamic config management)
- Wire all controllers into AdminModule
- Import AdminModule in AppModule

Admin API Routes:
- GET/POST/PUT/DELETE /admin/plans
- GET/POST/PUT/DELETE /admin/payment-methods
- GET /admin/payments (with status filter)
- POST /admin/payments/:id/verify
- POST /admin/payments/:id/reject
- GET /admin/users (with search)
- POST /admin/users/:id/grant-pro
- GET/POST/DELETE /admin/config

All routes protected by AuthGuard + AdminGuard
2025-10-11 14:32:45 +07:00

71 lines
2.5 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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdminPlansService = void 0;
const common_1 = require("@nestjs/common");
const prisma_service_1 = require("../prisma/prisma.service");
let AdminPlansService = class AdminPlansService {
prisma;
constructor(prisma) {
this.prisma = prisma;
}
async findAll() {
return this.prisma.plan.findMany({
orderBy: { sortOrder: 'asc' },
include: {
_count: {
select: { subscriptions: true },
},
},
});
}
async findOne(id) {
return this.prisma.plan.findUnique({
where: { id },
include: {
_count: {
select: { subscriptions: true },
},
},
});
}
async create(data) {
return this.prisma.plan.create({
data,
});
}
async update(id, data) {
return this.prisma.plan.update({
where: { id },
data,
});
}
async delete(id) {
return this.prisma.plan.update({
where: { id },
data: { isActive: false, isVisible: false },
});
}
async reorder(planIds) {
const updates = planIds.map((id, index) => this.prisma.plan.update({
where: { id },
data: { sortOrder: index + 1 },
}));
await this.prisma.$transaction(updates);
return { success: true };
}
};
exports.AdminPlansService = AdminPlansService;
exports.AdminPlansService = AdminPlansService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
], AdminPlansService);
//# sourceMappingURL=admin-plans.service.js.map