调整日志输出方式,更新数据库日志存储结构;首页查询统计数据接口实现
This commit is contained in:
@@ -7,7 +7,7 @@ drop table if exists logs_request cascade;
|
||||
create table logs_request (
|
||||
id serial primary key,
|
||||
|
||||
identity int,
|
||||
identity int not null,
|
||||
visitor int,
|
||||
ip varchar(45) not null,
|
||||
ua varchar(255),
|
||||
@@ -15,12 +15,14 @@ create table logs_request (
|
||||
method varchar(10) not null,
|
||||
path varchar(255) not null,
|
||||
|
||||
latency varchar(255),
|
||||
status int not null,
|
||||
error varchar(255),
|
||||
error text,
|
||||
|
||||
time timestamp default current_timestamp
|
||||
time timestamp not null,
|
||||
latency varchar(255) not null
|
||||
);
|
||||
create index logs_request_identity_index on logs_request (identity);
|
||||
create index logs_request_visitor_index on logs_request (visitor);
|
||||
|
||||
-- logs_access表字段注释
|
||||
comment on table logs_request is '访问日志表';
|
||||
@@ -31,10 +33,83 @@ comment on column logs_request.ip is 'IP地址';
|
||||
comment on column logs_request.ua is '用户代理';
|
||||
comment on column logs_request.method is '请求方法';
|
||||
comment on column logs_request.path is '请求路径';
|
||||
comment on column logs_request.latency is '请求延迟';
|
||||
comment on column logs_request.status is '响应状态码';
|
||||
comment on column logs_request.error is '错误信息';
|
||||
comment on column logs_request.time is '请求时间';
|
||||
comment on column logs_request.latency is '请求延迟';
|
||||
|
||||
-- logs_login
|
||||
|
||||
drop table if exists logs_login cascade;
|
||||
create table logs_login (
|
||||
id serial primary key,
|
||||
ip varchar(45) not null,
|
||||
ua varchar(255) not null,
|
||||
grant_type varchar(255) not null,
|
||||
password_grant_type varchar(255) not null,
|
||||
success bool not null,
|
||||
user_id int,
|
||||
time timestamp not null
|
||||
);
|
||||
create index logs_login_user_id_index on logs_login (user_id);
|
||||
|
||||
-- logs_login表字段注释
|
||||
comment on table logs_login is '登录日志表';
|
||||
comment on column logs_login.id is '登录日志ID';
|
||||
comment on column logs_login.user_id is '用户ID';
|
||||
comment on column logs_login.ip is 'IP地址';
|
||||
comment on column logs_login.ua is '用户代理';
|
||||
comment on column logs_login.grant_type is '授权类型:authorization_code-授权码模式,client_credentials-客户端凭证模式,refresh_token-刷新令牌模式,password-密码模式';
|
||||
comment on column logs_login.password_grant_type is '密码模式子授权类型:password-账号密码,phone_code-手机验证码,email_code-邮箱验证码';
|
||||
comment on column logs_login.success is '登录是否成功';
|
||||
comment on column logs_login.time is '登录时间';
|
||||
|
||||
-- logs_user_usage
|
||||
drop table if exists logs_user_usage cascade;
|
||||
create table logs_user_usage (
|
||||
id serial primary key,
|
||||
user_id int not null,
|
||||
resource_id int not null,
|
||||
count int not null,
|
||||
prov varchar(255),
|
||||
city varchar(255),
|
||||
isp varchar(255),
|
||||
ip varchar(45) not null,
|
||||
time timestamp not null
|
||||
);
|
||||
create index logs_user_usage_user_id_index on logs_user_usage (user_id);
|
||||
create index logs_user_usage_resource_id_index on logs_user_usage (resource_id);
|
||||
|
||||
-- logs_user_usage表字段注释
|
||||
comment on table logs_user_usage is '用户使用日志表';
|
||||
comment on column logs_user_usage.id is '日志ID';
|
||||
comment on column logs_user_usage.user_id is '用户ID';
|
||||
comment on column logs_user_usage.resource_id is '套餐ID';
|
||||
comment on column logs_user_usage.count is '数量';
|
||||
comment on column logs_user_usage.prov is '省份';
|
||||
comment on column logs_user_usage.city is '城市';
|
||||
comment on column logs_user_usage.isp is '运营商';
|
||||
comment on column logs_user_usage.ip is 'IP地址';
|
||||
comment on column logs_user_usage.time is '提取时间';
|
||||
|
||||
-- logs_user_bandwidth
|
||||
drop table if exists logs_user_bandwidth cascade;
|
||||
create table logs_user_bandwidth (
|
||||
id serial primary key,
|
||||
user_id int not null,
|
||||
bandwidth int not null,
|
||||
time timestamp not null
|
||||
);
|
||||
create index logs_user_bandwidth_user_id_index on logs_user_bandwidth (user_id);
|
||||
|
||||
-- logs_user_bandwidth表字段注释
|
||||
comment on table logs_user_bandwidth is '用户带宽日志表';
|
||||
comment on column logs_user_bandwidth.id is '日志ID';
|
||||
comment on column logs_user_bandwidth.user_id is '用户ID';
|
||||
comment on column logs_user_bandwidth.bandwidth is '带宽使用量(KB)';
|
||||
comment on column logs_user_bandwidth.time is '记录时间';
|
||||
|
||||
-- logs_user_bandwidth
|
||||
|
||||
-- endregion
|
||||
|
||||
@@ -806,7 +881,7 @@ create table trade (
|
||||
payment decimal(12, 2) not null default 0,
|
||||
method int not null,
|
||||
platform int not null,
|
||||
acquirer int ,
|
||||
acquirer int,
|
||||
status int not null default 0,
|
||||
pay_url text,
|
||||
paid_at timestamp,
|
||||
|
||||
Reference in New Issue
Block a user