message-schema.sql 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. create table if not exists `message_config`
  2. (
  3. id int unsigned primary key not null auto_increment,
  4. code varchar(30) comment '唯一编码',
  5. order_num int comment '顺序',
  6. name varchar(100) comment '消息名',
  7. icon varchar(100) comment '图标',
  8. view_type int default 0 comment '视图类型 0 - widget, 1 - web',
  9. android_widget varchar(100) comment 'android控件',
  10. ios_widget varchar(100) comment 'ios控件',
  11. web_url varchar(300) comment '网页',
  12. scope_platform int default 0 comment '专属平台的应用 0 - ALL',
  13. scope_company_id bigint comment '专属企业的应用',
  14. company_relate int comment '与公司相关的类型 0 - COMPANY_OR_PERSONAL'
  15. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='消息配置';
  16. create table if not exists `message_company`
  17. (
  18. config_id int not null,
  19. company_id bigint not null
  20. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='企业绑定消息配置';
  21. create table if not exists `message_unread`
  22. (
  23. id bigint unsigned primary key not null auto_increment,
  24. code varchar(30) not null comment 'message_config.code',
  25. body varchar(1000) comment '消息内容',
  26. account_id bigint unsigned not null comment 'ac_account.id',
  27. company_id bigint comment 'ac_company.id',
  28. create_time datetime comment '创建时间',
  29. push_time datetime comment '推送到客户端时间',
  30. push_error_code int comment '推送相关错误码',
  31. push_error_msg varchar(500) comment '推送相关错误信息'
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='未读消息';
  33. create table if not exists `message_history`
  34. (
  35. id bigint unsigned primary key not null,
  36. code varchar(30) not null comment 'message_config.code',
  37. body varchar(1000) comment '消息内容',
  38. account_id bigint unsigned not null comment 'ac_account.id',
  39. company_id bigint comment 'ac_company.id',
  40. create_time datetime comment '创建时间',
  41. push_time datetime comment '推送到客户端时间',
  42. push_error_code int comment '推送相关错误码',
  43. push_error_msg varchar(500) comment '推送相关错误信息',
  44. read_time datetime comment '阅读时间',
  45. read_platform int comment '在哪个平台/系统阅读的'
  46. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='已读消息';
  47. drop procedure if exists `p_message_all_read`;
  48. DELIMITER ;;
  49. create procedure `p_message_all_read`
  50. (
  51. in i_account_id bigint,
  52. in i_platform int
  53. )
  54. begin
  55. insert into message_history(id,code,body,account_id,company_id,create_time,push_time,push_error_code,
  56. push_error_msg,read_time,read_platform)
  57. select id,code,body,account_id,company_id,create_time,push_time,push_error_code,push_error_msg,sysdate(),
  58. i_platform from message_unread where account_id=i_account_id;
  59. delete from message_unread where account_id=i_account_id;
  60. commit;
  61. end
  62. ;;
  63. DELIMITER ;