@kipicore/dbcore 1.1.30 → 1.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/models/psql/SubCategoriesModel.d.ts +1 -0
- package/dist/models/psql/SubCategoriesModel.js +60 -63
- package/dist/models/psql/academicCalendarModel.d.ts +2 -1
- package/dist/models/psql/academicCalendarModel.js +41 -53
- package/dist/models/psql/accountHasReceiptDetailsModel.d.ts +6 -5
- package/dist/models/psql/accountHasReceiptDetailsModel.js +47 -68
- package/dist/models/psql/announcementModel.d.ts +10 -8
- package/dist/models/psql/announcementModel.js +90 -109
- package/dist/models/psql/areaModel.d.ts +5 -1
- package/dist/models/psql/areaModel.js +13 -12
- package/dist/models/psql/bankAccountDetailsModel.d.ts +6 -5
- package/dist/models/psql/bankAccountDetailsModel.js +25 -37
- package/dist/models/psql/bannerModel.d.ts +18 -18
- package/dist/models/psql/bannerModel.js +53 -81
- package/dist/models/psql/batchModel.d.ts +3 -1
- package/dist/models/psql/batchModel.js +77 -135
- package/dist/models/psql/batchSubjectBookAssessmentModel.d.ts +2 -1
- package/dist/models/psql/batchSubjectBookAssessmentModel.js +57 -104
- package/dist/models/psql/batchSubjectProjectAssessmentModel.d.ts +2 -1
- package/dist/models/psql/batchSubjectProjectAssessmentModel.js +59 -92
- package/dist/models/psql/bookAssessmentDateModel.d.ts +2 -1
- package/dist/models/psql/bookAssessmentDateModel.js +26 -46
- package/dist/models/psql/categoriesModel.d.ts +2 -1
- package/dist/models/psql/categoriesModel.js +25 -45
- package/dist/models/psql/cityModel.d.ts +2 -1
- package/dist/models/psql/cityModel.js +21 -33
- package/dist/models/psql/classRoomModel.d.ts +2 -1
- package/dist/models/psql/classRoomModel.js +41 -67
- package/dist/models/psql/cloudStorageModel.d.ts +2 -1
- package/dist/models/psql/cloudStorageModel.js +18 -29
- package/dist/models/psql/coinPurchaseOfferModel.d.ts +5 -4
- package/dist/models/psql/coinPurchaseOfferModel.js +18 -29
- package/dist/models/psql/contactFeedBackModel.d.ts +2 -1
- package/dist/models/psql/contactFeedBackModel.js +49 -62
- package/dist/models/psql/countryModel.d.ts +1 -1
- package/dist/models/psql/countryModel.js +2 -0
- package/dist/models/psql/courseHasVisitorsModel.d.ts +2 -1
- package/dist/models/psql/courseHasVisitorsModel.js +25 -38
- package/dist/models/psql/courseModel.d.ts +2 -1
- package/dist/models/psql/courseModel.js +41 -56
- package/dist/models/psql/driverModel.d.ts +3 -1
- package/dist/models/psql/driverModel.js +61 -65
- package/dist/models/psql/entityGroupModel.d.ts +2 -1
- package/dist/models/psql/entityGroupModel.js +25 -45
- package/dist/models/psql/facilityModel.d.ts +3 -1
- package/dist/models/psql/facilityModel.js +63 -73
- package/dist/models/psql/featureActionModel.d.ts +3 -2
- package/dist/models/psql/featureActionModel.js +21 -36
- package/dist/models/psql/feeHistoryDetailsModel.d.ts +2 -1
- package/dist/models/psql/feeHistoryDetailsModel.js +65 -106
- package/dist/models/psql/feeHistoryModel.d.ts +4 -2
- package/dist/models/psql/feeHistoryModel.js +154 -309
- package/dist/models/psql/feeReminderModel.d.ts +2 -0
- package/dist/models/psql/feeReminderModel.js +147 -179
- package/dist/models/psql/feeReminderSettingModel.d.ts +1 -0
- package/dist/models/psql/feeReminderSettingModel.js +23 -47
- package/dist/models/psql/feeTypeHasTermsModel.d.ts +1 -0
- package/dist/models/psql/feeTypeHasTermsModel.js +48 -51
- package/dist/models/psql/feeTypeModel.d.ts +1 -0
- package/dist/models/psql/feeTypeModel.js +44 -72
- package/dist/models/psql/feesCollectionModel.d.ts +2 -0
- package/dist/models/psql/feesCollectionModel.js +112 -144
- package/dist/models/psql/fileStorageModel.d.ts +1 -0
- package/dist/models/psql/fileStorageModel.js +27 -29
- package/dist/models/psql/floorManagementModel.d.ts +1 -0
- package/dist/models/psql/floorManagementModel.js +23 -42
- package/dist/models/psql/greetingsModel.d.ts +3 -2
- package/dist/models/psql/greetingsModel.js +64 -66
- package/dist/models/psql/homeWorkModel.d.ts +1 -0
- package/dist/models/psql/homeWorkModel.js +40 -70
- package/dist/models/psql/index.js +6 -3
- package/dist/models/psql/instituteEntityModel.d.ts +1 -0
- package/dist/models/psql/instituteEntityModel.js +59 -62
- package/dist/models/psql/instituteEntityTypeModel.d.ts +1 -0
- package/dist/models/psql/instituteEntityTypeModel.js +15 -28
- package/dist/models/psql/instituteModel.d.ts +1 -0
- package/dist/models/psql/instituteModel.js +66 -185
- package/dist/models/psql/instituteSubscriptionPlanModel.d.ts +1 -0
- package/dist/models/psql/instituteSubscriptionPlanModel.js +40 -81
- package/dist/models/psql/inventoryHistoryModel.d.ts +1 -0
- package/dist/models/psql/inventoryHistoryModel.js +39 -79
- package/dist/models/psql/inventoryModel.d.ts +1 -0
- package/dist/models/psql/inventoryModel.js +31 -62
- package/dist/models/psql/lectureHistoryModel.d.ts +1 -0
- package/dist/models/psql/lectureHistoryModel.js +65 -196
- package/dist/models/psql/lectureModel.d.ts +2 -0
- package/dist/models/psql/lectureModel.js +191 -454
- package/dist/models/psql/masterLeaveModel.d.ts +2 -0
- package/dist/models/psql/masterLeaveModel.js +71 -71
- package/dist/models/psql/moduleFeatureModel.d.ts +1 -0
- package/dist/models/psql/moduleFeatureModel.js +41 -44
- package/dist/models/psql/moduleModel.d.ts +1 -0
- package/dist/models/psql/moduleModel.js +48 -52
- package/dist/models/psql/offerModel.d.ts +1 -0
- package/dist/models/psql/offerModel.js +43 -64
- package/dist/models/psql/paymentTermsModel.d.ts +1 -0
- package/dist/models/psql/paymentTermsModel.js +43 -45
- package/dist/models/psql/pdcChequeModel.d.ts +1 -0
- package/dist/models/psql/pdcChequeModel.js +59 -64
- package/dist/models/psql/pdcHistoryModel.d.ts +1 -0
- package/dist/models/psql/pdcHistoryModel.js +55 -73
- package/dist/models/psql/pincodeModel.d.ts +1 -0
- package/dist/models/psql/pincodeModel.js +6 -9
- package/dist/models/psql/productModel.d.ts +1 -0
- package/dist/models/psql/productModel.js +40 -80
- package/dist/models/psql/projectAssessmentOptionModel.d.ts +1 -0
- package/dist/models/psql/projectAssessmentOptionModel.js +23 -45
- package/dist/models/psql/roleModel.d.ts +1 -0
- package/dist/models/psql/roleModel.js +15 -38
- package/dist/models/psql/rulesRegulationModel.d.ts +3 -2
- package/dist/models/psql/rulesRegulationModel.js +20 -33
- package/dist/models/psql/schoolFeeCollectionModel.d.ts +1 -0
- package/dist/models/psql/schoolFeeCollectionModel.js +47 -94
- package/dist/models/psql/schoolOfferModel.d.ts +1 -0
- package/dist/models/psql/schoolOfferModel.js +39 -78
- package/dist/models/psql/sendNotificationModel.d.ts +1 -0
- package/dist/models/psql/sendNotificationModel.js +37 -61
- package/dist/models/psql/slotModel.d.ts +2 -0
- package/dist/models/psql/slotModel.js +46 -58
- package/dist/models/psql/stateModel.d.ts +1 -0
- package/dist/models/psql/stateModel.js +17 -18
- package/dist/models/psql/subjectHasFeeModel.d.ts +1 -0
- package/dist/models/psql/subjectHasFeeModel.js +49 -46
- package/dist/models/psql/subjectHasPayFeeHistoryModel.d.ts +1 -0
- package/dist/models/psql/subjectHasPayFeeHistoryModel.js +74 -69
- package/dist/models/psql/syllabusModel.d.ts +1 -0
- package/dist/models/psql/syllabusModel.js +72 -85
- package/dist/models/psql/testimonialModel.d.ts +2 -0
- package/dist/models/psql/testimonialModel.js +97 -100
- package/dist/models/psql/toDoModel.d.ts +2 -0
- package/dist/models/psql/toDoModel.js +64 -64
- package/dist/models/psql/tripModel.d.ts +1 -0
- package/dist/models/psql/tripModel.js +51 -55
- package/dist/models/psql/typeManagementModel.d.ts +2 -0
- package/dist/models/psql/typeManagementModel.js +69 -69
- package/dist/models/psql/userBookAssessmentModel.d.ts +1 -0
- package/dist/models/psql/userBookAssessmentModel.js +83 -89
- package/dist/models/psql/userFeeTypeByAccountModel.d.ts +1 -0
- package/dist/models/psql/userFeeTypeByAccountModel.js +117 -122
- package/dist/models/psql/userFeeTypeModel.d.ts +1 -0
- package/dist/models/psql/userFeeTypeModel.js +97 -102
- package/dist/models/psql/userHasAnnouncementModel.d.ts +1 -0
- package/dist/models/psql/userHasAnnouncementModel.js +63 -66
- package/dist/models/psql/userHasBatchModel.d.ts +1 -0
- package/dist/models/psql/userHasBatchModel.js +55 -57
- package/dist/models/psql/userHasCourseModel.d.ts +1 -0
- package/dist/models/psql/userHasCourseModel.js +51 -55
- package/dist/models/psql/userHasDeviceModel.d.ts +1 -0
- package/dist/models/psql/userHasDeviceModel.js +35 -38
- package/dist/models/psql/userHasFeeTermsModel.d.ts +1 -0
- package/dist/models/psql/userHasFeeTermsModel.js +51 -117
- package/dist/models/psql/userHasFileModel.d.ts +1 -0
- package/dist/models/psql/userHasFileModel.js +33 -61
- package/dist/models/psql/userHasHomeWorkModel.d.ts +9 -6
- package/dist/models/psql/userHasHomeWorkModel.js +50 -72
- package/dist/models/psql/userHasInventoryHistoryModel.d.ts +5 -4
- package/dist/models/psql/userHasInventoryHistoryModel.js +42 -59
- package/dist/models/psql/userHasInventoryModel.d.ts +5 -4
- package/dist/models/psql/userHasInventoryModel.js +30 -54
- package/dist/models/psql/userHasLeaveHistoryModel.d.ts +5 -4
- package/dist/models/psql/userHasLeaveHistoryModel.js +21 -36
- package/dist/models/psql/userHasLeaveModel.d.ts +6 -5
- package/dist/models/psql/userHasLeaveModel.js +47 -68
- package/dist/models/psql/userHasOfferModel.d.ts +8 -7
- package/dist/models/psql/userHasOfferModel.js +54 -109
- package/dist/models/psql/userHasParentModel.d.ts +7 -5
- package/dist/models/psql/userHasParentModel.js +38 -65
- package/dist/models/psql/userHasRoleModel.d.ts +6 -5
- package/dist/models/psql/userHasRoleModel.js +27 -56
- package/dist/models/psql/userHasRollNumberModel.d.ts +5 -4
- package/dist/models/psql/userHasRollNumberModel.js +39 -54
- package/dist/models/psql/userHasStorageModel.d.ts +5 -4
- package/dist/models/psql/userHasStorageModel.js +31 -35
- package/dist/models/psql/userHasSubjectFeeModel.d.ts +5 -4
- package/dist/models/psql/userHasSubjectFeeModel.js +32 -47
- package/dist/models/psql/userLeaveRequestModel.d.ts +6 -5
- package/dist/models/psql/userLeaveRequestModel.js +24 -40
- package/dist/models/psql/userModel.d.ts +2 -2
- package/dist/models/psql/userModel.js +174 -370
- package/dist/models/psql/userPayoutDetailsModel.d.ts +1 -0
- package/dist/models/psql/userPayoutDetailsModel.js +65 -146
- package/dist/models/psql/userPayoutHistoryModel.d.ts +1 -0
- package/dist/models/psql/userPayoutHistoryModel.js +39 -66
- package/dist/models/psql/userPayoutModel.d.ts +2 -0
- package/dist/models/psql/userPayoutModel.js +205 -240
- package/dist/models/psql/userProjectAssessmentOptionModel.d.ts +1 -0
- package/dist/models/psql/userProjectAssessmentOptionModel.js +39 -74
- package/dist/models/psql/userRequiredStepsModel.d.ts +1 -0
- package/dist/models/psql/userRequiredStepsModel.js +23 -36
- package/dist/models/psql/vehicleModel.d.ts +1 -0
- package/dist/models/psql/vehicleModel.js +27 -53
- package/dist/models/psql/vendorManagementModel.d.ts +6 -5
- package/dist/models/psql/vendorManagementModel.js +48 -97
- package/dist/models/psql/walletHistoryModel.d.ts +2 -1
- package/dist/models/psql/walletHistoryModel.js +31 -33
- package/dist/models/psql/walletModel.d.ts +2 -1
- package/dist/models/psql/walletModel.js +28 -46
- package/dist/models/psql/workingDayModel.d.ts +3 -2
- package/dist/models/psql/workingDayModel.js +18 -31
- package/dist/models/psql/workingShiftModel.d.ts +3 -2
- package/dist/models/psql/workingShiftModel.js +43 -40
- package/dist/types/accountHasReceiptDetailsType.d.ts +1 -1
- package/dist/types/bannerType.d.ts +1 -1
- package/dist/types/batchSubjectBookAssessmentType.d.ts +1 -1
- package/dist/types/batchSubjectProjectAssessmentType.d.ts +1 -1
- package/dist/types/batchType.d.ts +1 -1
- package/dist/types/bookAssessmentDateType.d.ts +1 -1
- package/dist/types/examType.d.ts +1 -1
- package/dist/types/feeHistoryType.d.ts +1 -1
- package/dist/types/greetingsType.d.ts +1 -1
- package/dist/types/holidayType.js +1 -1
- package/dist/types/paymentTermsType.js +1 -1
- package/dist/types/projectAssessmentOptionType.d.ts +1 -1
- package/dist/types/subjectIndexType.d.ts +1 -1
- package/dist/types/syllabusType.d.ts +1 -1
- package/dist/types/testimonialType.d.ts +1 -1
- package/dist/types/userBookAssessmentType.d.ts +1 -1
- package/dist/types/userHasBatchType.d.ts +1 -1
- package/dist/types/userProjectAssessmentOptionType.d.ts +1 -1
- package/package.json +1 -1
|
@@ -6,471 +6,208 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const sequelize_1 = require("sequelize");
|
|
7
7
|
const index_1 = require("./index");
|
|
8
8
|
const app_1 = require("../../constants/app");
|
|
9
|
-
const
|
|
10
|
-
const instituteModel_1 = __importDefault(require("./instituteModel"));
|
|
11
|
-
const typeManagementModel_1 = __importDefault(require("./typeManagementModel"));
|
|
12
|
-
const workingDayModel_1 = __importDefault(require("./workingDayModel"));
|
|
13
|
-
const classRoomModel_1 = __importDefault(require("./classRoomModel"));
|
|
9
|
+
const userInstituteMetaModel_1 = __importDefault(require("../mongodb/userInstituteMetaModel"));
|
|
14
10
|
const errorMessages_1 = require("../../constants/errorMessages");
|
|
15
|
-
const batchModel_1 = __importDefault(require("./batchModel"));
|
|
16
11
|
const utils_1 = require("../../helpers/utils");
|
|
17
|
-
const instituteEntityModel_1 = __importDefault(require("./instituteEntityModel"));
|
|
18
|
-
const slotModel_1 = __importDefault(require("./slotModel"));
|
|
19
|
-
const workingShiftModel_1 = __importDefault(require("./workingShiftModel"));
|
|
20
|
-
const userHasBatchModel_1 = __importDefault(require("./userHasBatchModel"));
|
|
21
|
-
const userInstituteMetaModel_1 = __importDefault(require("../mongodb/userInstituteMetaModel"));
|
|
22
12
|
class LectureModel extends sequelize_1.Model {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
allowNull: true,
|
|
34
|
-
defaultValue: app_1.LECTURE_TITLE.LECTURE,
|
|
35
|
-
},
|
|
36
|
-
descriptions: {
|
|
37
|
-
type: sequelize_1.DataTypes.STRING,
|
|
38
|
-
allowNull: true,
|
|
39
|
-
},
|
|
40
|
-
type: {
|
|
41
|
-
type: sequelize_1.DataTypes.UUID,
|
|
42
|
-
allowNull: true,
|
|
43
|
-
},
|
|
44
|
-
slotDuration: {
|
|
45
|
-
type: sequelize_1.DataTypes.INTEGER,
|
|
46
|
-
field: 'slot_duration',
|
|
47
|
-
allowNull: false,
|
|
48
|
-
},
|
|
49
|
-
subject: {
|
|
50
|
-
type: sequelize_1.DataTypes.UUID,
|
|
51
|
-
allowNull: true,
|
|
52
|
-
},
|
|
53
|
-
startTime: {
|
|
54
|
-
type: sequelize_1.DataTypes.DATE,
|
|
55
|
-
field: 'start_time',
|
|
56
|
-
allowNull: false,
|
|
57
|
-
},
|
|
58
|
-
endTime: {
|
|
59
|
-
type: sequelize_1.DataTypes.DATE,
|
|
60
|
-
field: 'end_time',
|
|
61
|
-
allowNull: false,
|
|
62
|
-
},
|
|
63
|
-
instituteId: {
|
|
64
|
-
type: sequelize_1.DataTypes.UUID,
|
|
65
|
-
field: 'institute_id',
|
|
66
|
-
allowNull: true,
|
|
67
|
-
},
|
|
68
|
-
classRoomId: {
|
|
69
|
-
type: sequelize_1.DataTypes.UUID,
|
|
70
|
-
field: 'class_room_id',
|
|
71
|
-
allowNull: true,
|
|
72
|
-
},
|
|
73
|
-
groupId: {
|
|
74
|
-
type: sequelize_1.DataTypes.UUID,
|
|
75
|
-
field: 'group_id',
|
|
76
|
-
allowNull: true,
|
|
77
|
-
},
|
|
78
|
-
primaryUserId: {
|
|
79
|
-
type: sequelize_1.DataTypes.UUID,
|
|
80
|
-
field: 'primary_user_id',
|
|
81
|
-
allowNull: true,
|
|
82
|
-
},
|
|
83
|
-
secondaryUserId: {
|
|
84
|
-
type: sequelize_1.DataTypes.UUID,
|
|
85
|
-
field: 'secondary_user_id',
|
|
86
|
-
allowNull: true,
|
|
87
|
-
},
|
|
88
|
-
workingDayId: {
|
|
89
|
-
type: sequelize_1.DataTypes.UUID,
|
|
90
|
-
field: 'working_day_id',
|
|
91
|
-
allowNull: false,
|
|
92
|
-
},
|
|
93
|
-
batchId: {
|
|
94
|
-
type: sequelize_1.DataTypes.UUID,
|
|
95
|
-
field: 'batch_id',
|
|
96
|
-
allowNull: true,
|
|
97
|
-
},
|
|
98
|
-
status: {
|
|
99
|
-
type: sequelize_1.DataTypes.ENUM,
|
|
100
|
-
allowNull: false,
|
|
101
|
-
values: Object.values(app_1.LECTURE_STATUS),
|
|
102
|
-
defaultValue: app_1.LECTURE_STATUS.NOT_STARTED,
|
|
103
|
-
},
|
|
104
|
-
checkedInAt: {
|
|
105
|
-
type: sequelize_1.DataTypes.DATE,
|
|
106
|
-
field: 'checked_in_at',
|
|
107
|
-
allowNull: true,
|
|
108
|
-
},
|
|
109
|
-
checkedOutAt: {
|
|
110
|
-
type: sequelize_1.DataTypes.DATE,
|
|
111
|
-
field: 'checked_out_at',
|
|
112
|
-
allowNull: true,
|
|
113
|
-
},
|
|
114
|
-
color: {
|
|
115
|
-
type: sequelize_1.DataTypes.STRING,
|
|
116
|
-
allowNull: true,
|
|
117
|
-
},
|
|
118
|
-
plannerSyncStatus: {
|
|
119
|
-
type: sequelize_1.DataTypes.STRING,
|
|
120
|
-
field: 'planner_sync_status',
|
|
121
|
-
allowNull: true,
|
|
122
|
-
defaultValue: app_1.PLANNER_SYNC_STATUS.PENDING,
|
|
123
|
-
},
|
|
124
|
-
shiftId: {
|
|
125
|
-
type: sequelize_1.DataTypes.UUID,
|
|
126
|
-
field: 'shift_id',
|
|
127
|
-
allowNull: true,
|
|
128
|
-
},
|
|
129
|
-
slotId: {
|
|
130
|
-
type: sequelize_1.DataTypes.UUID,
|
|
131
|
-
field: 'slot_id',
|
|
132
|
-
allowNull: true,
|
|
133
|
-
},
|
|
134
|
-
}, {
|
|
135
|
-
modelName: 'LectureModel',
|
|
136
|
-
tableName: 'lectures',
|
|
137
|
-
timestamps: true,
|
|
138
|
-
sequelize: index_1.sequelize,
|
|
139
|
-
});
|
|
140
|
-
// Associations
|
|
141
|
-
LectureModel.belongsTo(userModel_1.default, {
|
|
142
|
-
foreignKey: {
|
|
143
|
-
name: 'createdBy',
|
|
144
|
-
allowNull: true,
|
|
145
|
-
field: 'created_by',
|
|
146
|
-
},
|
|
147
|
-
as: 'createdByUser',
|
|
148
|
-
});
|
|
149
|
-
LectureModel.belongsTo(userModel_1.default, {
|
|
150
|
-
foreignKey: {
|
|
151
|
-
name: 'updatedBy',
|
|
152
|
-
allowNull: true,
|
|
153
|
-
field: 'updated_by',
|
|
154
|
-
},
|
|
155
|
-
as: 'updatedByUser',
|
|
156
|
-
});
|
|
157
|
-
LectureModel.belongsTo(userModel_1.default, {
|
|
158
|
-
foreignKey: {
|
|
159
|
-
name: 'deletedBy',
|
|
160
|
-
allowNull: true,
|
|
161
|
-
field: 'deleted_by',
|
|
162
|
-
},
|
|
163
|
-
as: 'deletedByUser',
|
|
164
|
-
});
|
|
165
|
-
LectureModel.belongsTo(typeManagementModel_1.default, {
|
|
166
|
-
foreignKey: 'type',
|
|
167
|
-
as: 'lectureType',
|
|
168
|
-
});
|
|
169
|
-
LectureModel.belongsTo(instituteModel_1.default, {
|
|
170
|
-
foreignKey: 'instituteId',
|
|
171
|
-
as: 'institute',
|
|
172
|
-
});
|
|
173
|
-
instituteModel_1.default.hasMany(LectureModel, {
|
|
174
|
-
foreignKey: 'instituteId',
|
|
175
|
-
as: 'instituteHasLectures',
|
|
176
|
-
});
|
|
177
|
-
LectureModel.belongsTo(workingDayModel_1.default, {
|
|
178
|
-
foreignKey: 'workingDayId',
|
|
179
|
-
as: 'workingDay',
|
|
180
|
-
});
|
|
181
|
-
workingDayModel_1.default.hasMany(LectureModel, {
|
|
182
|
-
foreignKey: 'workingDayId',
|
|
183
|
-
as: 'workingDayHasLectures',
|
|
184
|
-
});
|
|
185
|
-
LectureModel.belongsTo(slotModel_1.default, {
|
|
186
|
-
foreignKey: 'slotId',
|
|
187
|
-
as: 'lectureSlot',
|
|
188
|
-
});
|
|
189
|
-
slotModel_1.default.hasMany(LectureModel, {
|
|
190
|
-
foreignKey: 'slotId',
|
|
191
|
-
as: 'slotLectureList',
|
|
192
|
-
});
|
|
193
|
-
LectureModel.belongsTo(workingShiftModel_1.default, {
|
|
194
|
-
foreignKey: 'shiftId',
|
|
195
|
-
as: 'lectureShift',
|
|
196
|
-
});
|
|
197
|
-
workingShiftModel_1.default.hasMany(LectureModel, {
|
|
198
|
-
foreignKey: 'shiftId',
|
|
199
|
-
as: 'shiftLectureList',
|
|
200
|
-
});
|
|
201
|
-
LectureModel.belongsTo(userModel_1.default, {
|
|
202
|
-
foreignKey: {
|
|
203
|
-
name: 'primaryUserId',
|
|
204
|
-
field: 'primary_user_id',
|
|
205
|
-
allowNull: true,
|
|
206
|
-
},
|
|
207
|
-
as: 'user',
|
|
208
|
-
});
|
|
209
|
-
userModel_1.default.hasMany(LectureModel, {
|
|
210
|
-
foreignKey: {
|
|
211
|
-
name: 'primaryUserId',
|
|
212
|
-
field: 'primary_user_id',
|
|
213
|
-
allowNull: true,
|
|
214
|
-
},
|
|
215
|
-
as: 'userHasLectures',
|
|
216
|
-
});
|
|
217
|
-
LectureModel.belongsTo(userModel_1.default, {
|
|
218
|
-
foreignKey: {
|
|
219
|
-
name: 'secondaryUserId',
|
|
220
|
-
field: 'secondary_user_id',
|
|
221
|
-
allowNull: true,
|
|
222
|
-
},
|
|
223
|
-
as: 'secondaryUser',
|
|
224
|
-
});
|
|
225
|
-
userModel_1.default.hasMany(LectureModel, {
|
|
226
|
-
foreignKey: {
|
|
227
|
-
name: 'secondaryUserId',
|
|
228
|
-
field: 'secondary_user_id',
|
|
229
|
-
allowNull: true,
|
|
230
|
-
},
|
|
231
|
-
as: 'secondaryUserHasLectures',
|
|
232
|
-
});
|
|
233
|
-
LectureModel.belongsTo(classRoomModel_1.default, {
|
|
234
|
-
foreignKey: 'classRoomId',
|
|
235
|
-
as: 'classRoom',
|
|
236
|
-
});
|
|
237
|
-
classRoomModel_1.default.hasMany(LectureModel, {
|
|
238
|
-
foreignKey: 'classRoomId',
|
|
239
|
-
as: 'classRoomHasLectures',
|
|
240
|
-
});
|
|
241
|
-
LectureModel.belongsTo(batchModel_1.default, {
|
|
242
|
-
foreignKey: 'batchId',
|
|
243
|
-
as: 'batch',
|
|
244
|
-
});
|
|
245
|
-
batchModel_1.default.hasMany(LectureModel, {
|
|
246
|
-
foreignKey: 'batchId',
|
|
247
|
-
as: 'batchHasLectures',
|
|
248
|
-
});
|
|
249
|
-
LectureModel.belongsTo(instituteEntityModel_1.default, {
|
|
250
|
-
foreignKey: 'subject',
|
|
251
|
-
as: 'subjectDetails',
|
|
252
|
-
});
|
|
253
|
-
instituteEntityModel_1.default.hasMany(LectureModel, {
|
|
254
|
-
foreignKey: 'subject',
|
|
255
|
-
as: 'subjectHasLectures',
|
|
256
|
-
});
|
|
257
|
-
const beforeCreateOrUpdateHook = async (lecture, transaction = null) => {
|
|
258
|
-
const options = {};
|
|
259
|
-
if (transaction)
|
|
260
|
-
options.transaction = transaction;
|
|
261
|
-
if (lecture.instituteId) {
|
|
262
|
-
const institute = await instituteModel_1.default.findByPk(lecture.instituteId);
|
|
263
|
-
if (!institute) {
|
|
264
|
-
throw new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (lecture.workingDayId) {
|
|
268
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
269
|
-
let workingDay = await workingDayModel_1.default.findOne({
|
|
270
|
-
where: { id: lecture.workingDayId },
|
|
271
|
-
include: [
|
|
272
|
-
{
|
|
273
|
-
association: 'workingDayShift',
|
|
274
|
-
required: false,
|
|
275
|
-
include: [{ association: 'shiftSlot', required: false }],
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
});
|
|
279
|
-
if (!workingDay) {
|
|
280
|
-
throw new Error(errorMessages_1.WORKING_DAYS_ERROR_MESSAGES.NOT_FOUND);
|
|
281
|
-
}
|
|
282
|
-
workingDay = JSON.parse(JSON.stringify(workingDay));
|
|
283
|
-
if (lecture.slotId) {
|
|
284
|
-
if (!workingDay.workingDayShift.length)
|
|
285
|
-
throw new Error(errorMessages_1.SCHOOL_SHIFT_ERROR_MESSAGES.NOT_FOUND);
|
|
286
|
-
const validShift = workingDay.workingDayShift.find((shift) => shift.slotId === lecture.slotId);
|
|
287
|
-
if (!validShift) {
|
|
288
|
-
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.INVALID_SLOT_OR_SHIFT);
|
|
13
|
+
static addHooks(models) {
|
|
14
|
+
const beforeCreateOrUpdateHook = async (lecture, transaction = null) => {
|
|
15
|
+
const { InstituteModel, WorkingDayModel, ClassRoomModel, UserHasBatchModel, BatchModel, TypeManagementModel, InstituteEntityModel } = models;
|
|
16
|
+
const options = {};
|
|
17
|
+
if (transaction)
|
|
18
|
+
options.transaction = transaction;
|
|
19
|
+
if (lecture.instituteId) {
|
|
20
|
+
const institute = await InstituteModel.findByPk(lecture.instituteId);
|
|
21
|
+
if (!institute)
|
|
22
|
+
throw new Error(errorMessages_1.INSTITUTE_ERROR_MESSAGES.NOT_FOUND);
|
|
289
23
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
24
|
+
if (lecture.workingDayId) {
|
|
25
|
+
let workingDay = await WorkingDayModel.findOne({
|
|
26
|
+
where: { id: lecture.workingDayId },
|
|
27
|
+
include: [
|
|
28
|
+
{
|
|
29
|
+
association: 'workingDayShift',
|
|
30
|
+
required: false,
|
|
31
|
+
include: [{ association: 'shiftSlot', required: false }],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
if (!workingDay)
|
|
36
|
+
throw new Error(errorMessages_1.WORKING_DAYS_ERROR_MESSAGES.NOT_FOUND);
|
|
37
|
+
workingDay = JSON.parse(JSON.stringify(workingDay));
|
|
38
|
+
if (lecture.slotId) {
|
|
39
|
+
if (!workingDay.workingDayShift.length)
|
|
40
|
+
throw new Error(errorMessages_1.SCHOOL_SHIFT_ERROR_MESSAGES.NOT_FOUND);
|
|
41
|
+
const validShift = workingDay.workingDayShift.find((shift) => shift.slotId === lecture.slotId);
|
|
42
|
+
if (!validShift)
|
|
43
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.INVALID_SLOT_OR_SHIFT);
|
|
44
|
+
validShift.startTime = new Date(validShift.startTime);
|
|
45
|
+
validShift.endTime = new Date(validShift.endTime);
|
|
46
|
+
const isValidStartTime = (0, utils_1.isTimeWithinRange)(lecture.startTime, validShift.startTime, validShift.endTime);
|
|
47
|
+
const isValidEndTime = (0, utils_1.isTimeWithinRange)(lecture.endTime, validShift.startTime, validShift.endTime);
|
|
48
|
+
if (!isValidStartTime || !isValidEndTime)
|
|
49
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.INVALID_LECTURE_TIME);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
workingDay.startTime = new Date(workingDay.startTime);
|
|
53
|
+
workingDay.endTime = new Date(workingDay.endTime);
|
|
54
|
+
const isValidStartTime = (0, utils_1.isTimeWithinRange)(lecture.startTime, workingDay.startTime, workingDay.endTime);
|
|
55
|
+
const isValidEndTime = (0, utils_1.isTimeWithinRange)(lecture.endTime, workingDay.startTime, workingDay.endTime);
|
|
56
|
+
if (!isValidStartTime || !isValidEndTime)
|
|
57
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.INVALID_LECTURE_TIME);
|
|
58
|
+
}
|
|
296
59
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
const isValidStartTime = (0, utils_1.isTimeWithinRange)(lecture.startTime, workingDay.startTime, workingDay.endTime);
|
|
302
|
-
const isValidEndTime = (0, utils_1.isTimeWithinRange)(lecture.endTime, workingDay.startTime, workingDay.endTime);
|
|
303
|
-
if (!isValidStartTime || !isValidEndTime) {
|
|
304
|
-
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.INVALID_LECTURE_TIME);
|
|
60
|
+
if (lecture.classRoomId) {
|
|
61
|
+
const classRoom = await ClassRoomModel.findByPk(lecture.classRoomId);
|
|
62
|
+
if (!classRoom)
|
|
63
|
+
throw new Error(errorMessages_1.CLASSROOM_ERROR_MESSAGES.NOT_FOUND);
|
|
305
64
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const classRoom = await classRoomModel_1.default.findByPk(lecture.classRoomId);
|
|
311
|
-
if (!classRoom) {
|
|
312
|
-
throw new Error(errorMessages_1.CLASSROOM_ERROR_MESSAGES.NOT_FOUND);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
// Validate the primaryUserId
|
|
316
|
-
if (lecture.primaryUserId) {
|
|
317
|
-
if (!lecture.batchId)
|
|
318
|
-
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.NOT_FOUND);
|
|
319
|
-
const batchWhere = {
|
|
320
|
-
batchId: lecture.batchId,
|
|
321
|
-
userId: lecture.primaryUserId,
|
|
322
|
-
};
|
|
323
|
-
if (lecture.subject)
|
|
324
|
-
batchWhere.subjects = { [sequelize_1.Op.overlap]: [lecture.subject] };
|
|
325
|
-
const user = await userHasBatchModel_1.default.findOne({
|
|
326
|
-
where: batchWhere,
|
|
327
|
-
...options,
|
|
328
|
-
include: [{ association: 'user', where: { type: app_1.USER_TYPES.TEACHER } }],
|
|
329
|
-
});
|
|
330
|
-
if (!user) {
|
|
331
|
-
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.INVALID_SELECTED);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
// Validate the secondaryUserId
|
|
335
|
-
// if (lecture.secondaryUserId) {
|
|
336
|
-
// if (!lecture.batchId) throw new Error(BATCH_ERROR_MESSAGES.NOT_FOUND);
|
|
337
|
-
// const batchWhere: WhereOptions = {
|
|
338
|
-
// batchId: lecture.batchId,
|
|
339
|
-
// userId: lecture.secondaryUserId,
|
|
340
|
-
// };
|
|
341
|
-
// if (lecture.subject) batchWhere.subjects = { [Op.overlap]: [lecture.subject] };
|
|
342
|
-
// const user = await userHasBatchService.findOne(batchWhere, { include: [{ association: 'user', where: { type: USER_TYPES.TEACHER } }] });
|
|
343
|
-
// if (!user) {
|
|
344
|
-
// throw new Error(BATCH_ERROR_MESSAGES.INVALID_SELECTED);
|
|
345
|
-
// }
|
|
346
|
-
// }
|
|
347
|
-
if (lecture.workingDayId && lecture.startTime && lecture.endTime) {
|
|
348
|
-
let where = {
|
|
349
|
-
[sequelize_1.Op.or]: [
|
|
350
|
-
{
|
|
351
|
-
[sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.lte]: lecture.startTime } }, { endTime: { [sequelize_1.Op.gt]: lecture.startTime } }],
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
[sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.lt]: lecture.endTime } }, { endTime: { [sequelize_1.Op.gte]: lecture.endTime } }],
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
[sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.gte]: lecture.startTime } }, { endTime: { [sequelize_1.Op.lte]: lecture.endTime } }],
|
|
358
|
-
},
|
|
359
|
-
],
|
|
360
|
-
instituteId: lecture.instituteId,
|
|
361
|
-
workingDayId: lecture.workingDayId,
|
|
362
|
-
};
|
|
363
|
-
if (lecture.id)
|
|
364
|
-
where = { ...where, id: { [sequelize_1.Op.ne]: lecture.id } };
|
|
365
|
-
// if (lecture.batchId) where = { ...where, batchId: lecture.batchId };
|
|
366
|
-
// if (lecture.classRoomId) where = { ...where, classRoomId: lecture.classRoomId };
|
|
367
|
-
// const existLecture = await LectureModel.findOne({ where });
|
|
368
|
-
// if (existLecture) throw new Error(LECTURE_ERROR_MESSAGES.DUPLICATE);
|
|
369
|
-
if (lecture.batchId) {
|
|
370
|
-
if (lecture.slotId)
|
|
371
|
-
where.slotId = lecture.slotId;
|
|
372
|
-
const batchConflict = await LectureModel.findOne({
|
|
373
|
-
where: {
|
|
374
|
-
...where,
|
|
65
|
+
if (lecture.primaryUserId) {
|
|
66
|
+
if (!lecture.batchId)
|
|
67
|
+
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.NOT_FOUND);
|
|
68
|
+
const batchWhere = {
|
|
375
69
|
batchId: lecture.batchId,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
70
|
+
userId: lecture.primaryUserId,
|
|
71
|
+
};
|
|
72
|
+
if (lecture.subject)
|
|
73
|
+
batchWhere.subjects = { [sequelize_1.Op.overlap]: [lecture.subject] };
|
|
74
|
+
const user = await UserHasBatchModel.findOne({
|
|
75
|
+
where: batchWhere,
|
|
76
|
+
...options,
|
|
77
|
+
include: [{ association: 'user', where: { type: app_1.USER_TYPES.TEACHER } }],
|
|
78
|
+
});
|
|
79
|
+
if (!user)
|
|
80
|
+
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.INVALID_SELECTED);
|
|
81
|
+
}
|
|
82
|
+
if (lecture.workingDayId && lecture.startTime && lecture.endTime) {
|
|
83
|
+
let where = {
|
|
84
|
+
[sequelize_1.Op.or]: [
|
|
85
|
+
{ [sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.lte]: lecture.startTime } }, { endTime: { [sequelize_1.Op.gt]: lecture.startTime } }] },
|
|
86
|
+
{ [sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.lt]: lecture.endTime } }, { endTime: { [sequelize_1.Op.gte]: lecture.endTime } }] },
|
|
87
|
+
{ [sequelize_1.Op.and]: [{ startTime: { [sequelize_1.Op.gte]: lecture.startTime } }, { endTime: { [sequelize_1.Op.lte]: lecture.endTime } }] },
|
|
88
|
+
],
|
|
89
|
+
instituteId: lecture.instituteId,
|
|
90
|
+
workingDayId: lecture.workingDayId,
|
|
91
|
+
};
|
|
92
|
+
if (lecture.id)
|
|
93
|
+
where = { ...where, id: { [sequelize_1.Op.ne]: lecture.id } };
|
|
94
|
+
if (lecture.batchId) {
|
|
95
|
+
if (lecture.slotId)
|
|
96
|
+
where.slotId = lecture.slotId;
|
|
97
|
+
const batchConflict = await LectureModel.findOne({ where: { ...where, batchId: lecture.batchId }, ...options });
|
|
98
|
+
if (batchConflict)
|
|
99
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.BATCH_OCCUPIED);
|
|
100
|
+
}
|
|
101
|
+
if (lecture.classRoomId) {
|
|
102
|
+
const classRoomConflict = await LectureModel.findOne({ where: { ...where, classRoomId: lecture.classRoomId }, ...options });
|
|
103
|
+
if (classRoomConflict)
|
|
104
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.CLASSROOM_OCCUPIED);
|
|
105
|
+
}
|
|
106
|
+
if (lecture.primaryUserId) {
|
|
107
|
+
const teacherConflict = await LectureModel.findOne({ where: { ...where, primaryUserId: lecture.primaryUserId }, ...options });
|
|
108
|
+
if (teacherConflict)
|
|
109
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.TEACHER_OCCUPIED);
|
|
110
|
+
}
|
|
111
|
+
if (lecture.secondaryUserId) {
|
|
112
|
+
const teacherConflict = await LectureModel.findOne({ where: { ...where, secondaryUserId: lecture.secondaryUserId }, ...options });
|
|
113
|
+
if (teacherConflict)
|
|
114
|
+
throw new Error(errorMessages_1.LECTURE_ERROR_MESSAGES.TEACHER_OCCUPIED);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (lecture.batchId) {
|
|
118
|
+
const batchWhere = { id: lecture.batchId };
|
|
119
|
+
if (lecture.shiftId)
|
|
120
|
+
batchWhere.shiftId = lecture.shiftId;
|
|
121
|
+
const batch = await BatchModel.findOne({ where: batchWhere, ...options });
|
|
122
|
+
if (!batch)
|
|
123
|
+
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.NOT_FOUND);
|
|
124
|
+
}
|
|
125
|
+
if (lecture.type) {
|
|
126
|
+
const type = await TypeManagementModel.findOne({ where: { id: lecture.type, type: app_1.TYPE_MANAGEMENT_TYPE.LECTURE } });
|
|
127
|
+
if (!type)
|
|
128
|
+
throw new Error(errorMessages_1.TYPE_MANAGEMENT_ERROR_MESSAGES.NOT_FOUND);
|
|
129
|
+
}
|
|
130
|
+
if (lecture.subject) {
|
|
131
|
+
const subject = await InstituteEntityModel.findOne({
|
|
132
|
+
where: { id: lecture.subject },
|
|
133
|
+
include: [{ association: 'entityType', where: { sequence: app_1.INSTITUTE_ENTITY_TYPE_SEQUENCE.LAST } }],
|
|
134
|
+
});
|
|
135
|
+
if (!subject)
|
|
136
|
+
throw new Error(errorMessages_1.INSTITUTE_ENTITY_ERROR_MESSAGES.NOT_FOUND);
|
|
137
|
+
const existSubjectInMeta = await userInstituteMetaModel_1.default.findOne({ entities: lecture.subject });
|
|
138
|
+
if (!existSubjectInMeta)
|
|
139
|
+
throw new Error(errorMessages_1.INSTITUTE_ENTITY_ERROR_MESSAGES.NOT_FOUND);
|
|
140
|
+
}
|
|
420
141
|
};
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (!batch) {
|
|
425
|
-
throw new Error(errorMessages_1.BATCH_ERROR_MESSAGES.NOT_FOUND);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
// Validate the type
|
|
429
|
-
if (lecture.type) {
|
|
430
|
-
const type = await typeManagementModel_1.default.findOne({
|
|
431
|
-
where: {
|
|
432
|
-
id: lecture.type,
|
|
433
|
-
type: app_1.TYPE_MANAGEMENT_TYPE.LECTURE,
|
|
434
|
-
},
|
|
142
|
+
LectureModel.beforeCreate(async (instance, options) => {
|
|
143
|
+
const transaction = options.transaction || null;
|
|
144
|
+
await beforeCreateOrUpdateHook(instance, transaction);
|
|
435
145
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
// Validate the workingDayId
|
|
441
|
-
if (lecture.subject) {
|
|
442
|
-
const subject = await instituteEntityModel_1.default.findOne({
|
|
443
|
-
where: { id: lecture.subject },
|
|
444
|
-
include: [
|
|
445
|
-
{
|
|
446
|
-
association: 'entityType',
|
|
447
|
-
where: { sequence: app_1.INSTITUTE_ENTITY_TYPE_SEQUENCE.LAST },
|
|
448
|
-
},
|
|
449
|
-
],
|
|
146
|
+
LectureModel.beforeBulkUpdate(async (options) => {
|
|
147
|
+
const transaction = options.transaction || null;
|
|
148
|
+
await beforeCreateOrUpdateHook(options.attributes, transaction);
|
|
450
149
|
});
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
150
|
+
LectureModel.beforeBulkCreate(async (instances, options) => {
|
|
151
|
+
const transaction = options.transaction || null;
|
|
152
|
+
for (const instance of instances) {
|
|
153
|
+
await beforeCreateOrUpdateHook(instance, transaction);
|
|
154
|
+
}
|
|
456
155
|
});
|
|
457
|
-
if (!existSubjectInMeta) {
|
|
458
|
-
throw new Error(errorMessages_1.INSTITUTE_ENTITY_ERROR_MESSAGES.NOT_FOUND);
|
|
459
|
-
}
|
|
460
156
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
});
|
|
466
|
-
LectureModel.
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
157
|
+
static associate(models) {
|
|
158
|
+
const { UserModel, TypeManagementModel, InstituteModel, WorkingDayModel, SlotModel, WorkingShiftModel, ClassRoomModel, BatchModel, InstituteEntityModel, } = models;
|
|
159
|
+
LectureModel.belongsTo(UserModel, { foreignKey: { name: 'createdBy', allowNull: true, field: 'created_by' }, as: 'createdByUser' });
|
|
160
|
+
LectureModel.belongsTo(UserModel, { foreignKey: { name: 'updatedBy', allowNull: true, field: 'updated_by' }, as: 'updatedByUser' });
|
|
161
|
+
LectureModel.belongsTo(UserModel, { foreignKey: { name: 'deletedBy', allowNull: true, field: 'deleted_by' }, as: 'deletedByUser' });
|
|
162
|
+
LectureModel.belongsTo(TypeManagementModel, { foreignKey: 'type', as: 'lectureType' });
|
|
163
|
+
LectureModel.belongsTo(InstituteModel, { foreignKey: 'instituteId', as: 'institute' });
|
|
164
|
+
InstituteModel.hasMany(LectureModel, { foreignKey: 'instituteId', as: 'instituteHasLectures' });
|
|
165
|
+
LectureModel.belongsTo(WorkingDayModel, { foreignKey: 'workingDayId', as: 'workingDay' });
|
|
166
|
+
WorkingDayModel.hasMany(LectureModel, { foreignKey: 'workingDayId', as: 'workingDayHasLectures' });
|
|
167
|
+
LectureModel.belongsTo(SlotModel, { foreignKey: 'slotId', as: 'lectureSlot' });
|
|
168
|
+
SlotModel.hasMany(LectureModel, { foreignKey: 'slotId', as: 'slotLectureList' });
|
|
169
|
+
LectureModel.belongsTo(WorkingShiftModel, { foreignKey: 'shiftId', as: 'lectureShift' });
|
|
170
|
+
WorkingShiftModel.hasMany(LectureModel, { foreignKey: 'shiftId', as: 'shiftLectureList' });
|
|
171
|
+
LectureModel.belongsTo(UserModel, { foreignKey: { name: 'primaryUserId', field: 'primary_user_id', allowNull: true }, as: 'user' });
|
|
172
|
+
UserModel.hasMany(LectureModel, { foreignKey: { name: 'primaryUserId', field: 'primary_user_id', allowNull: true }, as: 'userHasLectures' });
|
|
173
|
+
LectureModel.belongsTo(UserModel, {
|
|
174
|
+
foreignKey: { name: 'secondaryUserId', field: 'secondary_user_id', allowNull: true },
|
|
175
|
+
as: 'secondaryUser',
|
|
176
|
+
});
|
|
177
|
+
UserModel.hasMany(LectureModel, {
|
|
178
|
+
foreignKey: { name: 'secondaryUserId', field: 'secondary_user_id', allowNull: true },
|
|
179
|
+
as: 'secondaryUserHasLectures',
|
|
180
|
+
});
|
|
181
|
+
LectureModel.belongsTo(ClassRoomModel, { foreignKey: 'classRoomId', as: 'classRoom' });
|
|
182
|
+
ClassRoomModel.hasMany(LectureModel, { foreignKey: 'classRoomId', as: 'classRoomHasLectures' });
|
|
183
|
+
LectureModel.belongsTo(BatchModel, { foreignKey: 'batchId', as: 'batch' });
|
|
184
|
+
BatchModel.hasMany(LectureModel, { foreignKey: 'batchId', as: 'batchHasLectures' });
|
|
185
|
+
LectureModel.belongsTo(InstituteEntityModel, { foreignKey: 'subject', as: 'subjectDetails' });
|
|
186
|
+
InstituteEntityModel.hasMany(LectureModel, { foreignKey: 'subject', as: 'subjectHasLectures' });
|
|
474
187
|
}
|
|
475
|
-
}
|
|
188
|
+
}
|
|
189
|
+
LectureModel.init({
|
|
190
|
+
id: { type: sequelize_1.DataTypes.UUID, defaultValue: sequelize_1.DataTypes.UUIDV4, allowNull: false, primaryKey: true },
|
|
191
|
+
title: { type: sequelize_1.DataTypes.STRING, allowNull: true, defaultValue: app_1.LECTURE_TITLE.LECTURE },
|
|
192
|
+
descriptions: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
193
|
+
type: { type: sequelize_1.DataTypes.UUID, allowNull: true },
|
|
194
|
+
slotDuration: { type: sequelize_1.DataTypes.INTEGER, field: 'slot_duration', allowNull: false },
|
|
195
|
+
subject: { type: sequelize_1.DataTypes.UUID, allowNull: true },
|
|
196
|
+
startTime: { type: sequelize_1.DataTypes.DATE, field: 'start_time', allowNull: false },
|
|
197
|
+
endTime: { type: sequelize_1.DataTypes.DATE, field: 'end_time', allowNull: false },
|
|
198
|
+
instituteId: { type: sequelize_1.DataTypes.UUID, field: 'institute_id', allowNull: true },
|
|
199
|
+
classRoomId: { type: sequelize_1.DataTypes.UUID, field: 'class_room_id', allowNull: true },
|
|
200
|
+
groupId: { type: sequelize_1.DataTypes.UUID, field: 'group_id', allowNull: true },
|
|
201
|
+
primaryUserId: { type: sequelize_1.DataTypes.UUID, field: 'primary_user_id', allowNull: true },
|
|
202
|
+
secondaryUserId: { type: sequelize_1.DataTypes.UUID, field: 'secondary_user_id', allowNull: true },
|
|
203
|
+
workingDayId: { type: sequelize_1.DataTypes.UUID, field: 'working_day_id', allowNull: false },
|
|
204
|
+
batchId: { type: sequelize_1.DataTypes.UUID, field: 'batch_id', allowNull: true },
|
|
205
|
+
status: { type: sequelize_1.DataTypes.ENUM, allowNull: false, values: Object.values(app_1.LECTURE_STATUS), defaultValue: app_1.LECTURE_STATUS.NOT_STARTED },
|
|
206
|
+
checkedInAt: { type: sequelize_1.DataTypes.DATE, field: 'checked_in_at', allowNull: true },
|
|
207
|
+
checkedOutAt: { type: sequelize_1.DataTypes.DATE, field: 'checked_out_at', allowNull: true },
|
|
208
|
+
color: { type: sequelize_1.DataTypes.STRING, allowNull: true },
|
|
209
|
+
plannerSyncStatus: { type: sequelize_1.DataTypes.STRING, field: 'planner_sync_status', allowNull: true, defaultValue: app_1.PLANNER_SYNC_STATUS.PENDING },
|
|
210
|
+
shiftId: { type: sequelize_1.DataTypes.UUID, field: 'shift_id', allowNull: true },
|
|
211
|
+
slotId: { type: sequelize_1.DataTypes.UUID, field: 'slot_id', allowNull: true },
|
|
212
|
+
}, { modelName: 'LectureModel', tableName: 'lectures', timestamps: true, sequelize: index_1.sequelize });
|
|
476
213
|
exports.default = LectureModel;
|