goldstars-services 1.0.66 → 1.0.67
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.
|
@@ -15,6 +15,14 @@ var gymPassSchema = new _mongoose.default.Schema({
|
|
|
15
15
|
trim: true,
|
|
16
16
|
maxlength: [100, 'El nombre no puede exceder 100 caracteres']
|
|
17
17
|
},
|
|
18
|
+
cedula: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: [true, 'La cédula de identidad es obligatoria'],
|
|
21
|
+
trim: true,
|
|
22
|
+
unique: true,
|
|
23
|
+
maxlength: [20, 'La cédula no puede exceder 20 caracteres']
|
|
24
|
+
// Validaciones adicionales específicas se pueden agregar según el país
|
|
25
|
+
},
|
|
18
26
|
email: {
|
|
19
27
|
type: String,
|
|
20
28
|
required: [true, 'El email es obligatorio'],
|
|
@@ -64,6 +72,9 @@ gymPassSchema.index({
|
|
|
64
72
|
gymPassSchema.index({
|
|
65
73
|
passNumber: 1
|
|
66
74
|
});
|
|
75
|
+
gymPassSchema.index({
|
|
76
|
+
cedula: 1
|
|
77
|
+
});
|
|
67
78
|
gymPassSchema.index({
|
|
68
79
|
isUsed: 1,
|
|
69
80
|
expiresAt: 1
|
|
@@ -85,6 +96,12 @@ gymPassSchema.pre('save', /*#__PURE__*/function () {
|
|
|
85
96
|
if (existingByPhone) {
|
|
86
97
|
throw new Error('Ya existe un pase registrado con este teléfono');
|
|
87
98
|
}
|
|
99
|
+
var existingByCedula = yield this.constructor.findOne({
|
|
100
|
+
cedula: this.cedula
|
|
101
|
+
});
|
|
102
|
+
if (existingByCedula) {
|
|
103
|
+
throw new Error('Ya existe un pase registrado con esta cédula de identidad');
|
|
104
|
+
}
|
|
88
105
|
}
|
|
89
106
|
next();
|
|
90
107
|
});
|
|
@@ -47,10 +47,11 @@ var createGymPass = /*#__PURE__*/function () {
|
|
|
47
47
|
var {
|
|
48
48
|
name,
|
|
49
49
|
email,
|
|
50
|
-
phone
|
|
50
|
+
phone,
|
|
51
|
+
cedula
|
|
51
52
|
} = _ref3;
|
|
52
|
-
if (!name || !email || !phone) {
|
|
53
|
-
throw new Error('Todos los campos son requeridos: nombre, email y teléfono');
|
|
53
|
+
if (!name || !email || !phone || !cedula) {
|
|
54
|
+
throw new Error('Todos los campos son requeridos: nombre, cédula, email y teléfono');
|
|
54
55
|
}
|
|
55
56
|
var lastErr;
|
|
56
57
|
for (var attempt = 0; attempt < 3; attempt++) {
|
|
@@ -58,6 +59,7 @@ var createGymPass = /*#__PURE__*/function () {
|
|
|
58
59
|
var passNumber = yield getNextAvailablePassNumber();
|
|
59
60
|
var gymPass = yield _gymPassModel.default.create({
|
|
60
61
|
name: name.trim(),
|
|
62
|
+
cedula: cedula.trim(),
|
|
61
63
|
email: email.trim().toLowerCase(),
|
|
62
64
|
phone: phone.trim(),
|
|
63
65
|
passNumber
|
|
@@ -185,7 +187,7 @@ var getGymPassStats = /*#__PURE__*/function () {
|
|
|
185
187
|
}();
|
|
186
188
|
var updateGymPass = /*#__PURE__*/function () {
|
|
187
189
|
var _ref11 = _asyncToGenerator(function* (id, updateData) {
|
|
188
|
-
var allowedUpdates = ['name', 'phone'];
|
|
190
|
+
var allowedUpdates = ['name', 'phone', 'cedula'];
|
|
189
191
|
var updates = {};
|
|
190
192
|
Object.keys(updateData).forEach(key => {
|
|
191
193
|
if (allowedUpdates.includes(key)) {
|