message.noticeSetting.repo.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * 消息提醒设置
  3. * Created by ysj on 2017/12/4.
  4. */
  5. "use strict";
  6. let log = require('../../util/log');
  7. let ImDb = require('../oracle/db/im.db');
  8. const DB_TABLES = require('../../include/commons').DB_TABLES;
  9. class MessageNoticeSettingRepo{
  10. constructor(){
  11. }
  12. /**
  13. * 获取单个MessageNoticeSetting对象
  14. *
  15. * @param user
  16. * @param type
  17. * @param handler
  18. * return master_switch 总开关(1开,0关)',im_switch im消息开关(1开,0关)',family_topic_switch 健管师邀请后推送开关(1开,0关)',
  19. */
  20. static findOne(user,type, handler) {
  21. let sql = "SELECT MASTER_SWITCH,IM_SWITCH,FAMILY_TOPIC_SWITCH,SOUND_SWITCH,VIBRATION_SWITCH FROM " + DB_TABLES.MessageNoticeSetting + " S WHERE S.USER = ? AND S.TYPE=? ";
  22. ImDb.execQuery({
  23. "sql": sql,
  24. "args": [user,type],
  25. "handler": handler || function (err, res) {
  26. if(err) log.error(err);
  27. }
  28. });
  29. }
  30. /**
  31. * 保存MessageNoticeSetting
  32. *
  33. * @param user 用户id
  34. * @param type 用户类型 1doctor 2patient
  35. * @param createTime
  36. * @param handler 回调函数
  37. */
  38. static save(user, type, createTime, handler) {
  39. let sql = "INSERT INTO " + DB_TABLES.MessageNoticeSetting + " (USER,TYPE,MASTER_SWITCH,IM_SWITCH,FAMILY_TOPIC_SWITCH," +
  40. "SIGN_SWITCH,HEALTH_SIGN_SWITCH,SYSTEM_SWITCH,PRESCRIPTION_SWITCH,SOUND_SWITCH,VIBRATION_SWITCH,COORDINATION_SWITCH,CREATE_TIME)" +
  41. " VALUES (?,?,1,1,1,1,1,1,1,1,1,1,?)";
  42. ImDb.execQuery({
  43. "sql": sql,
  44. "args": [user, type, createTime.getTime()],
  45. "handler": handler
  46. });
  47. }
  48. }
  49. module.exports = MessageNoticeSettingRepo;