"use strict"; var log = require('../util/log'); var imRepo = require("./database/im.db.js"); exports.save = function(to, contentType, title, summary, content, handler) { imRepo.execQuery({ "sql": "INSERT INTO msg_system (to_uid,type,title,content,data) VALUES (?,?,?,?,?)", "args": [to, contentType, title, summary, content], "handler": handler }); }; exports.getLastMessageByType = function (userId,type, handler) { var sql="select m.content as lastContent,m.czrq FROM ydf_message m where m.type in ("+type+") and m.readonly = 1 and m.receiver = ? order by m.czrq desc limit 0,1" ; imRepo.execQuery({ "sql": sql, "args": [userId], "handler": handler }); }; exports.getMessagesAmountByType = function (userId,type, handler) { var sql="select count(1) as amount FROM ydf_message m where m.readonly = 1 and m.type in ("+type+") and m.receiver = ? order by m.czrq desc " ; imRepo.execQuery({ "sql": sql, "args": [userId], "handler": handler }); };