|
%% ---------------------------------------------------------
|
|
%% Author: xyao
|
|
%% Email: jiexiaowen@gmail.com
|
|
%% Created: 2012-5-4
|
|
%% Description: 日 ,周,目标 ets
|
|
%% --------------------------------------------------------
|
|
|
|
-define(WEEK_KEY(CounterType), {mod_week, CounterType}).
|
|
|
|
-define(DEFAULT_SUB_MODULE, 0). %% 默认模块子id设为0
|
|
-define(DEFAULT_OTHER, []). %% 默认other扩展数据
|
|
|
|
%% 周定时器类型
|
|
-define(WEEK_TYPE_ZERO, 0). %% 以0点为周期的周定时器类型
|
|
-define(WEEK_TYPE_FOUR, 4). %% 以4点为周期的周定时器类型
|
|
|
|
%% 每天记录
|
|
-record(ets_week, {
|
|
id = {0,0,0}, %% {模块id, 模块子id, 类型}
|
|
count = 0, %% 数量
|
|
other = [], %% 扩展数据
|
|
refresh_time = 0 %% 最后修改时间
|
|
}).
|
|
|
|
-record(base_week, {
|
|
module = 0, %% 所属模块id
|
|
sub_module = 0, %% 模块子id
|
|
id = 0, %% 周常id
|
|
limit = 0, %% 上限
|
|
type = 0, %% 周定时器类型
|
|
about ="" %% 描述
|
|
}).
|
|
|
|
%% 周计数器(0点分界)
|
|
-define(SQL_WEEK_ZERO_ROLE_ALL,
|
|
<<"SELECT `module`,`sub_module`,`type`,`count`,`other`,`refresh_time` FROM `counter_week` WHERE role_id=~p">>).
|
|
-define(SQL_WEEK_ZERO_ROLE_UPDATE,
|
|
<<"REPLACE INTO `counter_week` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p, ~p, ~p, ~p, ~p, '~ts', ~p)">>).
|
|
-define(SQL_WEEK_ZERO_ROLE_UPDATE_BATCH,
|
|
<<"REPLACE INTO `counter_week` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~ts">>).
|
|
|
|
-define(SQL_WEEK_ZERO_ROLE_CLEAR,
|
|
<<"delete from `counter_week` where `role_id` = ~p">>).
|
|
-define(SQL_WEEK_ZERO_CLEAR,
|
|
<<"DELETE FROM `counter_week` WHERE refresh_time < ~w">>).
|
|
-define(SQL_WEEK_ZERO_ROLE,
|
|
<<"SELECT `count`,`refresh_time`,`other` FROM `counter_week` WHERE role_id=~p and module = ~p and sub_module = ~p and type = ~p">>).
|
|
|
|
%% 周计数器(4点分界)
|
|
-define(SQL_WEEK_FOUR_ROLE_ALL,
|
|
<<"SELECT `module`,`sub_module`,`type`,`count`,`other`,`refresh_time` FROM `counter_week_four` WHERE role_id=~p">>).
|
|
-define(SQL_WEEK_FOUR_ROLE_UPDATE,
|
|
<<"REPLACE INTO `counter_week_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES (~p, ~p, ~p, ~p, ~p, '~ts', ~p)">>).
|
|
-define(SQL_WEEK_FOUR_ROLE_UPDATE_BATCH,
|
|
<<"REPLACE INTO `counter_week_four` (`role_id`,`module`,`sub_module`,`type`,`count`,`other`,`refresh_time`) VALUES ~ts">>).
|
|
-define(SQL_WEEK_FOUR_ROLE_CLEAR,
|
|
<<"delete from `counter_week_four` where `role_id` = ~p">>).
|
|
-define(SQL_WEEK_FOUR_CLEAR,
|
|
<<"DELETE FROM `counter_week_four` WHERE refresh_time < ~w">>).
|
|
-define(SQL_WEEK_FOUR_ROLE,
|
|
<<"SELECT `count`,`refresh_time`,`other` FROM `counter_week_four` WHERE role_id=~p and module = ~p and sub_module = ~p and type = ~p">>).
|
|
%%%---------------------------------------------------------------------
|
|
%%% 常量定义
|
|
%%%---------------------------------------------------------------------
|