mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 18:29:15 +03:00
make it better
This commit is contained in:
parent
92065a2ff5
commit
5510d9fbaf
55
build/.adonisrc.json
Normal file
55
build/.adonisrc.json
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"typescript": false,
|
||||
"commands": [
|
||||
"./commands",
|
||||
"@adonisjs/core/commands",
|
||||
"@adonisjs/repl/build/commands",
|
||||
"@adonisjs/lucid/build/commands",
|
||||
"@adonisjs/mail/build/commands",
|
||||
"@adonisjs/bouncer/build/commands"
|
||||
],
|
||||
"exceptionHandlerNamespace": "App/Exceptions/Handler",
|
||||
"namespaces": {
|
||||
"models": "App/Models",
|
||||
"middleware": "App/Middleware",
|
||||
"exceptions": "App/Exceptions",
|
||||
"validators": "App/Validators",
|
||||
"httpControllers": "App/Controllers/Http",
|
||||
"eventListeners": "App/Listeners",
|
||||
"redisListeners": "App/Listeners"
|
||||
},
|
||||
"aliases": {
|
||||
"App": "app",
|
||||
"Config": "config",
|
||||
"Database": "database",
|
||||
"Contracts": "contracts"
|
||||
},
|
||||
"preloads": [
|
||||
"./start/routes",
|
||||
"./start/kernel",
|
||||
"./start/event",
|
||||
"./start/bouncer"
|
||||
],
|
||||
"providers": [
|
||||
"./providers/AppProvider",
|
||||
"@adonisjs/core",
|
||||
"@adonisjs/lucid",
|
||||
"@adonisjs/auth",
|
||||
"@adonisjs/redis",
|
||||
"@adonisjs/mail",
|
||||
"@adonisjs/view",
|
||||
"@adonisjs/attachment-lite",
|
||||
"@adonisjs/bouncer",
|
||||
"@adonisjs/drive-s3"
|
||||
],
|
||||
"aceProviders": [
|
||||
"@adonisjs/repl"
|
||||
],
|
||||
"metaFiles": [
|
||||
{
|
||||
"pattern": "resources/views/**/*.edge",
|
||||
"reloadServer": false
|
||||
}
|
||||
],
|
||||
"lastCompiledAt": "2022-06-12T19:05:07.347Z"
|
||||
}
|
||||
16
build/ace
Normal file
16
build/ace
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Ace Commands
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is the entry point for running ace commands.
|
||||
|
|
||||
*/
|
||||
|
||||
require('reflect-metadata')
|
||||
require('source-map-support').install({ handleUncaughtExceptions: false })
|
||||
|
||||
const { Ignitor } = require('@adonisjs/core/build/standalone')
|
||||
new Ignitor(__dirname)
|
||||
.ace()
|
||||
.handle(process.argv.slice(2))
|
||||
573
build/ace-manifest.json
Normal file
573
build/ace-manifest.json
Normal file
@ -0,0 +1,573 @@
|
||||
{
|
||||
"commands": {
|
||||
"dump:rcfile": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/core/build/commands/DumpRc",
|
||||
"commandName": "dump:rcfile",
|
||||
"description": "Dump contents of .adonisrc.json file along with defaults",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": []
|
||||
},
|
||||
"list:routes": {
|
||||
"settings": {
|
||||
"loadApp": true,
|
||||
"stayAlive": true
|
||||
},
|
||||
"commandPath": "@adonisjs/core/build/commands/ListRoutes/index",
|
||||
"commandName": "list:routes",
|
||||
"description": "List application routes",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "verbose",
|
||||
"propertyName": "verbose",
|
||||
"type": "boolean",
|
||||
"description": "Display more information"
|
||||
},
|
||||
{
|
||||
"name": "reverse",
|
||||
"propertyName": "reverse",
|
||||
"type": "boolean",
|
||||
"alias": "r",
|
||||
"description": "Reverse routes display"
|
||||
},
|
||||
{
|
||||
"name": "methods",
|
||||
"propertyName": "methodsFilter",
|
||||
"type": "array",
|
||||
"alias": "m",
|
||||
"description": "Filter routes by method"
|
||||
},
|
||||
{
|
||||
"name": "patterns",
|
||||
"propertyName": "patternsFilter",
|
||||
"type": "array",
|
||||
"alias": "p",
|
||||
"description": "Filter routes by the route pattern"
|
||||
},
|
||||
{
|
||||
"name": "names",
|
||||
"propertyName": "namesFilter",
|
||||
"type": "array",
|
||||
"alias": "n",
|
||||
"description": "Filter routes by route name"
|
||||
},
|
||||
{
|
||||
"name": "json",
|
||||
"propertyName": "json",
|
||||
"type": "boolean",
|
||||
"description": "Output as JSON"
|
||||
},
|
||||
{
|
||||
"name": "table",
|
||||
"propertyName": "table",
|
||||
"type": "boolean",
|
||||
"description": "Output as Table"
|
||||
},
|
||||
{
|
||||
"name": "max-width",
|
||||
"propertyName": "maxWidth",
|
||||
"type": "number",
|
||||
"description": "Specify maximum rendering width. Ignored for JSON Output"
|
||||
}
|
||||
]
|
||||
},
|
||||
"generate:key": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/core/build/commands/GenerateKey",
|
||||
"commandName": "generate:key",
|
||||
"description": "Generate a new APP_KEY secret",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": []
|
||||
},
|
||||
"repl": {
|
||||
"settings": {
|
||||
"loadApp": true,
|
||||
"environment": "repl",
|
||||
"stayAlive": true
|
||||
},
|
||||
"commandPath": "@adonisjs/repl/build/commands/AdonisRepl",
|
||||
"commandName": "repl",
|
||||
"description": "Start a new REPL session",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": []
|
||||
},
|
||||
"db:seed": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/DbSeed",
|
||||
"commandName": "db:seed",
|
||||
"description": "Execute database seeders",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection for the seeders",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "interactive",
|
||||
"propertyName": "interactive",
|
||||
"type": "boolean",
|
||||
"description": "Run seeders in interactive mode",
|
||||
"alias": "i"
|
||||
},
|
||||
{
|
||||
"name": "files",
|
||||
"propertyName": "files",
|
||||
"type": "array",
|
||||
"description": "Define a custom set of seeders files names to run",
|
||||
"alias": "f"
|
||||
},
|
||||
{
|
||||
"name": "compact-output",
|
||||
"propertyName": "compactOutput",
|
||||
"type": "boolean",
|
||||
"description": "A compact single-line output"
|
||||
}
|
||||
]
|
||||
},
|
||||
"make:model": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/MakeModel",
|
||||
"commandName": "make:model",
|
||||
"description": "Make a new Lucid model",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "name",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"description": "Name of the model class"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "migration",
|
||||
"propertyName": "migration",
|
||||
"type": "boolean",
|
||||
"alias": "m",
|
||||
"description": "Generate the migration for the model"
|
||||
},
|
||||
{
|
||||
"name": "controller",
|
||||
"propertyName": "controller",
|
||||
"type": "boolean",
|
||||
"alias": "c",
|
||||
"description": "Generate the controller for the model"
|
||||
},
|
||||
{
|
||||
"name": "factory",
|
||||
"propertyName": "factory",
|
||||
"type": "boolean",
|
||||
"alias": "f",
|
||||
"description": "Generate a factory for the model"
|
||||
}
|
||||
]
|
||||
},
|
||||
"make:migration": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/MakeMigration",
|
||||
"commandName": "make:migration",
|
||||
"description": "Make a new migration file",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "name",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"description": "Name of the migration file"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "The connection flag is used to lookup the directory for the migration file"
|
||||
},
|
||||
{
|
||||
"name": "folder",
|
||||
"propertyName": "folder",
|
||||
"type": "string",
|
||||
"description": "Pre-select a migration directory"
|
||||
},
|
||||
{
|
||||
"name": "create",
|
||||
"propertyName": "create",
|
||||
"type": "string",
|
||||
"description": "Define the table name for creating a new table"
|
||||
},
|
||||
{
|
||||
"name": "table",
|
||||
"propertyName": "table",
|
||||
"type": "string",
|
||||
"description": "Define the table name for altering an existing table"
|
||||
}
|
||||
]
|
||||
},
|
||||
"make:seeder": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/MakeSeeder",
|
||||
"commandName": "make:seeder",
|
||||
"description": "Make a new Seeder file",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "name",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"description": "Name of the seeder class"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": []
|
||||
},
|
||||
"make:factory": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/MakeFactory",
|
||||
"commandName": "make:factory",
|
||||
"description": "Make a new factory",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "model",
|
||||
"name": "model",
|
||||
"required": true,
|
||||
"description": "The name of the model"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "model-path",
|
||||
"propertyName": "modelPath",
|
||||
"type": "string",
|
||||
"description": "The path to the model"
|
||||
},
|
||||
{
|
||||
"name": "exact",
|
||||
"propertyName": "exact",
|
||||
"type": "boolean",
|
||||
"description": "Create the factory with the exact name as provided",
|
||||
"alias": "e"
|
||||
}
|
||||
]
|
||||
},
|
||||
"db:wipe": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/DbWipe",
|
||||
"commandName": "db:wipe",
|
||||
"description": "Drop all tables, views and types in database",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "drop-views",
|
||||
"propertyName": "dropViews",
|
||||
"type": "boolean",
|
||||
"description": "Drop all views"
|
||||
},
|
||||
{
|
||||
"name": "drop-types",
|
||||
"propertyName": "dropTypes",
|
||||
"type": "boolean",
|
||||
"description": "Drop all custom types (Postgres only)"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explicitly force command to run in production"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:run": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Run",
|
||||
"commandName": "migration:run",
|
||||
"description": "Migrate database by running pending migrations",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explicitly force to run migrations in production"
|
||||
},
|
||||
{
|
||||
"name": "dry-run",
|
||||
"propertyName": "dryRun",
|
||||
"type": "boolean",
|
||||
"description": "Do not run actual queries. Instead view the SQL output"
|
||||
},
|
||||
{
|
||||
"name": "compact-output",
|
||||
"propertyName": "compactOutput",
|
||||
"type": "boolean",
|
||||
"description": "A compact single-line output"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:rollback": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Rollback",
|
||||
"commandName": "migration:rollback",
|
||||
"description": "Rollback migrations to a specific batch number",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explictly force to run migrations in production"
|
||||
},
|
||||
{
|
||||
"name": "dry-run",
|
||||
"propertyName": "dryRun",
|
||||
"type": "boolean",
|
||||
"description": "Do not run actual queries. Instead view the SQL output"
|
||||
},
|
||||
{
|
||||
"name": "batch",
|
||||
"propertyName": "batch",
|
||||
"type": "number",
|
||||
"description": "Define custom batch number for rollback. Use 0 to rollback to initial state"
|
||||
},
|
||||
{
|
||||
"name": "compact-output",
|
||||
"propertyName": "compactOutput",
|
||||
"type": "boolean",
|
||||
"description": "A compact single-line output"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:status": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Status",
|
||||
"commandName": "migration:status",
|
||||
"description": "View migrations status",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:reset": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Reset",
|
||||
"commandName": "migration:reset",
|
||||
"description": "Rollback all migrations",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explicitly force command to run in production"
|
||||
},
|
||||
{
|
||||
"name": "dry-run",
|
||||
"propertyName": "dryRun",
|
||||
"type": "boolean",
|
||||
"description": "Do not run actual queries. Instead view the SQL output"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:refresh": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Refresh",
|
||||
"commandName": "migration:refresh",
|
||||
"description": "Rollback and migrate database",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explicitly force command to run in production"
|
||||
},
|
||||
{
|
||||
"name": "dry-run",
|
||||
"propertyName": "dryRun",
|
||||
"type": "boolean",
|
||||
"description": "Do not run actual queries. Instead view the SQL output"
|
||||
},
|
||||
{
|
||||
"name": "seed",
|
||||
"propertyName": "seed",
|
||||
"type": "boolean",
|
||||
"description": "Run seeders"
|
||||
}
|
||||
]
|
||||
},
|
||||
"migration:fresh": {
|
||||
"settings": {
|
||||
"loadApp": true
|
||||
},
|
||||
"commandPath": "@adonisjs/lucid/build/commands/Migration/Fresh",
|
||||
"commandName": "migration:fresh",
|
||||
"description": "Drop all tables and re-migrate the database",
|
||||
"args": [],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "connection",
|
||||
"propertyName": "connection",
|
||||
"type": "string",
|
||||
"description": "Define a custom database connection",
|
||||
"alias": "c"
|
||||
},
|
||||
{
|
||||
"name": "force",
|
||||
"propertyName": "force",
|
||||
"type": "boolean",
|
||||
"description": "Explicitly force command to run in production"
|
||||
},
|
||||
{
|
||||
"name": "seed",
|
||||
"propertyName": "seed",
|
||||
"type": "boolean",
|
||||
"description": "Run seeders"
|
||||
},
|
||||
{
|
||||
"name": "drop-views",
|
||||
"propertyName": "dropViews",
|
||||
"type": "boolean",
|
||||
"description": "Drop all views"
|
||||
},
|
||||
{
|
||||
"name": "drop-types",
|
||||
"propertyName": "dropTypes",
|
||||
"type": "boolean",
|
||||
"description": "Drop all custom types (Postgres only)"
|
||||
}
|
||||
]
|
||||
},
|
||||
"make:mailer": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/mail/build/commands/MakeMailer",
|
||||
"commandName": "make:mailer",
|
||||
"description": "Make a new mailer class",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "name",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"description": "Name of the mailer class"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": []
|
||||
},
|
||||
"make:policy": {
|
||||
"settings": {},
|
||||
"commandPath": "@adonisjs/bouncer/build/commands/MakePolicy",
|
||||
"commandName": "make:policy",
|
||||
"description": "Make a new bouncer policy",
|
||||
"args": [
|
||||
{
|
||||
"type": "string",
|
||||
"propertyName": "name",
|
||||
"name": "name",
|
||||
"required": true,
|
||||
"description": "Name of the policy to create"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"flags": [
|
||||
{
|
||||
"name": "resource-model",
|
||||
"propertyName": "resourceModel",
|
||||
"type": "string",
|
||||
"description": "Name of the resource model to authorize"
|
||||
},
|
||||
{
|
||||
"name": "user-model",
|
||||
"propertyName": "userModel",
|
||||
"type": "string",
|
||||
"description": "Name of the user model to be authorized"
|
||||
},
|
||||
{
|
||||
"name": "actions",
|
||||
"propertyName": "actions",
|
||||
"type": "array",
|
||||
"description": "Actions to implement"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"aliases": {}
|
||||
}
|
||||
52
build/app/Controllers/Http/Api/v1/AuthController.js
Normal file
52
build/app/Controllers/Http/Api/v1/AuthController.js
Normal file
@ -0,0 +1,52 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const AuthService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/AuthService"));
|
||||
const AuthValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Auth/AuthValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let AuthController = class AuthController extends BaseController_1.default {
|
||||
constructor(authService) {
|
||||
super();
|
||||
Object.defineProperty(this, "authService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.authService = authService;
|
||||
}
|
||||
async login(ctx) {
|
||||
const payload = await ctx.request.validate(AuthValidator_1.default);
|
||||
const result = await this.authService.login(payload.login, payload.password, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async logout(ctx) {
|
||||
const result = await this.authService.logout(ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
AuthController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [AuthService_1.default])
|
||||
], AuthController);
|
||||
exports.default = AuthController;
|
||||
new standalone_1.Ioc().make(AuthController);
|
||||
//# sourceMappingURL=AuthController.js.map
|
||||
1
build/app/Controllers/Http/Api/v1/AuthController.js.map
Normal file
1
build/app/Controllers/Http/Api/v1/AuthController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"AuthController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/AuthController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gEAAyE;AACzE,iGAAmD;AAKnD,4GAA8D;AAK9D,0EAAkD;AAGlD,IAAqB,cAAc,GAAnC,MAAqB,cAAe,SAAQ,wBAAc;IAGxD,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QAHV;;;;;WAAiC;QAI/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAOM,KAAK,CAAC,KAAK,CAAC,GAAwB;QACzC,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,uBAAa,CAAC,CAAC;QAC1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAElF,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAOM,KAAK,CAAC,MAAM,CAAC,GAAwB;QAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAElD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAtCoB,cAAc;IADlC,IAAA,mBAAM,GAAE;qCAIkB,qBAAW;GAHjB,cAAc,CAsClC;kBAtCoB,cAAc;AAwCnC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC"}
|
||||
75
build/app/Controllers/Http/Api/v1/CategoriesController.js
Normal file
75
build/app/Controllers/Http/Api/v1/CategoriesController.js
Normal file
@ -0,0 +1,75 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const CategoryService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/CategoryService"));
|
||||
const CreateCategoryValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Category/CreateCategoryValidator"));
|
||||
const UpdateCategoryValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Category/UpdateCategoryValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let CategoriesController = class CategoriesController extends BaseController_1.default {
|
||||
constructor(categoryService) {
|
||||
super();
|
||||
Object.defineProperty(this, "categoryService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.categoryService = categoryService;
|
||||
}
|
||||
async list(ctx) {
|
||||
const result = await this.categoryService.fetchCategories();
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.categoryService.fetchCategory(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async create(ctx) {
|
||||
const payload = await ctx.request.validate(CreateCategoryValidator_1.default);
|
||||
const result = await this.categoryService.createCategory(payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async delete(ctx) {
|
||||
const result = await this.categoryService.deleteCategory(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async update(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateCategoryValidator_1.default);
|
||||
const result = await this.categoryService.updateCategory(ctx.params.id, payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
CategoriesController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [CategoryService_1.default])
|
||||
], CategoriesController);
|
||||
exports.default = CategoriesController;
|
||||
new standalone_1.Ioc().make(CategoriesController);
|
||||
//# sourceMappingURL=CategoriesController.js.map
|
||||
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CategoriesController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/CategoriesController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gEAAyE;AAKzE,yGAA2D;AAK3D,oIAAsF;AACtF,oIAAsF;AAEtF,0EAAkD;AAGlD,IAAqB,oBAAoB,GAAzC,MAAqB,oBAAqB,SAAQ,wBAAc;IAG9D,YAAY,eAAgC;QAC1C,KAAK,EAAE,CAAC;QAHV;;;;;WAAyC;QAIvC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAMM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC;QAE5D,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAMM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC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AE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAMM,KAAK,CAAC,MAAM,CAAC,GAAwB;QAC1C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,iCAAuB,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AA/EoB,oBAAoB;IADxC,IAAA,mBAAM,GAAE;qCAIsB,yBAAe;GAHzB,oBAAoB,CA+ExC;kBA/EoB,oBAAoB;AAiFzC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC"}
|
||||
34
build/app/Controllers/Http/Api/v1/ChatController.js
Normal file
34
build/app/Controllers/Http/Api/v1/ChatController.js
Normal file
@ -0,0 +1,34 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const HttpStatusEnum_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Datatypes/Enums/HttpStatusEnum"));
|
||||
const WsService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/WsService"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let ChatController = class ChatController extends BaseController_1.default {
|
||||
async getConversations(ctx) {
|
||||
const user = await ctx.auth.authenticate();
|
||||
const data = await WsService_1.default.messageStore.getConversations(user.id);
|
||||
const result = {
|
||||
success: true,
|
||||
status: HttpStatusEnum_1.default.OK,
|
||||
message: 'Fetched conversations.',
|
||||
data,
|
||||
};
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
ChatController = __decorate([
|
||||
(0, standalone_1.inject)()
|
||||
], ChatController);
|
||||
exports.default = ChatController;
|
||||
new standalone_1.Ioc().make(ChatController);
|
||||
//# sourceMappingURL=ChatController.js.map
|
||||
1
build/app/Controllers/Http/Api/v1/ChatController.js.map
Normal file
1
build/app/Controllers/Http/Api/v1/ChatController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ChatController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/ChatController.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gEAA8D;AAQ9D,8GAAgE;AAKhE,6FAA+C;AAE/C,0EAAkD;AAGlD,IAAqB,cAAc,GAAnC,MAAqB,cAAe,SAAQ,wBAAc;IAKjD,KAAK,CAAC,gBAAgB,CAAC,GAAwB;QACpD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,mBAAS,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,MAAM,MAAM,GAAkC;YAC5C,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,wBAAc,CAAC,EAAE;YACzB,OAAO,EAAE,wBAAwB;YACjC,IAAI;SACL,CAAC;QAEF,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAjBoB,cAAc;IADlC,IAAA,mBAAM,GAAE;GACY,cAAc,CAiBlC;kBAjBoB,cAAc;AAmBnC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC"}
|
||||
178
build/app/Controllers/Http/Api/v1/CoursesController.js
Normal file
178
build/app/Controllers/Http/Api/v1/CoursesController.js
Normal file
@ -0,0 +1,178 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const CourseService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/CourseService"));
|
||||
const AddCourseToUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/AddCourseToUserValidator"));
|
||||
const AttachStudentsValitator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/AttachStudentsValitator"));
|
||||
const DetachStudentstValitator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/DetachStudentstValitator"));
|
||||
const CreateCourseValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/CreateCourseValidator"));
|
||||
const DelCourseFromUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/DelCourseFromUserValidator"));
|
||||
const SetCourseStatusValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/SetCourseStatusValidator"));
|
||||
const UpdateCourseValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/UpdateCourseValidator"));
|
||||
const FetchCoursesValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Course/FetchCoursesValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let CoursesController = class CoursesController extends BaseController_1.default {
|
||||
constructor(courseService) {
|
||||
super();
|
||||
Object.defineProperty(this, "courseService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.courseService = courseService;
|
||||
}
|
||||
async list(ctx) {
|
||||
const payload = await ctx.request.validate(FetchCoursesValidator_1.default);
|
||||
const result = await this.courseService.fetchCourses(payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.courseService.fetchCourse(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async showTeacher(ctx) {
|
||||
const result = await this.courseService.fetchCourseTeacher(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async showCategory(ctx) {
|
||||
const result = await this.courseService.fetchCourseCategory(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async showLessons(ctx) {
|
||||
const result = await this.courseService.fetchCourseLessons(ctx.params.id, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async showStudents(ctx) {
|
||||
const result = await this.courseService.fetchCourseStudents(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async create(ctx) {
|
||||
const payload = await ctx.request.validate(CreateCourseValidator_1.default);
|
||||
const result = await this.courseService.createCourse(payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async delete(ctx) {
|
||||
const result = await this.courseService.deleteCourse(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async update(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateCourseValidator_1.default);
|
||||
const result = await this.courseService.updateCourse(ctx.params.id, payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async attachStudent(ctx) {
|
||||
const payload = await ctx.request.validate(AddCourseToUserValidator_1.default);
|
||||
const result = await this.courseService.attachUserCourse(ctx.params.id, payload.student_id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async attachStudentList(ctx) {
|
||||
const payload = await ctx.request.validate(AttachStudentsValitator_1.default);
|
||||
const result = await this.courseService.attachStudentList(ctx.params.id, payload.students);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async detachStudent(ctx) {
|
||||
const payload = await ctx.request.validate(DelCourseFromUserValidator_1.default);
|
||||
const result = await this.courseService.detachUserCourse(ctx.params.id, payload.student_id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async detachStudentList(ctx) {
|
||||
const payload = await ctx.request.validate(DetachStudentstValitator_1.default);
|
||||
const result = await this.courseService.detachStudentList(ctx.params.id, payload.students);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async studentsCount(ctx) {
|
||||
const result = await this.courseService.fetchStudentsCount(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async showLikes(ctx) {
|
||||
const result = await this.courseService.fetchCourseLikesCount(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async setLike(ctx) {
|
||||
const result = await this.courseService.attachUserLike(ctx.params.id, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async unsetLike(ctx) {
|
||||
const result = await this.courseService.detachUserLike(ctx.params.id, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async setStatus(ctx) {
|
||||
const payload = await ctx.request.validate(SetCourseStatusValidator_1.default);
|
||||
const result = await this.courseService.setCourseStatus(ctx.params.id, payload.status);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
CoursesController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [CourseService_1.default])
|
||||
], CoursesController);
|
||||
exports.default = CoursesController;
|
||||
new standalone_1.Ioc().make(CoursesController);
|
||||
//# sourceMappingURL=CoursesController.js.map
|
||||
File diff suppressed because one or more lines are too long
66
build/app/Controllers/Http/Api/v1/ImagesController.js
Normal file
66
build/app/Controllers/Http/Api/v1/ImagesController.js
Normal file
@ -0,0 +1,66 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const ImageService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/ImageService"));
|
||||
const CreateImageValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Image/CreateImageValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let ImagesController = class ImagesController extends BaseController_1.default {
|
||||
constructor(imageService) {
|
||||
super();
|
||||
Object.defineProperty(this, "imageService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.imageService = imageService;
|
||||
}
|
||||
async list(ctx) {
|
||||
const result = await this.imageService.fetchImages();
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.imageService.fetchImage(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async create(ctx) {
|
||||
const payload = await ctx.request.validate(CreateImageValidator_1.default);
|
||||
const result = await this.imageService.createImage(payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async delete(ctx) {
|
||||
const result = await this.imageService.deleteImage(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
ImagesController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [ImageService_1.default])
|
||||
], ImagesController);
|
||||
exports.default = ImagesController;
|
||||
new standalone_1.Ioc().make(ImagesController);
|
||||
//# sourceMappingURL=ImagesController.js.map
|
||||
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ImagesController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/ImagesController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAEzE,mGAAqD;AACrD,2HAA6E;AAC7E,0EAAkD;AAGlD,IAAqB,gBAAgB,GAArC,MAAqB,gBAAiB,SAAQ,wBAAc;IAG1D,YAAY,YAA0B;QACpC,KAAK,EAAE,CAAC;QAHV;;;;;WAAmC;QAIjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;QAErD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CA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C,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAElE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAhDoB,gBAAgB;IADpC,IAAA,mBAAM,GAAE;qCAImB,sBAAY;GAHnB,gBAAgB,CAgDpC;kBAhDoB,gBAAgB;AAkDrC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC"}
|
||||
113
build/app/Controllers/Http/Api/v1/LessonsController.js
Normal file
113
build/app/Controllers/Http/Api/v1/LessonsController.js
Normal file
@ -0,0 +1,113 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const Validator_1 = global[Symbol.for('ioc.use')]("Adonis/Core/Validator");
|
||||
const LessonService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/LessonService"));
|
||||
const LessonMaterial_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/LessonMaterial"));
|
||||
const CreateLessonValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Lesson/CreateLessonValidator"));
|
||||
const UpdateLessonValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Lesson/UpdateLessonValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let LessonsController = class LessonsController extends BaseController_1.default {
|
||||
constructor(lessonService) {
|
||||
super();
|
||||
Object.defineProperty(this, "lessonService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.lessonService = lessonService;
|
||||
}
|
||||
async list(ctx) {
|
||||
const result = await this.lessonService.fetchLessons();
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.lessonService.fetchLesson(ctx.params.id, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async create(ctx) {
|
||||
const payload = await ctx.request.validate(CreateLessonValidator_1.default);
|
||||
const result = await this.lessonService.createLesson(payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async delete(ctx) {
|
||||
const result = await this.lessonService.deleteLesson(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async update(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateLessonValidator_1.default);
|
||||
const result = await this.lessonService.updateLesson(ctx.params.id, payload);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async getContent(ctx) {
|
||||
const result = await this.lessonService.fetchLessonContent(ctx.params.id, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async getMaterial(ctx) {
|
||||
const { fileName } = ctx.request.params();
|
||||
const { data, message, status, success, error } = await this.lessonService.fetchMaterialFile(ctx, fileName);
|
||||
if (!success && error) {
|
||||
throw new standalone_1.Exception(message, status, error.code);
|
||||
}
|
||||
if (data instanceof LessonMaterial_1.default) {
|
||||
return this.sendFileFromDrive(`materials/${data.name}`, ctx);
|
||||
}
|
||||
return this.sendResponse(ctx, data, message, status);
|
||||
}
|
||||
async saveOrder(ctx) {
|
||||
const saveOrderSchema = Validator_1.schema.create({
|
||||
ids: Validator_1.schema.array([Validator_1.rules.minLength(1)]).members(Validator_1.schema.string()),
|
||||
});
|
||||
const payload = await ctx.request.validate({ schema: saveOrderSchema });
|
||||
const { data, message, status, success, error } = await this.lessonService.updateOrder(payload.ids);
|
||||
if (!success && error) {
|
||||
throw new standalone_1.Exception(message, status, error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, data, message, status);
|
||||
}
|
||||
async getVideoProgress(ctx) {
|
||||
const { data, message, status, success, error } = await this.lessonService.fetchLessonProgress(ctx.params.id, ctx);
|
||||
if (!success && error) {
|
||||
throw new standalone_1.Exception(message, status, error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, data, message, status);
|
||||
}
|
||||
};
|
||||
LessonsController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [LessonService_1.default])
|
||||
], LessonsController);
|
||||
exports.default = LessonsController;
|
||||
new standalone_1.Ioc().make(LessonsController);
|
||||
//# sourceMappingURL=LessonsController.js.map
|
||||
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonsController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/LessonsController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAEzE,2EAA2D;AAK3D,qGAAuD;AAKvD,qGAAuD;AAKvD,8HAAgF;AAChF,8HAAgF;AAEhF,0EAAkD;AAGlD,IAAqB,iBAAiB,GAAtC,MAAqB,iBAAkB,SAAQ,wBAAc;IAG3D,YAAY,aAA4B;QACtC,KAAK,EAAE,CAAC;QAHV;;;;;WAAqC;QAInC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAMM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;QAEvD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;IAMM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAExE,IAAI,CAA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AAI,CAAC,CAAC;SAClD;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAMM,KAAK,CAAC,gBAAgB,CAAC,GAAwB;QACpD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAEnH,IAAI,CAAC,OAAO,IAAI,KAAK,EAAE;YACrB,MAAM,IAAI,sBAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;SAClD;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AAjJoB,iBAAiB;IADrC,IAAA,mBAAM,GAAE;qCAIoB,uBAAa;GAHrB,iBAAiB,CAiJrC;kBAjJoB,iBAAiB;AAmJtC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC"}
|
||||
105
build/app/Controllers/Http/Api/v1/MeController.js
Normal file
105
build/app/Controllers/Http/Api/v1/MeController.js
Normal file
@ -0,0 +1,105 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const Validator_1 = global[Symbol.for('ioc.use')]("Adonis/Core/Validator");
|
||||
const MeService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/MeService"));
|
||||
const ChangePasswordValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Password/ChangePasswordValidator"));
|
||||
const UpdateContactsValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/Contacts/UpdateContactsValidator"));
|
||||
const UpdateUserInfoValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/User/UpdateUserInfoValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let MeController = class MeController extends BaseController_1.default {
|
||||
constructor(meService) {
|
||||
super();
|
||||
Object.defineProperty(this, "meService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.meService = meService;
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.meService.fetchUserData(ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async changePassword(ctx) {
|
||||
const payload = await ctx.request.validate(ChangePasswordValidator_1.default);
|
||||
const result = await this.meService.changeUserPassword(payload.oldPassword, payload.newPassword, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async changeEmail(ctx) {
|
||||
const payload = await ctx.request.validate({
|
||||
schema: Validator_1.schema.create({
|
||||
email: Validator_1.schema.string({}, [Validator_1.rules.email(), Validator_1.rules.unique({ table: 'users', column: 'email' })]),
|
||||
}),
|
||||
messages: {
|
||||
'email.unique': 'Email is not available.',
|
||||
},
|
||||
});
|
||||
const result = await MeService_1.default.changeUserEmail(payload.email);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async changeEmailConfirm(ctx) {
|
||||
const confirmChangeEmailSchema = Validator_1.schema.create({
|
||||
email: Validator_1.schema.string({}, [Validator_1.rules.email(), Validator_1.rules.unique({ table: 'users', column: 'email' })]),
|
||||
confirmationCode: Validator_1.schema.number(),
|
||||
});
|
||||
const payload = await ctx.request.validate({ schema: confirmChangeEmailSchema });
|
||||
const result = await MeService_1.default.changeUserEmailConfirm(ctx, payload.email, payload.confirmationCode);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async updateContacts(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateContactsValidator_1.default);
|
||||
const result = await this.meService.updateUserContacts(payload, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async updateInfo(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateUserInfoValidator_1.default);
|
||||
const result = await this.meService.updateUserInfo(payload, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async chatHistory(ctx) {
|
||||
const result = await this.meService.fetchChatHistory(ctx.params.chat_id, ctx.auth);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
MeController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [MeService_1.default])
|
||||
], MeController);
|
||||
exports.default = MeController;
|
||||
new standalone_1.Ioc().make(MeController);
|
||||
//# sourceMappingURL=MeController.js.map
|
||||
1
build/app/Controllers/Http/Api/v1/MeController.js.map
Normal file
1
build/app/Controllers/Http/Api/v1/MeController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"MeController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/MeController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAEzE,2EAA2D;AAK3D,6FAA+C;AAK/C,oIAAsF;AACtF,oIAAsF;AACtF,gIAAkF;AAElF,0EAAkD;AAGlD,IAAqB,YAAY,GAAjC,MAAqB,YAAa,SAAQ,wBAAc;IAGtD,YAAY,SAAoB;QAC9B,KAAK,EAAE,CAAC;QAHV;;;;;WAA6B;QAI3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAMM,KAAK,CAAC,IAAI,CAAC,GAAwB;QACxC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAE5D,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;I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I,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAzHoB,YAAY;IADhC,IAAA,mBAAM,GAAE;qCAIgB,mBAAS;GAHb,YAAY,CAyHhC;kBAzHoB,YAAY;AA2HjC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC"}
|
||||
43
build/app/Controllers/Http/Api/v1/StatController.js
Normal file
43
build/app/Controllers/Http/Api/v1/StatController.js
Normal file
@ -0,0 +1,43 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const StatService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/StatService"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let StatController = class StatController extends BaseController_1.default {
|
||||
constructor(statService) {
|
||||
super();
|
||||
Object.defineProperty(this, "statService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.statService = statService;
|
||||
}
|
||||
async index(ctx) {
|
||||
const result = await this.statService.fetchStatData();
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
StatController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [StatService_1.default])
|
||||
], StatController);
|
||||
exports.default = StatController;
|
||||
new standalone_1.Ioc().make(StatController);
|
||||
//# sourceMappingURL=StatController.js.map
|
||||
1
build/app/Controllers/Http/Api/v1/StatController.js.map
Normal file
1
build/app/Controllers/Http/Api/v1/StatController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"StatController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/StatController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAEzE,iGAAmD;AAEnD,0EAAkD;AAGlD,IAAqB,cAAc,GAAnC,MAAqB,cAAe,SAAQ,wBAAc;IAGxD,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QAHV;;;;;WAAiC;QAI/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAMM,KAAK,CAAC,KAAK,CAAC,GAAwB;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,CAAC;QAEtD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE;YACnC,MAAM,IAAI,sBAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AArBoB,cAAc;IADlC,IAAA,mBAAM,GAAE;qCAIkB,qBAAW;GAHjB,cAAc,CAqBlC;kBArBoB,cAAc;AAuBnC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC"}
|
||||
93
build/app/Controllers/Http/Api/v1/UsersController.js
Normal file
93
build/app/Controllers/Http/Api/v1/UsersController.js
Normal file
@ -0,0 +1,93 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const UserService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/UserService"));
|
||||
const AddRoleToUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/User/AddRoleToUserValidator"));
|
||||
const CreateUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/User/CreateUserValidator"));
|
||||
const DelRoleFromUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/User/DelRoleFromUserValidator"));
|
||||
const UpdateUserValidator_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Validators/User/UpdateUserValidator"));
|
||||
const BaseController_1 = __importDefault(require("../../BaseController"));
|
||||
let UsersController = class UsersController extends BaseController_1.default {
|
||||
constructor(userService) {
|
||||
super();
|
||||
Object.defineProperty(this, "userService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.userService = userService;
|
||||
}
|
||||
async list(ctx) {
|
||||
const result = await this.userService.fetchUsers(ctx.request.qs());
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status, result.meta);
|
||||
}
|
||||
async show(ctx) {
|
||||
const result = await this.userService.fetchUser(ctx.params.id);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async create(ctx) {
|
||||
const payload = await ctx.request.validate(CreateUserValidator_1.default);
|
||||
const result = await this.userService.createUser(payload, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async update(ctx) {
|
||||
const payload = await ctx.request.validate(UpdateUserValidator_1.default);
|
||||
const result = await this.userService.updateUser(ctx.params.id, payload, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async delete(ctx) {
|
||||
const result = await this.userService.deleteUser(ctx.params.id, ctx);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async attachRoles(ctx) {
|
||||
const payload = await ctx.request.validate(AddRoleToUserValidator_1.default);
|
||||
const result = await this.userService.attachRolesToUser(ctx.params.id, payload.roles);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
async detachRoles(ctx) {
|
||||
const payload = await ctx.request.validate(DelRoleFromUserValidator_1.default);
|
||||
const result = await this.userService.detachRolesFromUser(ctx.params.id, payload.roles);
|
||||
if (!result.success && result.error) {
|
||||
throw new standalone_1.Exception(result.message, result.status, result.error.code);
|
||||
}
|
||||
return this.sendResponse(ctx, result.data, result.message, result.status);
|
||||
}
|
||||
};
|
||||
UsersController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [UserService_1.default])
|
||||
], UsersController);
|
||||
exports.default = UsersController;
|
||||
new standalone_1.Ioc().make(UsersController);
|
||||
//# sourceMappingURL=UsersController.js.map
|
||||
1
build/app/Controllers/Http/Api/v1/UsersController.js.map
Normal file
1
build/app/Controllers/Http/Api/v1/UsersController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"UsersController.js","sourceRoot":"","sources":["../../../../../../app/Controllers/Http/Api/v1/UsersController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAMzE,iGAAmD;AAKnD,8HAAgF;AAChF,wHAA0E;AAC1E,kIAAoF;AACpF,wHAA0E;AAE1E,0EAAkD;AAGlD,IAAqB,eAAe,GAApC,MAAqB,eAAgB,SAAQ,wBAAc;IAGzD,YAAY,WAAwB;QAClC,KAAK,EAAE,CAAC;QAHV;;;;;WAAiC;QAI/B,IAAI,CAAC,WAAW,GAAG,WAAW,CA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AAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5E,CAAC;CACF,CAAA;AAlHoB,eAAe;IADnC,IAAA,mBAAM,GAAE;qCAIkB,qBAAW;GAHjB,eAAe,CAkHnC;kBAlHoB,eAAe;AAoHpC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC"}
|
||||
35
build/app/Controllers/Http/BaseController.js
Normal file
35
build/app/Controllers/Http/BaseController.js
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Drive_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Drive"));
|
||||
const path_1 = require("path");
|
||||
class BaseController {
|
||||
sendResponse(ctx, data, message, status = 200, meta) {
|
||||
const response = {
|
||||
status,
|
||||
message,
|
||||
data,
|
||||
meta,
|
||||
};
|
||||
return ctx.response.status(response.status).send(response);
|
||||
}
|
||||
sendStream(ctx, ...args) {
|
||||
return ctx.response.stream(...args);
|
||||
}
|
||||
sendFile(ctx, ...args) {
|
||||
return ctx.response.attachment(...args);
|
||||
}
|
||||
async sendFileFromDrive(pathname, ctx) {
|
||||
if (!(await Drive_1.default.exists(pathname)))
|
||||
return ctx.response.notFound();
|
||||
const { size } = await Drive_1.default.getStats(pathname);
|
||||
ctx.response.type((0, path_1.extname)(pathname));
|
||||
ctx.response.header('content-length', size);
|
||||
const stream = await Drive_1.default.getStream(pathname);
|
||||
return this.sendStream(ctx, stream);
|
||||
}
|
||||
}
|
||||
exports.default = BaseController;
|
||||
//# sourceMappingURL=BaseController.js.map
|
||||
1
build/app/Controllers/Http/BaseController.js.map
Normal file
1
build/app/Controllers/Http/BaseController.js.map
Normal file
@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AAI,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACF;AAnCD,iCAmCC"}
|
||||
49
build/app/Controllers/Http/VideosController.js
Normal file
49
build/app/Controllers/Http/VideosController.js
Normal file
@ -0,0 +1,49 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const LessonVideo_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/LessonVideo"));
|
||||
const LessonService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/LessonService"));
|
||||
const BaseController_1 = __importDefault(require("./BaseController"));
|
||||
let VideosController = class VideosController extends BaseController_1.default {
|
||||
constructor(lessonService) {
|
||||
super();
|
||||
Object.defineProperty(this, "lessonService", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.lessonService = lessonService;
|
||||
}
|
||||
async getVideo(ctx) {
|
||||
const { fileName } = ctx.request.params();
|
||||
const { data, message, status, success, error } = await this.lessonService.fetchVideoFile(ctx, fileName);
|
||||
if (!success && error) {
|
||||
throw new standalone_1.Exception(message, status, error.code);
|
||||
}
|
||||
if (data instanceof LessonVideo_1.default) {
|
||||
ctx.response.header('Accept-Ranges', 'bytes');
|
||||
return this.sendFileFromDrive(`videos/${data.name}`, ctx);
|
||||
}
|
||||
return this.sendResponse(ctx, data, message, status);
|
||||
}
|
||||
};
|
||||
VideosController = __decorate([
|
||||
(0, standalone_1.inject)(),
|
||||
__metadata("design:paramtypes", [LessonService_1.default])
|
||||
], VideosController);
|
||||
exports.default = VideosController;
|
||||
new standalone_1.Ioc().make(VideosController);
|
||||
//# sourceMappingURL=VideosController.js.map
|
||||
1
build/app/Controllers/Http/VideosController.js.map
Normal file
1
build/app/Controllers/Http/VideosController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"VideosController.js","sourceRoot":"","sources":["../../../../app/Controllers/Http/VideosController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAyE;AAMzE,+FAAiD;AAKjD,qGAAuD;AAEvD,sEAA8C;AAG9C,IAAqB,gBAAgB,GAArC,MAAqB,gBAAiB,SAAQ,wBAAc;IAG1D,YAAY,aAA4B;QACtC,KAAK,EAAE,CAAC;QAHV;;;;;WAAqC;QAInC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAMM,KAAK,CAAC,QAAQ,CAAC,GAAwB;QAC5C,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAEzG,IAAI,CAAC,OAAO,IAAI,KAAK,EAAE;YACrB,MAAM,IAAI,sBAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;SAClD;QAED,IAAI,IAAI,YAAY,qBAAW,EAAE;YAI/B,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;YAK9C,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;SAC3D;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;CACF,CAAA;AAlCoB,gBAAgB;IADpC,IAAA,mBAAM,GAAE;qCAIoB,uBAAa;GAHrB,gBAAgB,CAkCpC;kBAlCoB,gBAAgB;AAoCrC,IAAI,gBAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC"}
|
||||
68
build/app/Controllers/Ws/OnlineController.js
Normal file
68
build/app/Controllers/Ws/OnlineController.js
Normal file
@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class OnlineController {
|
||||
constructor(socket, io, sessionStore) {
|
||||
Object.defineProperty(this, "socket", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "io", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "sessionStore", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.socket = socket;
|
||||
this.io = io;
|
||||
this.sessionStore = sessionStore;
|
||||
}
|
||||
handle() {
|
||||
this.onConnected(this.socket);
|
||||
this.socket.on('disconnect', reason => this.onDisconnected(reason));
|
||||
}
|
||||
sendOnline(online) {
|
||||
this.io.sockets.emit('user:online', online);
|
||||
}
|
||||
setUserOnline() {
|
||||
const { sessionId, userId, userName } = this.socket.data;
|
||||
if (sessionId && userId && userName) {
|
||||
this.sessionStore
|
||||
.saveSession(sessionId, { userId, userName, connected: true })
|
||||
.then(() => this.sessionStore.getOnlineSessions())
|
||||
.then(online => this.sendOnline(online));
|
||||
}
|
||||
}
|
||||
async setUserOffline() {
|
||||
if (this.socket.data.userName && this.socket.data.sessionId && this.socket.data.userId) {
|
||||
const matchingSockets = await this.io.in(this.socket.data.userId).allSockets();
|
||||
const isDisconnected = matchingSockets.size === 0;
|
||||
if (isDisconnected) {
|
||||
const { sessionId, userId, userName } = this.socket.data;
|
||||
this.sessionStore
|
||||
.saveSession(sessionId, { userId, userName, connected: false })
|
||||
.then(() => this.sessionStore.getOnlineSessions())
|
||||
.then(online => this.socket.broadcast.emit('user:online', online));
|
||||
}
|
||||
}
|
||||
}
|
||||
async onConnected(socket) {
|
||||
this.setUserOnline();
|
||||
if (this.socket.data.userName && this.socket.data.sessionId && this.socket.data.userId) {
|
||||
socket.broadcast.emit('user:connected', { userId: this.socket.data.userId, userName: this.socket.data.userName });
|
||||
}
|
||||
socket.on('user:status', () => this.setUserOnline());
|
||||
}
|
||||
onDisconnected(_reason) {
|
||||
this.setUserOffline();
|
||||
}
|
||||
}
|
||||
exports.default = OnlineController;
|
||||
//# sourceMappingURL=OnlineController.js.map
|
||||
1
build/app/Controllers/Ws/OnlineController.js.map
Normal file
1
build/app/Controllers/Ws/OnlineController.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"OnlineController.js","sourceRoot":"","sources":["../../../../app/Controllers/Ws/OnlineController.ts"],"names":[],"mappings":";;AAIA,MAAqB,gBAAgB;IAOnC,YACE,MAAc,EACd,EAAqF,EACrF,YAA+B;QATjC;;;;;WAAiG;QAEjG;;;;;WAA6F;QAE7F;;;;;WAAuC;QAOrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,WAAW,CAAC,IA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CAAC,MAAM,CAAC,IAAI,CAAC;gBAIzD,IAAI,CAAC,YAAY;qBACd,WAAW,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qBAC9D,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAC;qBACjD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;aACtE;SACF;IACH,CAAC;IAKM,KAAK,CAAC,WAAW,CAAC,MAAyF;QAIhH,IAAI,CAAC,aAAa,EAAE,CAAC;QAKrB,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;YACtF,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;SACnH;QAKD,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACvD,CAAC;IAMM,cAAc,CAAC,OAAe;QACnC,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;CACF;AAvFD,mCAuFC"}
|
||||
10
build/app/Datatypes/Enums/CodeErrorEnum.js
Normal file
10
build/app/Datatypes/Enums/CodeErrorEnum.js
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var CodeErrorEnum;
|
||||
(function (CodeErrorEnum) {
|
||||
CodeErrorEnum["NOT_FOUND"] = "E_NOT_FOUND";
|
||||
CodeErrorEnum["BAD_REQUEST"] = "E_BAD_REQUEST";
|
||||
CodeErrorEnum["CONFIRM_CODE_EXIST"] = "E_CONFIRM_CODE_EXIST";
|
||||
})(CodeErrorEnum || (CodeErrorEnum = {}));
|
||||
exports.default = CodeErrorEnum;
|
||||
//# sourceMappingURL=CodeErrorEnum.js.map
|
||||
1
build/app/Datatypes/Enums/CodeErrorEnum.js.map
Normal file
1
build/app/Datatypes/Enums/CodeErrorEnum.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CodeErrorEnum.js","sourceRoot":"","sources":["../../../../app/Datatypes/Enums/CodeErrorEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,aAIJ;AAJD,WAAK,aAAa;IAChB,0CAAyB,CAAA;IACzB,8CAA6B,CAAA;IAC7B,4DAA2C,CAAA;AAC7C,CAAC,EAJI,aAAa,KAAb,aAAa,QAIjB;AAED,kBAAe,aAAa,CAAC"}
|
||||
32
build/app/Datatypes/Enums/ColorEnum.js
Normal file
32
build/app/Datatypes/Enums/ColorEnum.js
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ColorEnum;
|
||||
(function (ColorEnum) {
|
||||
ColorEnum["IndianRed"] = "#CD5C5C";
|
||||
ColorEnum["FireBrick"] = "#B22222";
|
||||
ColorEnum["Tomato"] = "#FF6347";
|
||||
ColorEnum["Orange"] = "#FFA500";
|
||||
ColorEnum["Gold"] = "#FFD700";
|
||||
ColorEnum["Purple"] = "#800080";
|
||||
ColorEnum["Indigo"] = "#4B0082";
|
||||
ColorEnum["Teal"] = "#008080";
|
||||
ColorEnum["Cyan"] = "#0BC5EA";
|
||||
ColorEnum["Crimson"] = "#DC143C";
|
||||
ColorEnum["Chocolate"] = "#D2691E";
|
||||
ColorEnum["Salmon"] = "#FA8072";
|
||||
ColorEnum["Violet"] = "#EE82EE";
|
||||
ColorEnum["Blue"] = "#0000FF";
|
||||
ColorEnum["SteelBlue"] = "#4682B4";
|
||||
ColorEnum["RosyBrown"] = "#BC8F8F";
|
||||
ColorEnum["DarkSlateGray"] = "#2F4F4F";
|
||||
ColorEnum["DimGray"] = "#696969";
|
||||
ColorEnum["MediumVioletRed"] = "#C71585";
|
||||
ColorEnum["MediumOrchid"] = "#BA55D3";
|
||||
ColorEnum["MediumPurple"] = "#9370DB";
|
||||
ColorEnum["MediumSlateBlue"] = "#7B68EE";
|
||||
ColorEnum["MediumSeaGreen"] = "#3CB371";
|
||||
ColorEnum["MediumAquamarine"] = "#66CDAA";
|
||||
ColorEnum["MediumTurquoise"] = "#48D1CC";
|
||||
})(ColorEnum || (ColorEnum = {}));
|
||||
exports.default = ColorEnum;
|
||||
//# sourceMappingURL=ColorEnum.js.map
|
||||
1
build/app/Datatypes/Enums/ColorEnum.js.map
Normal file
1
build/app/Datatypes/Enums/ColorEnum.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ColorEnum.js","sourceRoot":"","sources":["../../../../app/Datatypes/Enums/ColorEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,SA0BJ;AA1BD,WAAK,SAAS;IACZ,kCAAqB,CAAA;IACrB,kCAAqB,CAAA;IACrB,+BAAkB,CAAA;IAClB,+BAAkB,CAAA;IAClB,6BAAgB,CAAA;IAChB,+BAAkB,CAAA;IAClB,+BAAkB,CAAA;IAClB,6BAAgB,CAAA;IAChB,6BAAgB,CAAA;IAChB,gCAAmB,CAAA;IACnB,kCAAqB,CAAA;IACrB,+BAAkB,CAAA;IAClB,+BAAkB,CAAA;IAClB,6BAAgB,CAAA;IAChB,kCAAqB,CAAA;IACrB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;IACzB,gCAAmB,CAAA;IACnB,wCAA2B,CAAA;IAC3B,qCAAwB,CAAA;IACxB,qCAAwB,CAAA;IACxB,wCAA2B,CAAA;IAC3B,uCAA0B,CAAA;IAC1B,yCAA4B,CAAA;IAC5B,wCAA2B,CAAA;AAC7B,CAAC,EA1BI,SAAS,KAAT,SAAS,QA0Bb;AAED,kBAAe,SAAS,CAAC"}
|
||||
9
build/app/Datatypes/Enums/CourseStatusEnum.js
Normal file
9
build/app/Datatypes/Enums/CourseStatusEnum.js
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var CourseStatusEnum;
|
||||
(function (CourseStatusEnum) {
|
||||
CourseStatusEnum["PUBLISHED"] = "PUBLISHED";
|
||||
CourseStatusEnum["DRAFT"] = "DRAFT";
|
||||
})(CourseStatusEnum || (CourseStatusEnum = {}));
|
||||
exports.default = CourseStatusEnum;
|
||||
//# sourceMappingURL=CourseStatusEnum.js.map
|
||||
1
build/app/Datatypes/Enums/CourseStatusEnum.js.map
Normal file
1
build/app/Datatypes/Enums/CourseStatusEnum.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CourseStatusEnum.js","sourceRoot":"","sources":["../../../../app/Datatypes/Enums/CourseStatusEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,gBAGJ;AAHD,WAAK,gBAAgB;IACnB,2CAAuB,CAAA;IACvB,mCAAe,CAAA;AACjB,CAAC,EAHI,gBAAgB,KAAhB,gBAAgB,QAGpB;AAED,kBAAe,gBAAgB,CAAC"}
|
||||
17
build/app/Datatypes/Enums/HttpStatusEnum.js
Normal file
17
build/app/Datatypes/Enums/HttpStatusEnum.js
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var StatusCodeEnum;
|
||||
(function (StatusCodeEnum) {
|
||||
StatusCodeEnum[StatusCodeEnum["OK"] = 200] = "OK";
|
||||
StatusCodeEnum[StatusCodeEnum["CREATED"] = 201] = "CREATED";
|
||||
StatusCodeEnum[StatusCodeEnum["NO_CONTENT"] = 204] = "NO_CONTENT";
|
||||
StatusCodeEnum[StatusCodeEnum["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
||||
StatusCodeEnum[StatusCodeEnum["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
||||
StatusCodeEnum[StatusCodeEnum["FORBIDDEN"] = 403] = "FORBIDDEN";
|
||||
StatusCodeEnum[StatusCodeEnum["NOT_FOUND"] = 404] = "NOT_FOUND";
|
||||
StatusCodeEnum[StatusCodeEnum["CONFLICT"] = 409] = "CONFLICT";
|
||||
StatusCodeEnum[StatusCodeEnum["INTERNAL_SERVER"] = 500] = "INTERNAL_SERVER";
|
||||
StatusCodeEnum[StatusCodeEnum["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
||||
})(StatusCodeEnum || (StatusCodeEnum = {}));
|
||||
exports.default = StatusCodeEnum;
|
||||
//# sourceMappingURL=HttpStatusEnum.js.map
|
||||
1
build/app/Datatypes/Enums/HttpStatusEnum.js.map
Normal file
1
build/app/Datatypes/Enums/HttpStatusEnum.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"HttpStatusEnum.js","sourceRoot":"","sources":["../../../../app/Datatypes/Enums/HttpStatusEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,cAWJ;AAXD,WAAK,cAAc;IACjB,iDAAQ,CAAA;IACR,2DAAa,CAAA;IACb,iEAAgB,CAAA;IAChB,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,+DAAe,CAAA;IACf,+DAAe,CAAA;IACf,6DAAc,CAAA;IACd,2EAAqB,CAAA;IACrB,mFAAyB,CAAA;AAC3B,CAAC,EAXI,cAAc,KAAd,cAAc,QAWlB;AAED,kBAAe,cAAc,CAAC"}
|
||||
10
build/app/Datatypes/Enums/RoleEnum.js
Normal file
10
build/app/Datatypes/Enums/RoleEnum.js
Normal file
@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var RoleEnum;
|
||||
(function (RoleEnum) {
|
||||
RoleEnum["ADMIN"] = "admin";
|
||||
RoleEnum["TEACHER"] = "teacher";
|
||||
RoleEnum["STUDENT"] = "student";
|
||||
})(RoleEnum || (RoleEnum = {}));
|
||||
exports.default = RoleEnum;
|
||||
//# sourceMappingURL=RoleEnum.js.map
|
||||
1
build/app/Datatypes/Enums/RoleEnum.js.map
Normal file
1
build/app/Datatypes/Enums/RoleEnum.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"RoleEnum.js","sourceRoot":"","sources":["../../../../app/Datatypes/Enums/RoleEnum.ts"],"names":[],"mappings":";;AAAA,IAAK,QAIJ;AAJD,WAAK,QAAQ;IACX,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;AACrB,CAAC,EAJI,QAAQ,KAAR,QAAQ,QAIZ;AAED,kBAAe,QAAQ,CAAC"}
|
||||
3
build/app/Datatypes/Interfaces/IResponse.js
Normal file
3
build/app/Datatypes/Interfaces/IResponse.js
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=IResponse.js.map
|
||||
1
build/app/Datatypes/Interfaces/IResponse.js.map
Normal file
1
build/app/Datatypes/Interfaces/IResponse.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"IResponse.js","sourceRoot":"","sources":["../../../../app/Datatypes/Interfaces/IResponse.ts"],"names":[],"mappings":""}
|
||||
14
build/app/Exceptions/Handler.js
Normal file
14
build/app/Exceptions/Handler.js
Normal file
@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Logger_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Logger"));
|
||||
const HttpExceptionHandler_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/HttpExceptionHandler"));
|
||||
class ExceptionHandler extends HttpExceptionHandler_1.default {
|
||||
constructor() {
|
||||
super(Logger_1.default);
|
||||
}
|
||||
}
|
||||
exports.default = ExceptionHandler;
|
||||
//# sourceMappingURL=Handler.js.map
|
||||
1
build/app/Exceptions/Handler.js.map
Normal file
1
build/app/Exceptions/Handler.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Handler.js","sourceRoot":"","sources":["../../../app/Exceptions/Handler.ts"],"names":[],"mappings":";;;;;AAeA,sFAA6C;AAC7C,kHAAyE;AAEzE,MAAqB,gBAAiB,SAAQ,8BAAoB;IAChE;QACE,KAAK,CAAC,gBAAM,CAAC,CAAC;IAChB,CAAC;CACF;AAJD,mCAIC"}
|
||||
40
build/app/Helpers/ColorHelper.js
Normal file
40
build/app/Helpers/ColorHelper.js
Normal file
@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Color_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Color"));
|
||||
const utils = __importStar(global[Symbol.for('ioc.use')]("App/Utils"));
|
||||
class ColorHelper {
|
||||
static async generateRandomColor() {
|
||||
const colors = await Color_1.default.query();
|
||||
if (colors.length === 0)
|
||||
return null;
|
||||
return colors[utils.generateRandomInt({ min: 0, max: colors.length - 1 })];
|
||||
}
|
||||
}
|
||||
exports.default = ColorHelper;
|
||||
//# sourceMappingURL=ColorHelper.js.map
|
||||
1
build/app/Helpers/ColorHelper.js.map
Normal file
1
build/app/Helpers/ColorHelper.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ColorHelper.js","sourceRoot":"","sources":["../../../app/Helpers/ColorHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mFAAqC;AACrC,uEAAmC;AAEnC,MAAqB,WAAW;IACvB,MAAM,CAAC,KAAK,CAAC,mBAAmB;QACrC,MAAM,MAAM,GAAG,MAAM,eAAK,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACrC,OAAO,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAND,8BAMC"}
|
||||
17
build/app/Helpers/CookieHelper.js
Normal file
17
build/app/Helpers/CookieHelper.js
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class CookieHelper {
|
||||
static parseCookieString(string) {
|
||||
const values = string
|
||||
.split(';')
|
||||
.map(v => v.split('='))
|
||||
.reduce((acc, value) => {
|
||||
const [key, ...rest] = value;
|
||||
acc[decodeURIComponent(key.trim())] = decodeURIComponent(rest.join('=').trim());
|
||||
return acc;
|
||||
}, {});
|
||||
return values;
|
||||
}
|
||||
}
|
||||
exports.default = CookieHelper;
|
||||
//# sourceMappingURL=CookieHelper.js.map
|
||||
1
build/app/Helpers/CookieHelper.js.map
Normal file
1
build/app/Helpers/CookieHelper.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CookieHelper.js","sourceRoot":"","sources":["../../../app/Helpers/CookieHelper.ts"],"names":[],"mappings":";;AAAA,MAAqB,YAAY;IACxB,MAAM,CAAC,iBAAiB,CAAC,MAAc;QAC5C,MAAM,MAAM,GAAG,MAAM;aAClB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACtB,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACrB,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;YAC7B,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAChF,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;QAET,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAbD,+BAaC"}
|
||||
24
build/app/Helpers/CourseHelper.js
Normal file
24
build/app/Helpers/CourseHelper.js
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class CourseHelper {
|
||||
static getVideoFileNames(course) {
|
||||
const data = course.lessons.map(l => {
|
||||
if (!l.video)
|
||||
return null;
|
||||
return { path: 'videos/', name: l.video.name };
|
||||
});
|
||||
return data;
|
||||
}
|
||||
static getMaterialFileNames(course) {
|
||||
const data = course.lessons.flatMap(l => l.materials.map(m => ({ path: 'materials/', name: m.name })));
|
||||
return data;
|
||||
}
|
||||
static getImageFileName(course) {
|
||||
if (!course.image)
|
||||
return null;
|
||||
const data = { path: 'images/courses/', name: course.image.name };
|
||||
return data;
|
||||
}
|
||||
}
|
||||
exports.default = CourseHelper;
|
||||
//# sourceMappingURL=CourseHelper.js.map
|
||||
1
build/app/Helpers/CourseHelper.js.map
Normal file
1
build/app/Helpers/CourseHelper.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CourseHelper.js","sourceRoot":"","sources":["../../../app/Helpers/CourseHelper.ts"],"names":[],"mappings":";;AAOA,MAAqB,YAAY;IACxB,MAAM,CAAC,iBAAiB,CAAC,MAAc;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClC,IAAI,CAAC,CAAC,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC;YAC1B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,oBAAoB,CAAC,MAAc;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACvG,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,MAAc;QAC3C,IAAI,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAC/B,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AApBD,+BAoBC"}
|
||||
25
build/app/Helpers/OpaqueTokenHelper.js
Normal file
25
build/app/Helpers/OpaqueTokenHelper.js
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
class OpaqueTokenHelper {
|
||||
static parseToken(token) {
|
||||
const parts = token.split('.');
|
||||
if (parts.length !== 2) {
|
||||
throw new Error('E_INVALID_API_TOKEN');
|
||||
}
|
||||
const id = Buffer.from(parts[0], 'base64').toString('utf-8');
|
||||
if (!id) {
|
||||
throw new Error('E_INVALID_API_TOKEN');
|
||||
}
|
||||
const hashed = crypto_1.default.createHash('sha256').update(parts[1]).digest('hex');
|
||||
return {
|
||||
hashed,
|
||||
id,
|
||||
};
|
||||
}
|
||||
}
|
||||
exports.default = OpaqueTokenHelper;
|
||||
//# sourceMappingURL=OpaqueTokenHelper.js.map
|
||||
1
build/app/Helpers/OpaqueTokenHelper.js.map
Normal file
1
build/app/Helpers/OpaqueTokenHelper.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"OpaqueTokenHelper.js","sourceRoot":"","sources":["../../../app/Helpers/OpaqueTokenHelper.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,MAAqB,iBAAiB;IAO7B,MAAM,CAAC,UAAU,CAAC,KAAa;QACpC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACxC;QAED,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE7D,IAAI,CAAC,EAAE,EAAE;YACP,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;SACxC;QAED,MAAM,MAAM,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAE1E,OAAO;YACL,MAAM;YACN,EAAE;SACH,CAAC;IACJ,CAAC;CACF;AA3BD,oCA2BC"}
|
||||
17
build/app/Helpers/RoleHelper.js
Normal file
17
build/app/Helpers/RoleHelper.js
Normal file
@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class RoleHelper {
|
||||
static userHasRoles(userRoles, roles) {
|
||||
for (let i = 0; i < roles.length; i += 1) {
|
||||
if (!userRoles.map(r => r.slug).includes(roles[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static userContainRoles(userRoles, roles) {
|
||||
return userRoles.map(r => r.slug).some(r => roles.includes(r));
|
||||
}
|
||||
}
|
||||
exports.default = RoleHelper;
|
||||
//# sourceMappingURL=RoleHelper.js.map
|
||||
1
build/app/Helpers/RoleHelper.js.map
Normal file
1
build/app/Helpers/RoleHelper.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"RoleHelper.js","sourceRoot":"","sources":["../../../app/Helpers/RoleHelper.ts"],"names":[],"mappings":";;AAGA,MAAqB,UAAU;IAStB,MAAM,CAAC,YAAY,CAAC,SAAiB,EAAE,KAAiB;QAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACxC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBAIlD,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,SAAiB,EAAE,KAAiB;QACjE,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAxBD,6BAwBC"}
|
||||
33
build/app/Middleware/Auth.js
Normal file
33
build/app/Middleware/Auth.js
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/auth/build/standalone");
|
||||
class AuthMiddleware {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "redirectTo", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: '/login'
|
||||
});
|
||||
}
|
||||
async authenticate(auth, guards) {
|
||||
let guardLastAttempted;
|
||||
const authResults = await Promise.all(guards.map(guard => auth.use(guard).check()));
|
||||
for (let i = 0; i < authResults.length; i += 1) {
|
||||
if (authResults[i])
|
||||
return;
|
||||
}
|
||||
throw new standalone_1.AuthenticationException('Unauthorized access', 'E_UNAUTHORIZED_ACCESS', guardLastAttempted, this.redirectTo);
|
||||
}
|
||||
async handle(ctx, next, customGuards) {
|
||||
const token = ctx.request.cookie('token');
|
||||
if (token) {
|
||||
ctx.request.headers().authorization = `Bearer ${token}`;
|
||||
}
|
||||
const guards = customGuards.length ? customGuards : [ctx.auth.name];
|
||||
await this.authenticate(ctx.auth, guards);
|
||||
await next();
|
||||
}
|
||||
}
|
||||
exports.default = AuthMiddleware;
|
||||
//# sourceMappingURL=Auth.js.map
|
||||
1
build/app/Middleware/Auth.js.map
Normal file
1
build/app/Middleware/Auth.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Auth.js","sourceRoot":"","sources":["../../../app/Middleware/Auth.ts"],"names":[],"mappings":";;AAEA,gEAA0E;AAS1E,MAAqB,cAAc;IAAnC;QAIE;;;;mBAAuB,QAAQ;WAAC;IAuDlC,CAAC;IA7CW,KAAK,CAAC,YAAY,CAAC,IAAiC,EAAE,MAA4B;QAO1F,IAAI,kBAAsC,CAAC;QAC3C,MAAM,WAAW,GAAc,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE/F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YAI9C,IAAI,WAAW,CAAC,CAAC,CAAC;gBAAE,OAAO;SAC5B;QAKD,MAAM,IAAI,oCAAuB,CAC/B,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,IAAI,CAAC,UAAU,CAChB,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAwB,EAAE,IAAyB,EAAE,YAAkC;QAIzG,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC1C,IAAI,KAAK,EAAE;YACT,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;SACzD;QAMD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpE,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;CACF;AA3DD,iCA2DC"}
|
||||
38
build/app/Middleware/Role.js
Normal file
38
build/app/Middleware/Role.js
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const standalone_1 = require("@adonisjs/core/build/standalone");
|
||||
const User_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/User"));
|
||||
class Role {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "error", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.error = {
|
||||
message: 'You dont have permission to perform that action.',
|
||||
status: 403,
|
||||
code: 'E_ACCESS_DENIED',
|
||||
};
|
||||
}
|
||||
check(roles, userRoles) {
|
||||
if (!roles.some(role => userRoles.includes(role))) {
|
||||
throw new standalone_1.Exception(this.error.message, this.error.status, this.error.code);
|
||||
}
|
||||
}
|
||||
async handle({ auth }, next, roles) {
|
||||
const { userId } = auth.use('api').token?.meta;
|
||||
const user = await User_1.default.query().where('id', userId).preload('roles').first();
|
||||
if (!user) {
|
||||
throw new standalone_1.Exception('Cannot identify current user.', this.error.status, this.error.code);
|
||||
}
|
||||
this.check(roles, user.roles.map(role => role.slug));
|
||||
await next();
|
||||
}
|
||||
}
|
||||
exports.default = Role;
|
||||
//# sourceMappingURL=Role.js.map
|
||||
1
build/app/Middleware/Role.js.map
Normal file
1
build/app/Middleware/Role.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../app/Middleware/Role.ts"],"names":[],"mappings":";;;;;AAAA,gEAA4D;AAE5D,iFAAmC;AAEnC,MAAqB,IAAI;IAOvB;QANA;;;;;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||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const nanoid_1 = require("nanoid");
|
||||
const Redis_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Addons/Redis"));
|
||||
const CookieHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/CookieHelper"));
|
||||
const OpaqueTokenHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/OpaqueTokenHelper"));
|
||||
const WsService_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Services/WsService"));
|
||||
class AuthMiddleware {
|
||||
static async authenticate(socket, next) {
|
||||
const cookie = socket.handshake.headers?.cookie;
|
||||
if (!cookie) {
|
||||
return next(new Error('SocketErrors.MissingParameter'));
|
||||
}
|
||||
const token = CookieHelper_1.default.parseCookieString(cookie)?.token;
|
||||
if (!token) {
|
||||
return next(new Error('SocketErrors.MissingParameter'));
|
||||
}
|
||||
const tokenData = JSON.parse(Buffer.from(token.split('.')[0].split(':')[1], 'base64').toString('utf-8'));
|
||||
const parsed = OpaqueTokenHelper_1.default.parseToken(tokenData.message);
|
||||
const data = await Redis_1.default.get(`api:${parsed.id}`);
|
||||
if (!data) {
|
||||
return next(new Error('SocketErrors.BadCredentials'));
|
||||
}
|
||||
const sessionId = socket.handshake.auth.sessionId;
|
||||
if (sessionId) {
|
||||
const session = await WsService_1.default.sessionStore.findSession(sessionId);
|
||||
if (session) {
|
||||
socket.data.sessionId = sessionId;
|
||||
socket.data.userId = session.userId;
|
||||
socket.data.userName = session.userName;
|
||||
return next();
|
||||
}
|
||||
}
|
||||
const parsedData = JSON.parse(data);
|
||||
socket.data.sessionId = (0, nanoid_1.nanoid)();
|
||||
socket.data.userId = parsedData.user_id;
|
||||
socket.data.userName = parsedData.userName;
|
||||
return next();
|
||||
}
|
||||
}
|
||||
exports.default = AuthMiddleware;
|
||||
//# sourceMappingURL=Auth.js.map
|
||||
1
build/app/Middleware/Ws/Auth.js.map
Normal file
1
build/app/Middleware/Ws/Auth.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Auth.js","sourceRoot":"","sources":["../../../../app/Middleware/Ws/Auth.ts"],"names":[],"mappings":";;;;;AACA,mCAAgC;AAChC,sFAA6C;AAC7C,kGAAoD;AACpD,4GAA8D;AAC9D,6FAAuH;AAIvH,MAAqB,cAAc;IAS1B,MAAM,CAAC,KAAK,CAAC,YAAY,CAC9B,MAAyF,EACzF,IAA+C;QAK/C,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;QAEhD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,IAAI,CAAC,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;SACzD;QAED,MAAM,KAAK,GAAG,sBAAY,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC;QAE5D,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,IAAI,CAAC,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;SACzD;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACzG,MAAM,MAAM,GAAG,2BAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,IAAI,CAAC,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC,CAAC;SACvD;QAKD,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAA+B,CAAC;QAExE,IAAI,SAAS,EAAE;YACb,MAAM,OAAO,GAAG,MAAM,mBAAE,CAAC,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YAE7D,IAAI,OAAO,EAAE;gBACX,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;gBAClC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBACpC,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;gBAExC,OAAO,IAAI,EAAE,CAAC;aACf;SACF;QAKD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAKpC,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,IAAA,eAAM,GAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,OAAiB,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAkB,CAAC;QAErD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;CACF;AAnED,iCAmEC"}
|
||||
119
build/app/Models/Category.js
Normal file
119
build/app/Models/Category.js
Normal file
@ -0,0 +1,119 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const nanoid_1 = require("nanoid");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const ColorHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/ColorHelper"));
|
||||
const Color_1 = __importDefault(require("./Color"));
|
||||
class Category extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "title", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "description", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
static assignCategoryId(category) {
|
||||
category.id = (0, nanoid_1.nanoid)();
|
||||
}
|
||||
static async assignRandomColor(category) {
|
||||
const color = await ColorHelper_1.default.generateRandomColor();
|
||||
if (color) {
|
||||
category.color_id = color.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", String)
|
||||
], Category.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Category.prototype, "title", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Category.prototype, "description", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", Object)
|
||||
], Category.prototype, "color_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Color_1.default, {
|
||||
foreignKey: 'color_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Category.prototype, "color", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Category.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Category.prototype, "updatedAt", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Category]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], Category, "assignCategoryId", null);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Category]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], Category, "assignRandomColor", null);
|
||||
exports.default = Category;
|
||||
//# sourceMappingURL=Category.js.map
|
||||
1
build/app/Models/Category.js.map
Normal file
1
build/app/Models/Category.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Category.js","sourceRoot":"","sources":["../../../app/Models/Category.ts"],"names":[],"mappings":";;;;;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AE;;qCACiC,QAAQ;;uCAMvD;AAxCH,2BAyCC"}
|
||||
53
build/app/Models/Color.js
Normal file
53
build/app/Models/Color.js
Normal file
@ -0,0 +1,53 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const ColorEnum_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Datatypes/Enums/ColorEnum"));
|
||||
class Color extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "hex", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], Color.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Color.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Color.prototype, "hex", void 0);
|
||||
exports.default = Color;
|
||||
//# sourceMappingURL=Color.js.map
|
||||
1
build/app/Models/Color.js.map
Normal file
1
build/app/Models/Color.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Color.js","sourceRoot":"","sources":["../../../app/Models/Color.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAA0D;AAC1D,oGAAsD;AAEtD,MAAqB,KAAM,SAAQ,eAAS;IAA5C;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAoB;QAGpB;;;;;WAAsB;IACxB,CAAC;CAAA;AAPC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;iCACV;AAGlB;IADC,IAAA,YAAM,GAAE;;mCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;kCACa;AARxB,wBASC"}
|
||||
116
build/app/Models/Contact.js
Normal file
116
build/app/Models/Contact.js
Normal file
@ -0,0 +1,116 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const User_1 = __importDefault(require("./User"));
|
||||
class Contact extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "user_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "phone_number", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "vk_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "twitter_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "telegram_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "user", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], Contact.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], Contact.prototype, "user_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Contact.prototype, "phone_number", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Contact.prototype, "vk_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Contact.prototype, "twitter_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Contact.prototype, "telegram_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => User_1.default, {
|
||||
foreignKey: 'user_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Contact.prototype, "user", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Contact.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Contact.prototype, "updatedAt", void 0);
|
||||
exports.default = Contact;
|
||||
//# sourceMappingURL=Contact.js.map
|
||||
1
build/app/Models/Contact.js.map
Normal file
1
build/app/Models/Contact.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Contact.js","sourceRoot":"","sources":["../../../app/Models/Contact.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,gEAAgF;AAChF,kDAA0B;AAE1B,MAAqB,OAAQ,SAAQ,eAAS;IAA9C;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAuB;QAGvB;;;;;WAAmC;QAGnC;;;;;WAA4B;QAG5B;;;;;WAAiC;QAGjC;;;;;WAAkC;QAKlC;;;;;WAAoC;QAGpC;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AA3BC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;mCACV;AAGlB;IADC,IAAA,YAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;wCACP;AAGvB;IADC,IAAA,YAAM,GAAE;;6CAC0B;AAGnC;IADC,IAAA,YAAM,GAAE;;sCACmB;AAG5B;IADC,IAAA,YAAM,GAAE;;2CACwB;AAGjC;IADC,IAAA,YAAM,GAAE;;4CACyB;AAKlC;IAHC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,cAAI,EAAE;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC;;qCACkC;AAGpC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACvC,gBAAQ;0CAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACzD,gBAAQ;0CAAC;AA5B7B,0BA6BC"}
|
||||
246
build/app/Models/Course.js
Normal file
246
build/app/Models/Course.js
Normal file
@ -0,0 +1,246 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const nanoid_1 = require("nanoid");
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const AttachmentLite_1 = global[Symbol.for('ioc.use')]("Adonis/Addons/AttachmentLite");
|
||||
const ColorHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/ColorHelper"));
|
||||
const Category_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Category"));
|
||||
const Lesson_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Lesson"));
|
||||
const User_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/User"));
|
||||
const CourseStatusEnum_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Datatypes/Enums/CourseStatusEnum"));
|
||||
const Color_1 = __importDefault(require("./Color"));
|
||||
class Course extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "image", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "title", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "description", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "education_description", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "teacher_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "category_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "status", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "category", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "teacher", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lessons", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "students", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "likes", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
static assignCourseId(course) {
|
||||
course.id = (0, nanoid_1.nanoid)();
|
||||
}
|
||||
static async assignRandomColor(course) {
|
||||
const color = await ColorHelper_1.default.generateRandomColor();
|
||||
if (color) {
|
||||
course.color_id = color.id;
|
||||
}
|
||||
}
|
||||
serializeExtras() {
|
||||
return {
|
||||
students_count: this.$extras.students_count,
|
||||
likes_count: this.$extras.likes_count,
|
||||
lessons_count: this.$extras.lessons_count,
|
||||
};
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, AttachmentLite_1.attachment)({ folder: 'images/courses', preComputeUrl: true }),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "image", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "title", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "description", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "education_description", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "teacher_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "category_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "color_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Color_1.default, {
|
||||
foreignKey: 'color_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "color", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Course.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Category_1.default, {
|
||||
foreignKey: 'category_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "category", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => User_1.default, {
|
||||
foreignKey: 'teacher_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "teacher", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasMany)(() => Lesson_1.default, {
|
||||
foreignKey: 'course_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "lessons", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => User_1.default, {
|
||||
pivotTable: 'users_courses',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "students", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => User_1.default, {
|
||||
pivotTable: 'courses_likes',
|
||||
pivotTimestamps: {
|
||||
createdAt: 'liked_on',
|
||||
updatedAt: false,
|
||||
},
|
||||
pivotColumns: ['liked_on'],
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Course.prototype, "likes", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Course.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Course.prototype, "updatedAt", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Course]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], Course, "assignCourseId", null);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Course]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], Course, "assignRandomColor", null);
|
||||
exports.default = Course;
|
||||
//# sourceMappingURL=Course.js.map
|
||||
1
build/app/Models/Course.js.map
Normal file
1
build/app/Models/Course.js.map
Normal file
@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,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;yCAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;yCAAC;AAO3B;IADC,IAAA,kBAAY,GAAE;;qCACsB,MAAM;;kCAE1C;AAGD;IADC,IAAA,kBAAY,GAAE;;qCAC+B,MAAM;;qCAMnD;AArFH,yBAiGC"}
|
||||
80
build/app/Models/Image.js
Normal file
80
build/app/Models/Image.js
Normal file
@ -0,0 +1,80 @@
|
||||
"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 });
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
class Image extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "path", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "ext", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], Image.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Image.prototype, "path", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Image.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Image.prototype, "ext", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Image.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Image.prototype, "updatedAt", void 0);
|
||||
exports.default = Image;
|
||||
//# sourceMappingURL=Image.js.map
|
||||
1
build/app/Models/Image.js.map
Normal file
1
build/app/Models/Image.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Image.js","sourceRoot":"","sources":["../../../app/Models/Image.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iCAAiC;AACjC,gEAA0D;AAE1D,MAAqB,KAAM,SAAQ,eAAS;IAA5C;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAoB;QAGpB;;;;;WAAoB;QAGpB;;;;;WAAmB;QAGnB;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AAhBC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;iCACV;AAGlB;IADC,IAAA,YAAM,GAAE;;mCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;mCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;kCACU;AAGnB;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;wCAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;wCAAC;AAjB7B,wBAkBC"}
|
||||
227
build/app/Models/Lesson.js
Normal file
227
build/app/Models/Lesson.js
Normal file
@ -0,0 +1,227 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const nanoid_1 = require("nanoid");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const ColorHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/ColorHelper"));
|
||||
const Course_1 = __importDefault(require("./Course"));
|
||||
const LessonMaterial_1 = __importDefault(require("./LessonMaterial"));
|
||||
const LessonContent_1 = __importDefault(require("./LessonContent"));
|
||||
const LessonProgress_1 = __importDefault(require("./LessonProgress"));
|
||||
const LessonVideo_1 = __importDefault(require("./LessonVideo"));
|
||||
const Color_1 = __importDefault(require("./Color"));
|
||||
class Lesson extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "course_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "title", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "display_order", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "description", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "linked_video_url", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "duration", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "course", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "color", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "content", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "video", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "materials", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "progress", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
static assignLessonId(lesson) {
|
||||
lesson.id = (0, nanoid_1.nanoid)();
|
||||
}
|
||||
static async assignRandomColor(course) {
|
||||
const color = await ColorHelper_1.default.generateRandomColor();
|
||||
if (color) {
|
||||
course.color_id = color.id;
|
||||
}
|
||||
}
|
||||
serializeExtras() {
|
||||
return {
|
||||
materials_count: this.$extras.materials_count,
|
||||
};
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", String)
|
||||
], Lesson.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Lesson.prototype, "course_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Lesson.prototype, "title", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", Number)
|
||||
], Lesson.prototype, "display_order", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Lesson.prototype, "description", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "linked_video_url", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Lesson.prototype, "duration", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Course_1.default, {
|
||||
foreignKey: 'course_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "course", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "color_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Color_1.default, {
|
||||
foreignKey: 'color_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "color", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasOne)(() => LessonContent_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "content", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasOne)(() => LessonVideo_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "video", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasMany)(() => LessonMaterial_1.default, { foreignKey: 'lesson_id' }),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "materials", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasOne)(() => LessonProgress_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Lesson.prototype, "progress", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Lesson.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Lesson.prototype, "updatedAt", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Lesson]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], Lesson, "assignLessonId", null);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Course_1.default]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], Lesson, "assignRandomColor", null);
|
||||
exports.default = Lesson;
|
||||
//# sourceMappingURL=Lesson.js.map
|
||||
1
build/app/Models/Lesson.js.map
Normal file
1
build/app/Models/Lesson.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Lesson.js","sourceRoot":"","sources":["../../../app/Models/Lesson.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,iCAAiC;AACjC,mCAAgC;AAChC,gEAU+B;AAC/B,gGAAkD;AAClD,sDAA8B;AAC9B,sEAA8C;AAC9C,oEAA4C;AAC5C,sEAA8C;AAC9C,gEAAwC;AACxC,oDAA4B;AAE5B,MAAqB,MAAO,SAAQ,eAAS;IAA7C;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAyB;QAGzB;;;;;WAAqB;QAGrB;;;;;WAA6B;QAG7B;;;;;WAA2B;QAG3B;;;;;WAAuC;QAGvC;;;;;WAAwB;QAKxB;;;;;WAAwC;QAGxC;;;;;WAA+B;QAK/B;;;;;WAAsC;QAKtC;;;;;WAA6C;QAK7C;;;;;WAAyC;QAGzC;;;;;WAAiD;QAKjD;;;;;WAA+C;QAG/C;;;;;WAA2B;QAG3B;;;;;WAA2B;IA4B7B,CAAC;IArBQ,MAAM,CAAC,cAAc,C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AGzC;IADC,IAAA,aAAO,EAAC,GAAG,EAAE,CAAC,wBAAc,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;;yCACV;AAKjD;IAHC,IAAA,YAAM,EAAC,GAAG,EAAE,CAAC,wBAAc,EAAE;QAC5B,UAAU,EAAE,WAAW;KACxB,CAAC;;wCAC6C;AAG/C;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;yCAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;yCAAC;AAO3B;IADC,IAAA,kBAAY,GAAE;;qCACsB,MAAM;;kCAE1C;AAGD;IADC,IAAA,kBAAY,GAAE;;qCAC+B,gBAAM;;qCAMnD;AA3EH,yBAqFC"}
|
||||
84
build/app/Models/LessonContent.js
Normal file
84
build/app/Models/LessonContent.js
Normal file
@ -0,0 +1,84 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const luxon_1 = require("luxon");
|
||||
const Lesson_1 = __importDefault(require("./Lesson"));
|
||||
class LessonContent extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "body", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], LessonContent.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonContent.prototype, "lesson_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonContent.prototype, "body", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Lesson_1.default, { foreignKey: 'lesson_id' }),
|
||||
__metadata("design:type", Object)
|
||||
], LessonContent.prototype, "lesson", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonContent.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonContent.prototype, "updatedAt", void 0);
|
||||
exports.default = LessonContent;
|
||||
//# sourceMappingURL=LessonContent.js.map
|
||||
1
build/app/Models/LessonContent.js.map
Normal file
1
build/app/Models/LessonContent.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonContent.js","sourceRoot":"","sources":["../../../app/Models/LessonContent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gEAAgF;AAChF,iCAAiC;AACjC,sDAA8B;AAE9B,MAAqB,aAAc,SAAQ,eAAS;IAApD;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAyB;QAGzB;;;;;WAAoB;QAGpB;;;;;WAAwC;QAGxC;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AAhBC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;yCACV;AAGlB;IADC,IAAA,YAAM,GAAE;;gDACgB;AAGzB;IADC,IAAA,YAAM,GAAE;;2CACW;AAGpB;IADC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;;6CACb;AAGxC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACvC,gBAAQ;gDAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACzD,gBAAQ;gDAAC;AAjB7B,gCAkBC"}
|
||||
116
build/app/Models/LessonMaterial.js
Normal file
116
build/app/Models/LessonMaterial.js
Normal file
@ -0,0 +1,116 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const luxon_1 = require("luxon");
|
||||
const Lesson_1 = __importDefault(require("./Lesson"));
|
||||
class LessonMaterial extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "size", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "clientName", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "ext", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], LessonMaterial.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonMaterial.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Number)
|
||||
], LessonMaterial.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonMaterial.prototype, "clientName", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonMaterial.prototype, "ext", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonMaterial.prototype, "lesson_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Lesson_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], LessonMaterial.prototype, "lesson", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonMaterial.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonMaterial.prototype, "updatedAt", void 0);
|
||||
exports.default = LessonMaterial;
|
||||
//# sourceMappingURL=LessonMaterial.js.map
|
||||
1
build/app/Models/LessonMaterial.js.map
Normal file
1
build/app/Models/LessonMaterial.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonMaterial.js","sourceRoot":"","sources":["../../../app/Models/LessonMaterial.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gEAAgF;AAChF,iCAAiC;AACjC,sDAA8B;AAE9B,MAAqB,cAAe,SAAQ,eAAS;IAArD;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAoB;QAGpB;;;;;WAAoB;QAGpB;;;;;WAA0B;QAG1B;;;;;WAAmB;QAGnB;;;;;WAAyB;QAKzB;;;;;WAAwC;QAGxC;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AA3BC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;0CACV;AAGlB;IADC,IAAA,YAAM,GAAE;;4CACW;AAGpB;IADC,IAAA,YAAM,GAAE;;4CACW;AAGpB;IADC,IAAA,YAAM,GAAE;;kDACiB;AAG1B;IADC,IAAA,YAAM,GAAE;;2CACU;AAGnB;IADC,IAAA,YAAM,GAAE;;iDACgB;AAKzB;IAHC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE;QACvB,UAAU,EAAE,WAAW;KACxB,CAAC;;8CACsC;AAGxC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;iDAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;iDAAC;AA5B7B,iCA6BC"}
|
||||
88
build/app/Models/LessonProgress.js
Normal file
88
build/app/Models/LessonProgress.js
Normal file
@ -0,0 +1,88 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const Lesson_1 = __importDefault(require("./Lesson"));
|
||||
const User_1 = __importDefault(require("./User"));
|
||||
class LessonProgress extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "user_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "is_watched", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "user", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true, serializeAs: null }),
|
||||
__metadata("design:type", Number)
|
||||
], LessonProgress.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], LessonProgress.prototype, "lesson_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], LessonProgress.prototype, "user_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], LessonProgress.prototype, "is_watched", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Lesson_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], LessonProgress.prototype, "lesson", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => User_1.default, {
|
||||
foreignKey: 'user_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], LessonProgress.prototype, "user", void 0);
|
||||
exports.default = LessonProgress;
|
||||
//# sourceMappingURL=LessonProgress.js.map
|
||||
1
build/app/Models/LessonProgress.js.map
Normal file
1
build/app/Models/LessonProgress.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonProgress.js","sourceRoot":"","sources":["../../../app/Models/LessonProgress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,gEAAgF;AAChF,sDAA8B;AAC9B,kDAA0B;AAE1B,MAAqB,cAAe,SAAQ,eAAS;IAArD;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAyB;QAGzB;;;;;WAAuB;QAGvB;;;;;WAA2B;QAK3B;;;;;WAAwC;QAKxC;;;;;WAAoC;IACtC,CAAC;CAAA;AApBC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;0CAC7B;AAGlB;IADC,IAAA,YAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;iDACL;AAGzB;IADC,IAAA,YAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;+CACP;AAGvB;IADC,IAAA,YAAM,GAAE;;kDACkB;AAK3B;IAHC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE;QACvB,UAAU,EAAE,WAAW;KACxB,CAAC;;8CACsC;AAKxC;IAHC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,cAAI,EAAE;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC;;4CACkC;AArBtC,iCAsBC"}
|
||||
126
build/app/Models/LessonVideo.js
Normal file
126
build/app/Models/LessonVideo.js
Normal file
@ -0,0 +1,126 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const Lesson_1 = __importDefault(require("./Lesson"));
|
||||
class LessonVideo extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson_id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "size", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "clientName", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "ext", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "url", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lesson", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], LessonVideo.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], LessonVideo.prototype, "lesson_id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonVideo.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Number)
|
||||
], LessonVideo.prototype, "size", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonVideo.prototype, "clientName", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonVideo.prototype, "ext", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], LessonVideo.prototype, "url", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.belongsTo)(() => Lesson_1.default, {
|
||||
foreignKey: 'lesson_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], LessonVideo.prototype, "lesson", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonVideo.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], LessonVideo.prototype, "updatedAt", void 0);
|
||||
exports.default = LessonVideo;
|
||||
//# sourceMappingURL=LessonVideo.js.map
|
||||
1
build/app/Models/LessonVideo.js.map
Normal file
1
build/app/Models/LessonVideo.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonVideo.js","sourceRoot":"","sources":["../../../app/Models/LessonVideo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iCAAiC;AACjC,gEAAgF;AAChF,sDAA8B;AAE9B,MAAqB,WAAY,SAAQ,eAAS;IAAlD;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAyB;QAGzB;;;;;WAAoB;QAGpB;;;;;WAAoB;QAGpB;;;;;WAA0B;QAG1B;;;;;WAAmB;QAGnB;;;;;WAAmB;QAKnB;;;;;WAAwC;QAGxC;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AA9BC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;uCACV;AAGlB;IADC,IAAA,YAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;8CACL;AAGzB;IADC,IAAA,YAAM,GAAE;;yCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;yCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;+CACiB;AAG1B;IADC,IAAA,YAAM,GAAE;;wCACU;AAGnB;IADC,IAAA,YAAM,GAAE;;wCACU;AAKnB;IAHC,IAAA,eAAS,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE;QACvB,UAAU,EAAE,WAAW;KACxB,CAAC;;2CACsC;AAGxC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;8CAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;8CAAC;AA/B7B,8BAgCC"}
|
||||
86
build/app/Models/Role.js
Normal file
86
build/app/Models/Role.js
Normal file
@ -0,0 +1,86 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const User_1 = __importDefault(require("./User"));
|
||||
class Role extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "slug", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "users", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", Number)
|
||||
], Role.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Role.prototype, "name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], Role.prototype, "slug", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => User_1.default, {
|
||||
pivotTable: 'users_roles',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], Role.prototype, "users", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Role.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true, serializeAs: null }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], Role.prototype, "updatedAt", void 0);
|
||||
exports.default = Role;
|
||||
//# sourceMappingURL=Role.js.map
|
||||
1
build/app/Models/Role.js.map
Normal file
1
build/app/Models/Role.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../app/Models/Role.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iCAAiC;AACjC,gEAAkF;AAClF,kDAA0B;AAE1B,MAAqB,IAAK,SAAQ,eAAS;IAA3C;;QAEE;;;;;WAAkB;QAGlB;;;;;WAAoB;QAGpB;;;;;WAAoB;QAKpB;;;;;WAAsC;QAGtC;;;;;WAA2B;QAG3B;;;;;WAA2B;IAC7B,CAAC;CAAA;AAlBC;IADC,IAAA,YAAM,EAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;gCACV;AAGlB;IADC,IAAA,YAAM,GAAE;;kCACW;AAGpB;IADC,IAAA,YAAM,GAAE;;kCACW;AAKpB;IAHC,IAAA,gBAAU,EAAC,GAAG,EAAE,CAAC,cAAI,EAAE;QACtB,UAAU,EAAE,aAAa;KAC1B,CAAC;;mCACoC;AAGtC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACvC,gBAAQ;uCAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8BACzD,gBAAQ;uCAAC;AAnB7B,uBAoBC"}
|
||||
217
build/app/Models/User.js
Normal file
217
build/app/Models/User.js
Normal file
@ -0,0 +1,217 @@
|
||||
"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 __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const luxon_1 = require("luxon");
|
||||
const Orm_1 = global[Symbol.for('ioc.use')]("Adonis/Lucid/Orm");
|
||||
const Hash_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Hash"));
|
||||
const nanoid_1 = require("nanoid");
|
||||
const Role_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Role"));
|
||||
const Contact_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Contact"));
|
||||
const Course_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Course"));
|
||||
const LessonProgress_1 = __importDefault(require("./LessonProgress"));
|
||||
class User extends Orm_1.BaseModel {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
Object.defineProperty(this, "id", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "first_name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "last_name", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "login", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "email", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "password", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "contacts", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "roles", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "courses", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "likes", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "lessons_progress", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "about", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "last_login", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "createdAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "updatedAt", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
}
|
||||
get fullname() {
|
||||
return `${this.first_name} ${this.last_name}`;
|
||||
}
|
||||
static assignUui(user) {
|
||||
user.id = (0, nanoid_1.nanoid)();
|
||||
}
|
||||
static async hashPassword(user) {
|
||||
if (user.$dirty.password) {
|
||||
user.password = await Hash_1.default.make(user.password);
|
||||
}
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ isPrimary: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "first_name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "last_name", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.computed)(),
|
||||
__metadata("design:type", Object),
|
||||
__metadata("design:paramtypes", [])
|
||||
], User.prototype, "fullname", null);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "login", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)({ serializeAs: null }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasOne)(() => Contact_1.default, {
|
||||
foreignKey: 'user_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "contacts", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => Role_1.default, {
|
||||
pivotTable: 'users_roles',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "roles", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => Course_1.default, {
|
||||
pivotTable: 'users_courses',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "courses", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.manyToMany)(() => Course_1.default, {
|
||||
pivotTable: 'courses_likes',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "likes", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.hasMany)(() => LessonProgress_1.default, {
|
||||
foreignKey: 'user_id',
|
||||
}),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "lessons_progress", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.column)(),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "about", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime(),
|
||||
__metadata("design:type", Object)
|
||||
], User.prototype, "last_login", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], User.prototype, "createdAt", void 0);
|
||||
__decorate([
|
||||
Orm_1.column.dateTime({ autoCreate: true, autoUpdate: true }),
|
||||
__metadata("design:type", luxon_1.DateTime)
|
||||
], User.prototype, "updatedAt", void 0);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeCreate)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [User]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], User, "assignUui", null);
|
||||
__decorate([
|
||||
(0, Orm_1.beforeSave)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [User]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], User, "hashPassword", null);
|
||||
exports.default = User;
|
||||
//# sourceMappingURL=User.js.map
|
||||
1
build/app/Models/User.js.map
Normal file
1
build/app/Models/User.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../app/Models/User.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,iCAAiC;AACjC,gEAY+B;AAC/B,kFAAyC;AACzC,mC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GAAG,EAAE,CAAC,iBAAO,EAAE;QACrB,UAAU,EAAE,SAAS;KACtB,CAAC;;sCACsC;AAKxC;IAHC,IAAA,gBAAU,EAAC,GAAG,EAAE,CAAC,cAAI,EAAE;QACtB,UAAU,EAAE,aAAa;KAC1B,CAAC;;mCACoC;AAKtC;IAHC,IAAA,gBAAU,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE;QACxB,UAAU,EAAE,eAAe;KAC5B,CAAC;;qCACwC;AAK1C;IAHC,IAAA,gBAAU,EAAC,GAAG,EAAE,CAAC,gBAAM,EAAE;QACxB,UAAU,EAAE,eAAe;KAC5B,CAAC;;mCACsC;AAKxC;IAHC,IAAA,aAAO,EAAC,GAAG,EAAE,CAAC,wBAAc,EAAE;QAC7B,UAAU,EAAE,SAAS;KACtB,CAAC;;8CACsD;AAGxD;IADC,IAAA,YAAM,GAAE;;mCACmB;AAG5B;IADC,YAAM,CAAC,QAAQ,EAAE;;wCACiB;AAGnC;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACpB,gBAAQ;uCAAC;AAG3B;IADC,YAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;8BACtC,gBAAQ;uCAAC;AAO3B;IADC,IAAA,kBAAY,GAAE;;qCACe,IAAI;;2BAEjC;AAOD;IADC,IAAA,gBAAU,GAAE;;qCAC0B,IAAI;;8BAI1C;AA/EH,uBAgFC"}
|
||||
21
build/app/Policies/LessonPolicy.js
Normal file
21
build/app/Policies/LessonPolicy.js
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Bouncer_1 = global[Symbol.for('ioc.use')]("Adonis/Addons/Bouncer");
|
||||
const RoleHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/RoleHelper"));
|
||||
const RoleEnum_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Datatypes/Enums/RoleEnum"));
|
||||
class LessonPolicy extends Bouncer_1.BasePolicy {
|
||||
async view(user, lesson) {
|
||||
await user.load(loader => loader.load('roles').load('courses'));
|
||||
await lesson.load('course');
|
||||
const isAdminOrTeacher = RoleHelper_1.default.userContainRoles(user.roles, [RoleEnum_1.default.ADMIN, RoleEnum_1.default.TEACHER]);
|
||||
if (isAdminOrTeacher) {
|
||||
return true;
|
||||
}
|
||||
return !!user.courses.find(course => course.id === lesson.course.id);
|
||||
}
|
||||
}
|
||||
exports.default = LessonPolicy;
|
||||
//# sourceMappingURL=LessonPolicy.js.map
|
||||
1
build/app/Policies/LessonPolicy.js.map
Normal file
1
build/app/Policies/LessonPolicy.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonPolicy.js","sourceRoot":"","sources":["../../../app/Policies/LessonPolicy.ts"],"names":[],"mappings":";;;;;AAAA,yEAAwD;AAKxD,8FAAgD;AAWhD,kGAAoD;AAEpD,MAAqB,YAAa,SAAQ,oBAAU;IAC3C,KAAK,CAAC,IAAI,CAAC,IAAU,EAAE,MAAc;QAI1C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QAChE,MAAM,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE5B,MAAM,gBAAgB,GAAG,oBAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAQ,CAAC,KAAK,EAAE,kBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAErG,IAAI,gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;CACF;AAhBD,+BAgBC"}
|
||||
23
build/app/Policies/RolePolicy.js
Normal file
23
build/app/Policies/RolePolicy.js
Normal file
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Bouncer_1 = global[Symbol.for('ioc.use')]("Adonis/Addons/Bouncer");
|
||||
const RoleHelper_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Helpers/RoleHelper"));
|
||||
const RoleEnum_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Datatypes/Enums/RoleEnum"));
|
||||
class RolePolicy extends Bouncer_1.BasePolicy {
|
||||
async manage(user, roles) {
|
||||
await user.load('roles');
|
||||
const isAdmin = RoleHelper_1.default.userContainRoles(user.roles, [RoleEnum_1.default.ADMIN]);
|
||||
const isTeacher = RoleHelper_1.default.userContainRoles(user.roles, [RoleEnum_1.default.TEACHER]);
|
||||
if (isAdmin) {
|
||||
return true;
|
||||
}
|
||||
if (!(roles.includes(RoleEnum_1.default.TEACHER) || roles.includes(RoleEnum_1.default.ADMIN)) && isTeacher) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.default = RolePolicy;
|
||||
//# sourceMappingURL=RolePolicy.js.map
|
||||
1
build/app/Policies/RolePolicy.js.map
Normal file
1
build/app/Policies/RolePolicy.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"RolePolicy.js","sourceRoot":"","sources":["../../../app/Policies/RolePolicy.ts"],"names":[],"mappings":";;;;;AAAA,yEAAwD;AAUxD,8FAAgD;AAKhD,kGAAoD;AAEpD,MAAqB,UAAW,SAAQ,oBAAU;IACzC,KAAK,CAAC,MAAM,CAAC,IAAU,EAAE,KAAsB;QACpD,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzB,MAAM,OAAO,GAAG,oBAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,MAAM,SAAS,GAAG,oBAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,kBAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAE9E,IAAI,OAAO,EAAE;YACX,OAAO,IAAI,CAAC;SACb;QAKD,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,kBAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,SAAS,EAAE;YACtF,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF;AAlBD,6BAkBC"}
|
||||
50
build/app/Repositories/CategoryRepository.js
Normal file
50
build/app/Repositories/CategoryRepository.js
Normal file
@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Category_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Category"));
|
||||
class CategoryRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Category", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Category = Category_1.default;
|
||||
}
|
||||
async getAll() {
|
||||
const categories = await this.Category.query().preload('color');
|
||||
return categories;
|
||||
}
|
||||
async getById(id) {
|
||||
const category = await this.Category.query().preload('color').where('id', id).first();
|
||||
return category;
|
||||
}
|
||||
async create(data) {
|
||||
const category = await this.Category.create({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
});
|
||||
return category;
|
||||
}
|
||||
async delete(id) {
|
||||
const category = await this.Category.query().where('id', id).first();
|
||||
if (category) {
|
||||
await category.delete();
|
||||
return category;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async update(id, data) {
|
||||
const category = await this.Category.query().where('id', id).first();
|
||||
if (category) {
|
||||
await category.merge(data).save();
|
||||
return category;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.default = CategoryRepository;
|
||||
//# sourceMappingURL=CategoryRepository.js.map
|
||||
1
build/app/Repositories/CategoryRepository.js.map
Normal file
1
build/app/Repositories/CategoryRepository.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"CategoryRepository.js","sourceRoot":"","sources":["../../../app/Repositories/CategoryRepository.ts"],"names":[],"mappings":";;;;;AAGA,yFAA2C;AAQ3C,MAAqB,kBAAkB;IAGrC;QAFA;;;;;WAAkC;QAGhC,IAAI,CAAC,QAAQ,GAAG,kBAAQ,CAAC;IAC3B,CAAC;IAOM,KAAK,CAAC,MAAM;QACjB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAChE,OAAO,UAAU,CAAC;IACpB,CAAC;IAQM,KAAK,CAAC,OAAO,CAAC,EAAmB;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACtF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAQM,KAAK,CAAC,MAAM,CAAC,IAAgD;QAClE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC1C,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAQM,KAAK,CAAC,MAAM,CAAC,EAAmB;QACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAErE,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;YACxB,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IASM,KAAK,CAAC,MAAM,CAAC,EAAmB,EAAE,IAAgD;QACvF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAErE,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7ED,qCA6EC"}
|
||||
39
build/app/Repositories/ContactRepository.js
Normal file
39
build/app/Repositories/ContactRepository.js
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Contact_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Contact"));
|
||||
class ContactRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Contact", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Contact = Contact_1.default;
|
||||
}
|
||||
async getByUser(userId) {
|
||||
const contacts = await this.Contact.query().where('user_id', userId).first();
|
||||
return contacts;
|
||||
}
|
||||
async create(user, data) {
|
||||
const contacts = await this.Contact.create(data);
|
||||
await contacts.related('user').associate(user);
|
||||
await user.load('contacts');
|
||||
await user.load('roles');
|
||||
return contacts;
|
||||
}
|
||||
async update(user, data) {
|
||||
const contacts = await this.Contact.query().where('user_id', user.id).first();
|
||||
if (contacts) {
|
||||
await contacts.merge(data).save();
|
||||
await user.load('contacts');
|
||||
return contacts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.default = ContactRepository;
|
||||
//# sourceMappingURL=ContactRepository.js.map
|
||||
1
build/app/Repositories/ContactRepository.js.map
Normal file
1
build/app/Repositories/ContactRepository.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ContactRepository.js","sourceRoot":"","sources":["../../../app/Repositories/ContactRepository.ts"],"names":[],"mappings":";;;;;AAGA,uFAAyC;AASzC,MAAqB,iBAAiB;IAGpC;QAFA;;;;;WAAgC;QAG9B,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC;IACzB,CAAC;IAQM,KAAK,CAAC,SAAS,CAAC,MAAuB;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;QAC7E,OAAO,QAAQ,CAAC;IAClB,CAAC;IASM,KAAK,CAAC,MAAM,CAAC,IAAU,EAAE,IAAgD;QAC9E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAKjD,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAK/C,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEzB,OAAO,QAAQ,CAAC;IAClB,CAAC;IASM,KAAK,CAAC,MAAM,CAAC,IAAU,EAAE,IAAgD;QAC9E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAE9E,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YAClC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAE5B,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7DD,oCA6DC"}
|
||||
177
build/app/Repositories/CourseRepository.js
Normal file
177
build/app/Repositories/CourseRepository.js
Normal file
@ -0,0 +1,177 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Database_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Lucid/Database"));
|
||||
const AttachmentLite_1 = global[Symbol.for('ioc.use')]("Adonis/Addons/AttachmentLite");
|
||||
const Course_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Course"));
|
||||
class CourseRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Database", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "Course", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Database = Database_1.default;
|
||||
this.Course = Course_1.default;
|
||||
}
|
||||
async getByTeacherId(id) {
|
||||
const data = await this.Course.query()
|
||||
.preload('lessons', q => q.preload('video').preload('materials'))
|
||||
.where('teacher_id', id);
|
||||
return data;
|
||||
}
|
||||
async getByCategoryId(id) {
|
||||
const data = await this.Course.query()
|
||||
.preload('lessons', q => q.preload('video').preload('materials'))
|
||||
.where('category_id', id);
|
||||
return data;
|
||||
}
|
||||
async setStatus(id, status) {
|
||||
const data = await this.Course.query().where('id', id).update({ status }).first();
|
||||
return data;
|
||||
}
|
||||
async getAll(params) {
|
||||
const { status, category_id, limit } = params || {};
|
||||
const query = this.Course.query();
|
||||
if (category_id) {
|
||||
query.andWhereHas('category', q => q.where('id', category_id));
|
||||
}
|
||||
if (status) {
|
||||
query.andWhere('status', status);
|
||||
}
|
||||
if (limit) {
|
||||
query.limit(limit);
|
||||
}
|
||||
const courses = await query
|
||||
.preload('color')
|
||||
.preload('category')
|
||||
.withCount('students')
|
||||
.withCount('likes')
|
||||
.withCount('lessons')
|
||||
.orderBy('created_at', 'desc');
|
||||
return courses;
|
||||
}
|
||||
async getById(id) {
|
||||
const course = await this.Course.query()
|
||||
.preload('teacher')
|
||||
.preload('color')
|
||||
.preload('category', q => q.preload('color'))
|
||||
.preload('lessons', q => q.preload('color').orderBy('display_order', 'asc').withCount('materials'))
|
||||
.preload('students', q => q.preload('roles').preload('contacts'))
|
||||
.withCount('likes')
|
||||
.withCount('lessons')
|
||||
.withCount('students')
|
||||
.where('id', id)
|
||||
.first();
|
||||
return course;
|
||||
}
|
||||
async getByIdWithoutRelations(id, params) {
|
||||
const { status } = params || {};
|
||||
const query = this.Course.query().where('id', id);
|
||||
if (status) {
|
||||
query.where('status', status);
|
||||
}
|
||||
const course = await query.first();
|
||||
return course;
|
||||
}
|
||||
async getLikesCount(id) {
|
||||
const likes = await this.Database.query().from('courses_likes').where('course_id', id).count('* as count');
|
||||
return likes[0].count;
|
||||
}
|
||||
async getTeacher(id) {
|
||||
const course = await this.Course.query()
|
||||
.select('teacher_id')
|
||||
.preload('teacher', user => user.preload('contacts').preload('roles'))
|
||||
.where('id', id)
|
||||
.first();
|
||||
return course && course.teacher;
|
||||
}
|
||||
async getCategory(id) {
|
||||
const course = await this.Course.query().select('category_id').preload('category').where('id', id).first();
|
||||
return course && course.category;
|
||||
}
|
||||
async getLessons(id, userId) {
|
||||
const course = await this.Course.query()
|
||||
.select('id')
|
||||
.preload('lessons', q => q
|
||||
.preload('progress', p => p.where('user_id', userId))
|
||||
.preload('color')
|
||||
.orderBy('display_order', 'asc'))
|
||||
.where('id', id)
|
||||
.first();
|
||||
return course && course.lessons;
|
||||
}
|
||||
async getStudents(id) {
|
||||
const course = await this.Course.query().preload('students').where('id', id).first();
|
||||
return course && course.students;
|
||||
}
|
||||
async getStudentsCount(id) {
|
||||
const students = await this.Database.query().from('users_courses').where('course_id', id).count('* as count');
|
||||
return students[0].count;
|
||||
}
|
||||
async create(data) {
|
||||
const course = new this.Course();
|
||||
course.title = data.title;
|
||||
course.description = data.description;
|
||||
course.education_description = data.education_description;
|
||||
course.status = data.status;
|
||||
course.teacher_id = data.teacher_id;
|
||||
course.category_id = data.category_id;
|
||||
if (data.image) {
|
||||
course.image = AttachmentLite_1.Attachment.fromFile(data.image);
|
||||
}
|
||||
await course.save();
|
||||
return course;
|
||||
}
|
||||
async delete(id) {
|
||||
const course = await this.Course.query()
|
||||
.preload('category')
|
||||
.preload('lessons', q => q.preload('video').preload('materials'))
|
||||
.withCount('students')
|
||||
.withCount('likes')
|
||||
.withCount('lessons')
|
||||
.where('id', id)
|
||||
.first();
|
||||
if (course) {
|
||||
await course.delete();
|
||||
return course;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async update(id, data) {
|
||||
const course = await this.Course.query()
|
||||
.preload('teacher')
|
||||
.preload('category')
|
||||
.preload('lessons')
|
||||
.where('id', id)
|
||||
.first();
|
||||
if (course) {
|
||||
course.merge({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
education_description: data.education_description,
|
||||
teacher_id: data.teacher_id,
|
||||
category_id: data.category_id,
|
||||
});
|
||||
if (data.image) {
|
||||
course.image = AttachmentLite_1.Attachment.fromFile(data.image);
|
||||
}
|
||||
await course.load('category');
|
||||
await course.load('teacher');
|
||||
await course.save();
|
||||
return course;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.default = CourseRepository;
|
||||
//# sourceMappingURL=CourseRepository.js.map
|
||||
1
build/app/Repositories/CourseRepository.js.map
Normal file
1
build/app/Repositories/CourseRepository.js.map
Normal file
File diff suppressed because one or more lines are too long
46
build/app/Repositories/ImageRepository.js
Normal file
46
build/app/Repositories/ImageRepository.js
Normal file
@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Drive_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Drive"));
|
||||
const Image_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Image"));
|
||||
class ImageRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Image", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Image = Image_1.default;
|
||||
}
|
||||
async getById(id) {
|
||||
const image = await this.Image.query().where('id', id).first();
|
||||
return image;
|
||||
}
|
||||
async getByFileName(name) {
|
||||
const image = await this.Image.query().where('name', name).first();
|
||||
return image;
|
||||
}
|
||||
async getAll() {
|
||||
const images = await this.Image.query();
|
||||
return images;
|
||||
}
|
||||
async create({ file, location }) {
|
||||
await file.moveToDisk(location);
|
||||
const image = await this.Image.create({ name: file.fileName, path: file.filePath, ext: file.extname });
|
||||
return image;
|
||||
}
|
||||
async delete(id) {
|
||||
const image = await this.Image.query().where('id', id).first();
|
||||
if (image) {
|
||||
await Drive_1.default.delete(image.path);
|
||||
await image.delete();
|
||||
return image;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.default = ImageRepository;
|
||||
//# sourceMappingURL=ImageRepository.js.map
|
||||
1
build/app/Repositories/ImageRepository.js.map
Normal file
1
build/app/Repositories/ImageRepository.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"ImageRepository.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,KAAK,EAAE,CAAC;QAE/D,IAAI,KAAK,EAAE;YAIT,MAAM,eAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAK/B,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;SACd;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AArDD,kCAqDC"}
|
||||
30
build/app/Repositories/LessonProgressRepository.js
Normal file
30
build/app/Repositories/LessonProgressRepository.js
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const LessonProgress_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/LessonProgress"));
|
||||
class LessonProgressRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "LessonProgress", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.LessonProgress = LessonProgress_1.default;
|
||||
}
|
||||
async get(user_id, lesson_id) {
|
||||
const progress = await this.LessonProgress.query()
|
||||
.where('user_id', user_id)
|
||||
.andWhere('lesson_id', lesson_id)
|
||||
.first();
|
||||
return progress;
|
||||
}
|
||||
async create(data) {
|
||||
const progress = await this.LessonProgress.create(data);
|
||||
return progress;
|
||||
}
|
||||
}
|
||||
exports.default = LessonProgressRepository;
|
||||
//# sourceMappingURL=LessonProgressRepository.js.map
|
||||
1
build/app/Repositories/LessonProgressRepository.js.map
Normal file
1
build/app/Repositories/LessonProgressRepository.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"LessonProgressRepository.js","sourceRoot":"","sources":["../../../app/Repositories/LessonProgressRepository.ts"],"names":[],"mappings":";;;;;AAAA,qGAAuD;AAEvD,MAAqB,wBAAwB;IAG3C;QAFA;;;;;WAA8C;QAG5C,IAAI,CAAC,cAAc,GAAG,wBAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,SAAiB;QACjD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE;aAC/C,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;aACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,CAAC;aAChC,KAAK,EAAE,CAAC;QAEX,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,IAAiE;QACnF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AApBD,2CAoBC"}
|
||||
175
build/app/Repositories/LessonRepository.js
Normal file
175
build/app/Repositories/LessonRepository.js
Normal file
@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Drive_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Drive"));
|
||||
const Helpers_1 = global[Symbol.for('ioc.use')]("Adonis/Core/Helpers");
|
||||
const Lesson_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Lesson"));
|
||||
const LessonMaterial_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/LessonMaterial"));
|
||||
const LessonVideo_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/LessonVideo"));
|
||||
class LessonRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Lesson", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "LessonMaterial", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "LessonVideo", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
Object.defineProperty(this, "Drive", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Lesson = Lesson_1.default;
|
||||
this.LessonMaterial = LessonMaterial_1.default;
|
||||
this.LessonVideo = LessonVideo_1.default;
|
||||
this.Drive = Drive_1.default;
|
||||
}
|
||||
async getAll() {
|
||||
const lessons = await this.Lesson.query();
|
||||
return lessons;
|
||||
}
|
||||
async getById(id) {
|
||||
const lesson = await this.Lesson.query().where('id', id).preload('color').withCount('materials').first();
|
||||
return lesson;
|
||||
}
|
||||
async getContentById(id) {
|
||||
const lesson = await this.Lesson.query().preload('content').where('id', id).first();
|
||||
return lesson && lesson.content;
|
||||
}
|
||||
async getMaterialFileByName(fileName) {
|
||||
const material = await this.LessonMaterial.query().where('name', fileName).first();
|
||||
return material;
|
||||
}
|
||||
async getMaterialFileById(id) {
|
||||
const material = await this.LessonMaterial.query().where('id', id).first();
|
||||
return material;
|
||||
}
|
||||
async getVideoFileByName(fileName) {
|
||||
const video = await this.LessonVideo.query().where('name', fileName).first();
|
||||
return video;
|
||||
}
|
||||
async create(course, data) {
|
||||
await course.loadCount('lessons');
|
||||
const lesson = await this.Lesson.create({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
duration: data.duration.toFormat('HH:mm:ss'),
|
||||
display_order: Number.parseInt(course.$extras.lessons_count, 10) + 1,
|
||||
course_id: course.id,
|
||||
linked_video_url: !data.video ? data.linked_video_url : null,
|
||||
});
|
||||
await lesson.related('content').create({ body: '' });
|
||||
if (data.video) {
|
||||
await this.createVideo(lesson, data.video);
|
||||
}
|
||||
if (data.materials) {
|
||||
await this.createMaterials(lesson, data.materials);
|
||||
}
|
||||
await lesson.load(loader => loader.load('content').load('materials').load('video').load('progress'));
|
||||
return lesson;
|
||||
}
|
||||
async update(id, data) {
|
||||
const lesson = await this.Lesson.query().preload('video').preload('color').where('id', id).first();
|
||||
if (lesson) {
|
||||
lesson.merge({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
course_id: data.course_id,
|
||||
...(data.duration && { duration: data.duration.toFormat('HH:mm:ss') }),
|
||||
});
|
||||
if (data.linked_video_url && !data.video) {
|
||||
if (lesson.video) {
|
||||
await this.Drive.delete(`videos/${lesson.video.name}`);
|
||||
}
|
||||
await lesson.related('video').query().delete();
|
||||
lesson.merge({ linked_video_url: data.linked_video_url });
|
||||
}
|
||||
if (data.video) {
|
||||
if (lesson.video) {
|
||||
await this.Drive.delete(`videos/${lesson.video.name}`);
|
||||
}
|
||||
await lesson.related('video').query().delete();
|
||||
await this.createVideo(lesson, data.video);
|
||||
lesson.merge({ linked_video_url: null });
|
||||
}
|
||||
if (data.materials && data.materials !== null) {
|
||||
await this.deleteMaterials(lesson);
|
||||
await this.createMaterials(lesson, data.materials);
|
||||
}
|
||||
else if (data.materials === null)
|
||||
await this.deleteMaterials(lesson);
|
||||
await lesson.load(loader => loader.load('video').load('materials'));
|
||||
await lesson.save();
|
||||
return lesson;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async delete(id) {
|
||||
const lesson = await this.Lesson.query().where('id', id).preload('video').preload('color').first();
|
||||
if (lesson) {
|
||||
if (lesson.video) {
|
||||
await this.Drive.delete(`videos/${lesson.video.name}`);
|
||||
}
|
||||
await this.deleteMaterials(lesson);
|
||||
await lesson.delete();
|
||||
return lesson;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async createVideo(lesson, video) {
|
||||
const videoName = `${(0, Helpers_1.cuid)()}.${video.extname}`;
|
||||
await video.moveToDisk('videos', { name: videoName });
|
||||
if (video.state === 'moved') {
|
||||
await lesson.related('video').create({
|
||||
name: videoName,
|
||||
clientName: video.clientName,
|
||||
ext: video.extname,
|
||||
size: video.size,
|
||||
url: `/video/${videoName}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
async createMaterials(lesson, materials) {
|
||||
const files = await Promise.all(materials.map(async (file) => {
|
||||
const name = `${(0, Helpers_1.cuid)()}.${file.extname}`;
|
||||
await file.moveToDisk('materials', { name });
|
||||
return { file, name };
|
||||
}));
|
||||
const promises = await Promise.all(files.map(async ({ file, name }) => {
|
||||
if (file.state === 'moved' && file.fileName && file.extname) {
|
||||
const material = new LessonMaterial_1.default();
|
||||
material.name = name;
|
||||
material.size = file.size;
|
||||
material.clientName = file.clientName;
|
||||
material.ext = file.extname;
|
||||
return material;
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
await lesson.related('materials').createMany(promises.filter((l) => l !== null));
|
||||
}
|
||||
async deleteMaterials(lesson) {
|
||||
await lesson.load('materials');
|
||||
await Promise.all(lesson.materials.map(async (material) => {
|
||||
await this.Drive.delete(`materials/${material.name}`);
|
||||
await material.delete();
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.default = LessonRepository;
|
||||
//# sourceMappingURL=LessonRepository.js.map
|
||||
1
build/app/Repositories/LessonRepository.js.map
Normal file
1
build/app/Repositories/LessonRepository.js.map
Normal file
File diff suppressed because one or more lines are too long
32
build/app/Repositories/RoleRepository.js
Normal file
32
build/app/Repositories/RoleRepository.js
Normal file
@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Role_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/Role"));
|
||||
class RoleRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "Role", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.Role = Role_1.default;
|
||||
}
|
||||
async getAll(params) {
|
||||
const { roles } = params || {};
|
||||
const query = this.Role.query();
|
||||
if (roles) {
|
||||
query.whereIn('slug', roles);
|
||||
}
|
||||
const data = await query;
|
||||
return data;
|
||||
}
|
||||
async getBySlug(slug) {
|
||||
const role = await this.Role.query().where('slug', slug).first();
|
||||
return role;
|
||||
}
|
||||
}
|
||||
exports.default = RoleRepository;
|
||||
//# sourceMappingURL=RoleRepository.js.map
|
||||
1
build/app/Repositories/RoleRepository.js.map
Normal file
1
build/app/Repositories/RoleRepository.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"RoleRepository.js","sourceRoot":"","sources":["../../../app/Repositories/RoleRepository.ts"],"names":[],"mappings":";;;;;AAGA,iFAAmC;AAEnC,MAAqB,cAAc;IAGjC;QAFA;;;;;WAA0B;QAGxB,IAAI,CAAC,IAAI,GAAG,cAAI,CAAC;IACnB,CAAC;IAQM,KAAK,CAAC,MAAM,CAAC,MAAY;QAC9B,MAAM,EAAE,KAAK,EAAE,GAAQ,MAAM,IAAI,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAEhC,IAAI,KAAK,EAAE;YACT,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC9B;QAED,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAQM,KAAK,CAAC,SAAS,CAAC,IAAY;QACjC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAnCD,iCAmCC"}
|
||||
125
build/app/Repositories/UserRepository.js
Normal file
125
build/app/Repositories/UserRepository.js
Normal file
@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const Hash_1 = __importDefault(global[Symbol.for('ioc.use')]("Adonis/Core/Hash"));
|
||||
const luxon_1 = require("luxon");
|
||||
const User_1 = __importDefault(global[Symbol.for('ioc.use')]("App/Models/User"));
|
||||
class UserRepository {
|
||||
constructor() {
|
||||
Object.defineProperty(this, "User", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.User = User_1.default;
|
||||
}
|
||||
async getById(id) {
|
||||
const data = await this.User.query().preload('contacts').preload('roles').where('id', id).first();
|
||||
return data;
|
||||
}
|
||||
async getByIds(ids) {
|
||||
const data = await this.User.query().preload('contacts').preload('roles').whereIn('id', ids);
|
||||
return data;
|
||||
}
|
||||
async getByColumn(column, value) {
|
||||
const data = await this.User.query().preload('contacts').preload('roles').where(column, value).first();
|
||||
return data;
|
||||
}
|
||||
async getAllByRole(role) {
|
||||
const data = await this.User.query()
|
||||
.preload('contacts')
|
||||
.preload('roles')
|
||||
.whereHas('roles', q => q.where('slug', role));
|
||||
return data;
|
||||
}
|
||||
async getAll(params) {
|
||||
const { search, email, login, first_name, last_name, role, page, limit } = params || {};
|
||||
const query = this.User.query();
|
||||
if (email) {
|
||||
query.where('email', 'like', `%${email}%`);
|
||||
}
|
||||
if (login) {
|
||||
query.where('login', 'like', `%${login}%`);
|
||||
}
|
||||
if (first_name) {
|
||||
query.where('first_name', 'like', `%${first_name}%`);
|
||||
}
|
||||
if (last_name) {
|
||||
query.where('last_name', 'like', `%${last_name}%`);
|
||||
}
|
||||
if (search) {
|
||||
query
|
||||
.orWhere('first_name', 'ilike', `%${search}%`)
|
||||
.orWhere('last_name', 'ilike', `%${search}%`)
|
||||
.orWhereRaw(`CONCAT(first_name, ' ', last_name) ilike ?`, [search])
|
||||
.orWhere('email', 'like', `${search}`)
|
||||
.orWhere('id', 'like', `${search}`);
|
||||
}
|
||||
if (role) {
|
||||
query.whereHas('roles', q => q.where('slug', role));
|
||||
}
|
||||
query.preload('contacts').preload('roles').orderBy('created_at', 'desc');
|
||||
if (limit && page) {
|
||||
const data = await query.paginate(page, limit);
|
||||
return data.toJSON();
|
||||
}
|
||||
const data = await query;
|
||||
return data;
|
||||
}
|
||||
async create(data) {
|
||||
const user = await this.User.create({
|
||||
first_name: data.first_name.charAt(0).toUpperCase() + data.first_name.substr(1),
|
||||
last_name: data.last_name.charAt(0).toUpperCase() + data.last_name.substr(1),
|
||||
login: data.login,
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
});
|
||||
await user.load('contacts');
|
||||
await user.load('roles');
|
||||
return user;
|
||||
}
|
||||
async update(id, data) {
|
||||
const user = await this.User.query().preload('contacts').preload('roles').where('id', id).first();
|
||||
const { role, ...updatedFields } = data;
|
||||
if (user) {
|
||||
await user.merge(updatedFields).save();
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async updateLastLogin(id) {
|
||||
await this.User.query().where('id', id).update({ last_login: luxon_1.DateTime.now() }).first();
|
||||
}
|
||||
async updateInfo(id, data) {
|
||||
const user = await this.User.query().preload('contacts').preload('roles').where('id', id).first();
|
||||
const { about } = data;
|
||||
if (user) {
|
||||
await user.merge({ about }).save();
|
||||
return { about: user.about };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async updateRoles(user, roles) {
|
||||
await user.related('roles').detach();
|
||||
await user.related('roles').attach(roles.map(role => role.id));
|
||||
await user.load('roles');
|
||||
return user.roles.map(role => role);
|
||||
}
|
||||
async delete(id) {
|
||||
const user = await this.User.query().preload('contacts').preload('roles').where('id', id).first();
|
||||
if (user) {
|
||||
await user.delete();
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async updatePassword(password, id) {
|
||||
const hashedPass = await Hash_1.default.make(password);
|
||||
return this.User.query().where('id', id).update({ password: hashedPass }).first();
|
||||
}
|
||||
}
|
||||
exports.default = UserRepository;
|
||||
//# sourceMappingURL=UserRepository.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user