Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/src/db/entities/AbsenceType.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class AbsenceType implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down
7 changes: 6 additions & 1 deletion server/src/db/entities/AttReport.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { User } from './User.entity';
import { KlassType } from './KlassType.entity';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsNumber, MaxLength, IsDate, IsPositive } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, MaxLength, IsDate, IsPositive, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { fillDefaultReportDateValue } from '@shared/utils/entity/deafultValues.util';
import { DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer';
Expand Down Expand Up @@ -99,11 +99,15 @@ export class AttReport implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

@ValidateIf((attReport: AttReport) => !Boolean(attReport.studentReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'student_tz', length: 10, nullable: true })
studentTz: string;

Expand All @@ -117,6 +121,7 @@ export class AttReport implements IHasUserId {

@ValidateIf((attReport: AttReport) => !Boolean(attReport.teacherReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', length: 10, nullable: true })
teacherId: string;

Expand Down
7 changes: 6 additions & 1 deletion server/src/db/entities/Grade.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { KlassType } from './KlassType.entity';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { fillDefaultReportDateValue } from '@shared/utils/entity/deafultValues.util';
import { IsOptional, ValidateIf } from 'class-validator';
import { IsDate, IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsDate, IsNotEmpty, IsNumber, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { CrudValidationGroups } from '@dataui/crud';
import { StudentBaseKlass } from '../view-entities/StudentBaseKlass.entity';
import { DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer';
Expand Down Expand Up @@ -91,11 +91,15 @@ export class Grade implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

@ValidateIf((grade: Grade) => !Boolean(grade.studentReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'student_tz', length: 10, nullable: true })
studentTz: string;

Expand All @@ -107,6 +111,7 @@ export class Grade implements IHasUserId {

@ValidateIf((grade: Grade) => !Boolean(grade.teacherReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', length: 10, nullable: true })
teacherId: string;

Expand Down
6 changes: 5 additions & 1 deletion server/src/db/entities/Klass.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { User } from './User.entity';
import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity/foreignKey.util';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsNumber, IsUniqueCombination, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, IsUniqueCombination, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { NumberType, StringType } from '@shared/utils/entity/class-transformer';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { CreatedAtColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util';
Expand Down Expand Up @@ -64,6 +64,9 @@ export class Klass implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down Expand Up @@ -104,6 +107,7 @@ export class Klass implements IHasUserId {
@Index('klasses_klass_type_reference_id_idx')
klassTypeReferenceId: number;

@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', nullable: true, length: 10 })
teacherId: string | null;

Expand Down
3 changes: 2 additions & 1 deletion server/src/db/entities/KlassType.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IHasUserId } from '@shared/base-entity/interface';
import { User } from 'src/db/entities/User.entity';
import { IsOptional } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity/foreignKey.util';
import { Teacher } from './Teacher.entity';
import { NumberType, StringType } from '@shared/utils/entity/class-transformer';
Expand Down Expand Up @@ -73,6 +73,7 @@ export class KlassType implements IHasUserId {
@Index('klass_types_klassTypeEnum_idx')
klassTypeEnum: KlassTypeEnum;

@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', length: 10, nullable: true })
teacherId: string;

Expand Down
6 changes: 5 additions & 1 deletion server/src/db/entities/KnownAbsence.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity
import { Student } from './Student.entity';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsBoolean, IsDate, IsNotEmpty, IsNumber, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { fillDefaultReportDateValue } from '@shared/utils/entity/deafultValues.util';
import { Klass } from './Klass.entity';
Expand Down Expand Up @@ -87,11 +87,15 @@ export class KnownAbsence implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

@ValidateIf((attReport: KnownAbsence) => !Boolean(attReport.studentReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'student_tz', length: 10, nullable: true })
studentTz: string;

Expand Down
5 changes: 5 additions & 0 deletions server/src/db/entities/Lesson.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
IsUniqueCombination,
MaxLength,
Min,
IsDigitsOnly,
} from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { cleanDateFields } from '@shared/utils/entity/deafultValues.util';
Expand Down Expand Up @@ -83,6 +84,9 @@ export class Lesson implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down Expand Up @@ -125,6 +129,7 @@ export class Lesson implements IHasUserId {
})
klassReferenceIdsJson: string;

@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', length: 10, nullable: true })
teacherId: string;

Expand Down
6 changes: 5 additions & 1 deletion server/src/db/entities/LessonSchedule.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { User } from './User.entity';
import { findOneAndAssignReferenceId, getDataSource } from '@shared/utils/entity/foreignKey.util';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsNumber, MaxLength, IsDate } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, MaxLength, IsDate, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { cleanDateFields, cleanTimeFields } from '@shared/utils/entity/deafultValues.util';
import { DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer';
Expand Down Expand Up @@ -74,6 +74,9 @@ export class LessonSchedule implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down Expand Up @@ -138,6 +141,7 @@ export class LessonSchedule implements IHasUserId {

@ValidateIf((lessonSchedule: LessonSchedule) => !Boolean(lessonSchedule.teacherReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@IsDigitsOnly(10, { always: true })
@Column('varchar', { name: 'teacher_id', length: 10, nullable: true })
teacherId: string;

Expand Down
11 changes: 10 additions & 1 deletion server/src/db/entities/ReportGroup.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import { Teacher } from './Teacher.entity';
import { Lesson } from './Lesson.entity';
import { Klass } from './Klass.entity';
import { ReportGroupSession } from './ReportGroupSession.entity';
import { IsOptional } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { StringType, NumberType } from '@shared/utils/entity/class-transformer';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { LongTextColumn } from '@shared/utils/entity/column-types.util';
Expand Down Expand Up @@ -53,22 +54,30 @@ export class ReportGroup implements IHasUserId {
@LongTextColumn({ nullable: true })
signatureData: string; // ONE signature for entire group

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
@Index('report_groups_teacher_reference_id_idx')
teacherReferenceId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
@Index('report_groups_lesson_reference_id_idx')
lessonReferenceId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
@Index('report_groups_klass_reference_id_idx')
klassReferenceId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down
5 changes: 4 additions & 1 deletion server/src/db/entities/ReportGroupSession.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import {
import { ReportGroup } from './ReportGroup.entity';
import { AttReport } from './AttReport.entity';
import { Grade } from './Grade.entity';
import { IsOptional } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsDate } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsDate, IsNumber } from '@shared/utils/validation/class-validator-he';
import { StringType, NumberType, DateType } from '@shared/utils/entity/class-transformer';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { cleanDateFields, cleanTimeFields } from '@shared/utils/entity/deafultValues.util';
Expand All @@ -37,7 +38,9 @@ export class ReportGroupSession {
@Column()
userId: number;

@IsOptional({ groups: [CrudValidationGroups.UPDATE] })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@Column()
reportGroupId: number;
Comment thread
buzz-code marked this conversation as resolved.
Resolved
Expand Down
7 changes: 5 additions & 2 deletions server/src/db/entities/ReportMonth.entity.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CrudValidationGroups } from '@dataui/crud';
import { IsOptional } from 'class-validator';
import { BeforeInsert, BeforeUpdate, Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
import { IsDate, IsNotEmpty, IsUniqueDateRange, MaxLength } from '@shared/utils/validation/class-validator-he';
import { DateType, StringType } from '@shared/utils/entity/class-transformer';
import { IsDate, IsNotEmpty, IsNumber, IsUniqueDateRange, MaxLength } from '@shared/utils/validation/class-validator-he';
import { DateType, NumberType, StringType } from '@shared/utils/entity/class-transformer';
import { CreatedAtColumn, DateColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';

Expand Down Expand Up @@ -61,6 +61,9 @@ export class ReportMonth {
@Column({ default: ReportMonthSemester.fullYear })
semester: ReportMonthSemester;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down
4 changes: 3 additions & 1 deletion server/src/db/entities/Student.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IHasUserId } from '@shared/base-entity/interface';
import { User } from 'src/db/entities/User.entity';
import { IsOptional } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsUniqueCombination, MaxLength, IsBoolean } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsUniqueCombination, MaxLength, IsBoolean, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { StringType, BooleanType } from '@shared/utils/entity/class-transformer';
import { CreatedAtColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util';

Expand All @@ -23,6 +23,7 @@ export class Student implements IHasUserId {

@IsOptional({ groups: [CrudValidationGroups.UPDATE] })
@MaxLength(10, { always: true })
@IsDigitsOnly(undefined, { always: true })
@StringType
@IsUniqueCombination(['userId'], [Student, User], { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
Expand All @@ -31,6 +32,7 @@ export class Student implements IHasUserId {

@IsOptional({ always: true })
@MaxLength(20, { always: true })
@IsDigitsOnly(undefined, { always: true })
@StringType
@IsUniqueCombination(['userId'], [Student, User], { always: true })
@Column('varchar', { name: 'student_number', nullable: true, length: 20 })
Expand Down
3 changes: 2 additions & 1 deletion server/src/db/entities/StudentKlass.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { KlassType } from './KlassType.entity';
import { Teacher } from './Teacher.entity';
import { IsOptional, ValidateIf } from 'class-validator';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsNumber, MaxLength } from '@shared/utils/validation/class-validator-he';
import { IsNotEmpty, IsNumber, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { fillDefaultYearValue } from '@shared/utils/entity/year.util';
import { MaxCountByUserLimit } from '@shared/utils/validation/max-count-by-user-limit';
import { StudentByYear } from '../view-entities/StudentByYear.entity';
Expand Down Expand Up @@ -107,6 +107,7 @@ export class StudentKlass implements IHasUserId {
@ValidateIf((attReport: StudentKlass) => !Boolean(attReport.studentReferenceId), { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@MaxLength(10, { always: true })
@IsDigitsOnly(undefined, { always: true })
@StringType
@Column('varchar', { name: 'student_tz', length: 10, nullable: true })
studentTz: string;
Expand Down
9 changes: 7 additions & 2 deletions server/src/db/entities/Teacher.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { User } from 'src/db/entities/User.entity';
import { IsArray, IsEmail, IsOptional } from 'class-validator';
import { Transform } from 'class-transformer';
import { CrudValidationGroups } from '@dataui/crud';
import { IsNotEmpty, IsUniqueCombination, MaxLength } from '@shared/utils/validation/class-validator-he';
import { StringType } from '@shared/utils/entity/class-transformer';
import { IsNotEmpty, IsNumber, IsUniqueCombination, MaxLength, IsDigitsOnly } from '@shared/utils/validation/class-validator-he';
import { NumberType, StringType } from '@shared/utils/entity/class-transformer';
import { CreatedAtColumn, UpdatedAtColumn } from '@shared/utils/entity/column-types.util';

@Index('teachers_users_idx', ['userId'], {})
Expand All @@ -29,12 +29,16 @@ export class Teacher implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

@IsOptional({ groups: [CrudValidationGroups.UPDATE] })
@StringType
@MaxLength(10, { always: true })
@IsDigitsOnly(undefined, { always: true })
@IsUniqueCombination(['userId'], [Teacher, User], { always: true })
@IsNotEmpty({ groups: [CrudValidationGroups.CREATE] })
@Column('varchar', { name: 'tz', length: 10 })
Expand Down Expand Up @@ -62,6 +66,7 @@ export class Teacher implements IHasUserId {
@IsOptional({ always: true })
@StringType
@MaxLength(10, { always: true })
@IsDigitsOnly(undefined, { always: true })
@IsUniqueCombination(['userId'], [Teacher, User], { always: true })
@Column('varchar', { name: 'number', nullable: true, length: 10 })
number: string | null;
Expand Down
3 changes: 3 additions & 0 deletions server/src/db/entities/Transportation.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export class Transportation implements IHasUserId {
@Column('int', { name: 'user_id' })
userId: number;

@IsOptional({ always: true })
@NumberType
@IsNumber({ maxDecimalPlaces: 0 }, { always: true })
@Column({ nullable: true })
year: number;

Expand Down
Loading