源战役
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
3.2 KiB

  1. %% ---------------------------------------------------------
  2. %% Author: xyao
  3. %% Email: jiexiaowen@gmail.com
  4. %% Created: 2012-5-4
  5. %% Description: 日 ,周,目标 ets
  6. %% --------------------------------------------------------
  7. -define(WEEK_KEY(CounterType), {mod_week, CounterType}).
  8. -define(DEFAULT_SUB_MODULE, 0). %% 默认模块子id设为0
  9. -define(DEFAULT_OTHER, []). %% 默认other扩展数据
  10. %% 周定时器类型
  11. -define(WEEK_TYPE_ZERO, 0). %% 以0点为周期的周定时器类型
  12. -define(WEEK_TYPE_FOUR, 4). %% 以4点为周期的周定时器类型
  13. %% 每天记录
  14. -record(ets_week, {
  15. id = {0,0,0}, %% {模块id, 模块子id, 类型}
  16. count = 0, %% 数量
  17. other = [], %% 扩展数据
  18. refresh_time = 0 %% 最后修改时间
  19. }).
  20. -record(base_week, {
  21. module = 0, %% 所属模块id
  22. sub_module = 0, %% 模块子id
  23. id = 0, %% 周常id
  24. limit = 0, %% 上限
  25. type = 0, %% 周定时器类型
  26. about ="" %% 描述
  27. }).
  28. %% 周计数器(0点分界)
  29. -define(SQL_WEEK_ZERO_ROLE_ALL,
  30. <<"SELECT `module`,`sub_module`,`type`,`count`,`other`,`refresh_time` FROM `counter_week` WHERE role_id=~p">>).
  31. -define(SQL_WEEK_ZERO_ROLE_UPDATE,
  32. <<"REPLACE INTO `counter_week` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p, ~p, ~p, ~p, ~p, '~ts', ~p)">>).
  33. -define(SQL_WEEK_ZERO_ROLE_UPDATE_BATCH,
  34. <<"REPLACE INTO `counter_week` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~ts">>).
  35. -define(SQL_WEEK_ZERO_ROLE_CLEAR,
  36. <<"delete from `counter_week` where `role_id` = ~p">>).
  37. -define(SQL_WEEK_ZERO_CLEAR,
  38. <<"DELETE FROM `counter_week` WHERE refresh_time < ~w">>).
  39. -define(SQL_WEEK_ZERO_ROLE,
  40. <<"SELECT `count`,`refresh_time`,`other` FROM `counter_week` WHERE role_id=~p and module = ~p and sub_module = ~p and type = ~p">>).
  41. %% 周计数器(4点分界)
  42. -define(SQL_WEEK_FOUR_ROLE_ALL,
  43. <<"SELECT `module`,`sub_module`,`type`,`count`,`other`,`refresh_time` FROM `counter_week_four` WHERE role_id=~p">>).
  44. -define(SQL_WEEK_FOUR_ROLE_UPDATE,
  45. <<"REPLACE INTO `counter_week_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p, ~p, ~p, ~p, ~p, '~ts', ~p)">>).
  46. -define(SQL_WEEK_FOUR_ROLE_UPDATE_BATCH,
  47. <<"REPLACE INTO `counter_week_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~ts">>).
  48. -define(SQL_WEEK_FOUR_ROLE_CLEAR,
  49. <<"delete from `counter_week_four` where `role_id` = ~p">>).
  50. -define(SQL_WEEK_FOUR_CLEAR,
  51. <<"DELETE FROM `counter_week_four` WHERE refresh_time < ~w">>).
  52. -define(SQL_WEEK_FOUR_ROLE,
  53. <<"SELECT `count`,`refresh_time`,`other` FROM `counter_week_four` WHERE role_id=~p and module = ~p and sub_module = ~p and type = ~p">>).
  54. %%%---------------------------------------------------------------------
  55. %%% 常量定义
  56. %%%---------------------------------------------------------------------