UNPKG

phx-node-test

Version:

PHX NODE

69 lines 4.58 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var PHXStatisticalNotificationByModuleService_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.PHXStatisticalNotificationByModuleService = void 0; const common_1 = require("@nestjs/common"); const query_1 = require("../../query/notification/query"); const grpc_client_system_service_1 = require("../grpc-client/grpc-client-system.service"); let PHXStatisticalNotificationByModuleService = PHXStatisticalNotificationByModuleService_1 = class PHXStatisticalNotificationByModuleService { constructor(grpcClientSystemService) { this.grpcClientSystemService = grpcClientSystemService; this.logger = new common_1.Logger(PHXStatisticalNotificationByModuleService_1.name); } updateStatisticalNotificationByModule(_a) { return __awaiter(this, arguments, void 0, function* ({ userId, deviceId, appName, hostname, moduleCode, action, studentCode, totalNotification, totalNotificationImportant, }) { yield this.grpcClientSystemService .mutationDataCenter({ query: (0, query_1.MUTATION_UPDATE_NOTIFICATION_UNREAD)({ studentCode, action }), variables: { user_id: userId, device_id: deviceId, hostname, app: appName, module_code: moduleCode, total_notification: totalNotification, total_notification_important: totalNotificationImportant, }, }) .then((response) => __awaiter(this, void 0, void 0, function* () { const isUpdateCountNotificationSuccess = response.update_feature_mobile_push_count_notification_unread .returning.length > 0; if (isUpdateCountNotificationSuccess) { this.logger.log('Update row statistical notification successfully'); return; } if (totalNotification === 0) return; yield this.grpcClientSystemService.mutationDataCenter({ query: query_1.MUTATION_INSERT_NOTIFICATION, variables: Object.assign(Object.assign(Object.assign({ user_id: userId, device_id: deviceId, hostname, app: appName, module_code: moduleCode }, (action && { action })), (studentCode && { student_code: studentCode })), { total_notification: totalNotification, total_notification_important: totalNotificationImportant }), }); this.logger.log('Insert row statistical notification successfully'); })); }); } }; exports.PHXStatisticalNotificationByModuleService = PHXStatisticalNotificationByModuleService; exports.PHXStatisticalNotificationByModuleService = PHXStatisticalNotificationByModuleService = PHXStatisticalNotificationByModuleService_1 = __decorate([ (0, common_1.Injectable)(), __metadata("design:paramtypes", [grpc_client_system_service_1.PHXGrpcClientSystemService]) ], PHXStatisticalNotificationByModuleService); //# sourceMappingURL=statistical-notification.service.js.map