/** * 消息提醒设置 * Created by ysj on 2017/12/4. */ "use strict"; let log = require('../../util/log'); let ImDb = require('../mysql/db/im.db'); const DB_TABLES = require('../../include/commons').DB_TABLES; class MessageNoticeSettingRepo{ constructor(){ } /** * 获取单个MessageNoticeSetting对象 * * @param user * @param type * @param handler * return master_switch 总开关(1开,0关)',im_switch im消息开关(1开,0关)',family_topic_switch 健管师邀请后推送开关(1开,0关)', */ static findOne(user,type, handler) { let sql = "select master_switch,im_switch,family_topic_switch from " + DB_TABLES.MessageNoticeSetting + " s where s.user = ? and s.type=? "; ImDb.execQuery({ "sql": sql, "args": [user,type], "handler": handler || function (err, res) { if(err) log.error(err); } }); } /** * 保存MessageNoticeSetting * * @param user 用户id * @param type 用户类型 1doctor 2patient * @param createTime * @param handler 回调函数 */ static save(user, type, createTime, handler) { let sql = "insert into " + DB_TABLES.MessageNoticeSetting + " (user,type,master_switch,im_switch,family_topic_switch," + "sign_switch,health_sign_switch,system_switch,prescription_switch,sound_switch,vibration_switch,coordination_switch,create_time)" + " values (?,?,1,1,1,1,1,1,1,1,1,1,?)"; ImDb.execQuery({ "sql": sql, "args": [user, type, createTime.getTime()], "handler": handler }); } } module.exports = MessageNoticeSettingRepo;