From 5716959feb02a350b963e2a6e0d2849275690fa8 Mon Sep 17 00:00:00 2001 From: Zakhar Molchanov Date: Sun, 23 Jun 2024 18:47:39 +0500 Subject: [PATCH] feat(backend): change orm --- backend/src/entity/Course.ts | 1 - backend/src/entity/CoursesModules.ts | 6 ------ backend/src/entity/CoursesStep.ts | 10 ---------- backend/src/entity/CoursesViewers.ts | 7 ------- backend/src/entity/User.ts | 8 -------- backend/src/entity/UsersActivity.ts | 30 ---------------------------- backend/src/entity/UsersRoles.ts | 21 ------------------- 7 files changed, 83 deletions(-) delete mode 100644 backend/src/entity/UsersActivity.ts delete mode 100644 backend/src/entity/UsersRoles.ts diff --git a/backend/src/entity/Course.ts b/backend/src/entity/Course.ts index ac59792..2b16f26 100644 --- a/backend/src/entity/Course.ts +++ b/backend/src/entity/Course.ts @@ -7,7 +7,6 @@ import { ManyToOne, } from "typeorm"; import { CoursesModule } from "./CoursesModules"; -import { CoursesStep } from "./CoursesStep"; import { CoursesViewer } from "./CoursesViewers"; @Entity("courses") diff --git a/backend/src/entity/CoursesModules.ts b/backend/src/entity/CoursesModules.ts index e0d86a1..5129979 100644 --- a/backend/src/entity/CoursesModules.ts +++ b/backend/src/entity/CoursesModules.ts @@ -23,12 +23,6 @@ export class CoursesModule extends BaseEntity { @Column("text") description: string | undefined; - @Column({ default: false, type: "boolean" }) - isVisible: boolean | undefined; - - @Column({ type: "integer" }) - moduleNumber: number | undefined; - @ManyToOne(() => Course, (course) => course.modules) course: Course; diff --git a/backend/src/entity/CoursesStep.ts b/backend/src/entity/CoursesStep.ts index 6d24185..f79038c 100644 --- a/backend/src/entity/CoursesStep.ts +++ b/backend/src/entity/CoursesStep.ts @@ -7,7 +7,6 @@ import { PrimaryGeneratedColumn, } from "typeorm"; import { CoursesModule } from "./CoursesModules"; -import { UsersActivity } from "./UsersActivity"; @Entity("courses_steps") export class CoursesStep extends BaseEntity { @@ -26,21 +25,12 @@ export class CoursesStep extends BaseEntity { @Column({ nullable: true, type: "text" }) youtubeVideoLink: string | undefined; - @Column({ default: false, type: "boolean" }) - isVisible: boolean | undefined; - - @Column({ type: "integer" }) - stepNumber: number | undefined; - @Column({ default: -1, type: "integer" }) deadline: number | undefined; @Column({ default: 1, type: "integer" }) ratingAward: number | undefined; - @OneToMany(() => UsersActivity, (activity) => activity.step) - activities: UsersActivity[]; - @ManyToOne(() => CoursesModule, (module) => module.steps) module: CoursesModule; } diff --git a/backend/src/entity/CoursesViewers.ts b/backend/src/entity/CoursesViewers.ts index 51de0d5..aa44757 100644 --- a/backend/src/entity/CoursesViewers.ts +++ b/backend/src/entity/CoursesViewers.ts @@ -5,7 +5,6 @@ import { OneToMany, PrimaryGeneratedColumn, } from "typeorm"; -import { UsersRole } from "./UsersRoles"; import { Course } from "./Course"; import { User } from "./User"; @@ -20,12 +19,6 @@ export class CoursesViewer extends BaseEntity { @Column({ type: "uuid" }) courseId: "uuid" | undefined; - @Column({ type: "uuid" }) - roleId: "uuid" | undefined; - - @OneToMany(() => UsersRole, (role) => role.viewer) - roles: UsersRole[]; - @OneToMany(() => User, (user) => user.viewers) user: User[]; diff --git a/backend/src/entity/User.ts b/backend/src/entity/User.ts index dd71e34..e008b65 100644 --- a/backend/src/entity/User.ts +++ b/backend/src/entity/User.ts @@ -2,13 +2,8 @@ import { Column, Entity, ManyToOne, - OneToMany, PrimaryGeneratedColumn, } from "typeorm"; -import { UUID } from "crypto"; -import { UsersActivity } from "./UsersActivity"; -import { UsersRole } from "./UsersRoles"; -import { Course } from "./Course"; import { CoursesViewer } from "./CoursesViewers"; @Entity("users") @@ -49,9 +44,6 @@ export class User { @Column({ type: "text", nullable: true }) healthIssues: string; - @OneToMany(() => UsersActivity, (activity) => activity.user) - activities: UsersActivity[]; - @ManyToOne(() => CoursesViewer, (viewer) => viewer.user) viewers: CoursesViewer; } diff --git a/backend/src/entity/UsersActivity.ts b/backend/src/entity/UsersActivity.ts deleted file mode 100644 index 91892bf..0000000 --- a/backend/src/entity/UsersActivity.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - BaseEntity, - Column, - Entity, - ManyToOne, - PrimaryGeneratedColumn, -} from "typeorm"; -import { User } from "./User"; -import { CoursesStep } from "./CoursesStep"; - -@Entity("users_activity") -export class UsersActivity extends BaseEntity { - @PrimaryGeneratedColumn("uuid") - activityId: string | undefined; - - @Column({ type: "uuid" }) - userId: string | undefined; - - @Column({ type: "uuid" }) - stepId: string | undefined; - - @Column({ type: "timestamp with time zone" }) - timestamp: Date | undefined; - - @ManyToOne(() => User, (user) => user.activities) - user: User; - - @ManyToOne(() => CoursesStep, (step) => step.activities) - step: CoursesStep; -} diff --git a/backend/src/entity/UsersRoles.ts b/backend/src/entity/UsersRoles.ts deleted file mode 100644 index 9ace5fb..0000000 --- a/backend/src/entity/UsersRoles.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { - BaseEntity, - Column, - Entity, - ManyToOne, - PrimaryGeneratedColumn, -} from "typeorm"; -import { User } from "./User"; -import { CoursesViewer } from "./CoursesViewers"; - -@Entity("users_roles") -export class UsersRole extends BaseEntity { - @PrimaryGeneratedColumn("uuid") - roleId: "uuid" | undefined; - - @Column({ unique: true, type: "varchar", length: 50 }) - name: string | undefined; - - @ManyToOne(() => CoursesViewer, (viewer) => viewer.roles) - viewer: CoursesViewer; -}