goldstars-services 1.0.60 → 1.0.62
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.
|
@@ -62,6 +62,8 @@ var reportSchema = new _mongoose.default.Schema({
|
|
|
62
62
|
type: Date,
|
|
63
63
|
default: Date.now
|
|
64
64
|
}
|
|
65
|
+
}, {
|
|
66
|
+
timestamps: true // This adds createdAt and updatedAt fields automatically
|
|
65
67
|
});
|
|
66
68
|
reportSchema.pre('save', function (next) {
|
|
67
69
|
this.lastChangeDate = Date.now();
|
|
@@ -91,7 +91,12 @@ var UserSchema = Schema({
|
|
|
91
91
|
});
|
|
92
92
|
UserSchema.pre("save", /*#__PURE__*/function () {
|
|
93
93
|
var _ref = _asyncToGenerator(function* (next) {
|
|
94
|
+
console.log('=== PRE-SAVE DEBUG ===');
|
|
95
|
+
console.log('Usuario antes de encriptar password:', this.toObject());
|
|
96
|
+
console.log('confirmEmail en pre-save:', this.confirmEmail);
|
|
94
97
|
this.password = yield (0, _encrypt.encrypt)(this.password);
|
|
98
|
+
console.log('Usuario después de encriptar password:', this.toObject());
|
|
99
|
+
console.log('confirmEmail después de encriptar:', this.confirmEmail);
|
|
95
100
|
next();
|
|
96
101
|
});
|
|
97
102
|
return function (_x) {
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _report = _interopRequireDefault(require("../models/report.model"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
10
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9
11
|
/**
|
|
10
12
|
* @description Get report by query params
|
|
11
13
|
* @param {Object} queryParams
|
|
@@ -47,9 +49,51 @@ var updateReport = (queryParams, paramsToUpdate) => {
|
|
|
47
49
|
var deleteReport = queryParams => {
|
|
48
50
|
return _report.default.findOneAndDelete(queryParams);
|
|
49
51
|
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @description Get all reports with pagination and filters
|
|
55
|
+
* @param {Object} filters - MongoDB query filters
|
|
56
|
+
* @param {Object} options - Pagination options { page, limit, sort }
|
|
57
|
+
* @returns Promise<Object> - { data, currentPage, totalPages, total, hasNext, hasPrev }
|
|
58
|
+
*/
|
|
59
|
+
var getAllReports = /*#__PURE__*/function () {
|
|
60
|
+
var _ref = _asyncToGenerator(function* () {
|
|
61
|
+
var filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
62
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
|
+
var {
|
|
64
|
+
page = 1,
|
|
65
|
+
limit = 10,
|
|
66
|
+
sort = {
|
|
67
|
+
createdAt: -1
|
|
68
|
+
}
|
|
69
|
+
} = options;
|
|
70
|
+
var skip = (page - 1) * limit;
|
|
71
|
+
try {
|
|
72
|
+
var [data, total] = yield Promise.all([_report.default.find(filters).sort(sort).skip(skip).limit(limit).lean(), _report.default.countDocuments(filters)]);
|
|
73
|
+
var totalPages = Math.ceil(total / limit);
|
|
74
|
+
var currentPage = page;
|
|
75
|
+
var hasNext = page < totalPages;
|
|
76
|
+
var hasPrev = page > 1;
|
|
77
|
+
return {
|
|
78
|
+
data,
|
|
79
|
+
currentPage,
|
|
80
|
+
totalPages,
|
|
81
|
+
total,
|
|
82
|
+
hasNext,
|
|
83
|
+
hasPrev
|
|
84
|
+
};
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw new Error("Error getting reports: ".concat(error.message));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return function getAllReports() {
|
|
90
|
+
return _ref.apply(this, arguments);
|
|
91
|
+
};
|
|
92
|
+
}();
|
|
50
93
|
var _default = exports.default = {
|
|
51
94
|
getReport,
|
|
52
95
|
createReport,
|
|
53
96
|
updateReport,
|
|
54
|
-
deleteReport
|
|
97
|
+
deleteReport,
|
|
98
|
+
getAllReports
|
|
55
99
|
};
|
|
@@ -37,12 +37,17 @@ var populateQueryUserData = userQuery => {
|
|
|
37
37
|
* @returns {Promise<UserModel>}
|
|
38
38
|
*/
|
|
39
39
|
var createUser = (params, isTrainer) => {
|
|
40
|
+
console.log('=== DEBUG createUser en MicroService ===');
|
|
41
|
+
console.log('Parámetros recibidos:', params);
|
|
42
|
+
console.log('confirmEmail recibido:', params.confirmEmail);
|
|
40
43
|
var userBody = params;
|
|
41
44
|
if (isTrainer) {
|
|
42
45
|
userBody["isTrainer"] = {
|
|
43
46
|
confirmed: false
|
|
44
47
|
};
|
|
45
48
|
}
|
|
49
|
+
console.log('userBody final antes de guardar:', userBody);
|
|
50
|
+
console.log('confirmEmail en userBody:', userBody.confirmEmail);
|
|
46
51
|
var User = new _user.default(userBody);
|
|
47
52
|
return User.save();
|
|
48
53
|
};
|