123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /**
- * 模型类模板代码消除工具。
- */
- "use strict";
- let log = require("./log.js");
- let MODEL_EVENTS = require("../include/commons").MODEL_EVENTS;
- /**
- * 发送模型数据成功获取消息。
- *
- * @param eventEmitter
- * @param data
- */
- module.exports.emitData = function (eventEmitter, data) {
- eventEmitter.emit(MODEL_EVENTS.OK, data);
- };
- /**
- * 发送模型未取得数据消息。
- *
- * @param eventEmitter
- * @param description
- */
- module.exports.emitDataNotFound = function (eventEmitter, description) {
- eventEmitter.emit(MODEL_EVENTS.DataNotFound, description);
- };
- /**
- * 发送模型读取数据失败消息。
- *
- * @param eventEmitter
- * @param err
- * @param description
- */
- module.exports.emitDbError = function (eventEmitter, description, err) {
- logError(description, err);
- eventEmitter.emit(MODEL_EVENTS.Error, {message: description});
- };
- /**
- * 只记录错误。
- *
- * @type {logError}
- */
- function logError(description, err) {
- log.error(description, ':', err);
- }
- module.exports.logError = logError;
|