diff --git a/build/doc/db.sql b/build/doc/db.sql index e63c72f..8622d97 100644 --- a/build/doc/db.sql +++ b/build/doc/db.sql @@ -12,6 +12,22 @@ CREATE TABLE `tank20_download_token` UNIQUE KEY `id_UNIQUE` (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='下载的token表'; +CREATE TABLE `tank20_footprint` +( + `uuid` char(36) NOT NULL, + `user_uuid` char(36) DEFAULT NULL, + `ip` varchar(45) DEFAULT NULL, + `host` varchar(45) DEFAULT NULL, + `uri` varchar(255) DEFAULT NULL, + `params` text, + `cost` int(11) DEFAULT '0' COMMENT '耗时 ms', + `success` tinyint(1) DEFAULT '1', + `sort` bigint(20) NOT NULL DEFAULT '0', + `update_time` timestamp NULL DEFAULT NULL, + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问记录表'; + CREATE TABLE `tank20_image_cache` ( `uuid` char(36) NOT NULL, @@ -40,6 +56,7 @@ CREATE TABLE `tank20_matter` `size` bigint(20) DEFAULT '0' COMMENT '文件大小', `privacy` tinyint(1) DEFAULT '0' COMMENT '文件是否是公有的', `path` varchar(255) DEFAULT NULL, + `times` bigint(20) DEFAULT '0' COMMENT '下载次数', `sort` bigint(20) DEFAULT NULL, `update_time` timestamp NULL DEFAULT NULL, `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', @@ -63,33 +80,15 @@ CREATE TABLE `tank20_preference` UNIQUE KEY `id_UNIQUE` (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='网站偏好设置表'; -CREATE TABLE `tank20_security_visit` -( - `uuid` char(36) NOT NULL, - `session_id` varchar(45) DEFAULT NULL, - `user_uuid` char(36) DEFAULT NULL, - `ip` varchar(45) DEFAULT NULL, - `host` varchar(45) DEFAULT NULL, - `uri` varchar(255) DEFAULT NULL, - `params` text, - `cost` int(11) DEFAULT '0' COMMENT '耗时 ms', - `success` tinyint(1) DEFAULT '1', - `sort` bigint(20) NOT NULL DEFAULT '0', - `update_time` timestamp NULL DEFAULT NULL, - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`uuid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='访问记录表'; - CREATE TABLE `tank20_session` ( - `uuid` char(36) NOT NULL, - `authentication` char(36) DEFAULT NULL COMMENT '认证身份,存放在cookie中', - `user_uuid` char(36) DEFAULT NULL COMMENT '用户uuid', - `ip` varchar(45) DEFAULT NULL COMMENT '用户的ip地址', - `expire_time` timestamp NULL DEFAULT NULL, - `sort` bigint(20) DEFAULT NULL, - `update_time` timestamp NULL DEFAULT NULL, - `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `uuid` char(36) NOT NULL, + `user_uuid` char(36) DEFAULT NULL COMMENT '用户uuid', + `ip` varchar(45) DEFAULT NULL COMMENT '用户的ip地址', + `expire_time` timestamp NULL DEFAULT NULL, + `sort` bigint(20) DEFAULT NULL, + `update_time` timestamp NULL DEFAULT NULL, + `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`uuid`), UNIQUE KEY `id_UNIQUE` (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='session表'; @@ -131,5 +130,7 @@ CREATE TABLE `tank20_user` `update_time` timestamp NULL DEFAULT NULL, `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', PRIMARY KEY (`uuid`), - UNIQUE KEY `id_UNIQUE` (`uuid`) + UNIQUE KEY `id_UNIQUE` (`uuid`), + UNIQUE KEY `email_UNIQUE` (`email`), + UNIQUE KEY `username_UNIQUE` (`username`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表描述'; diff --git a/rest/logger.go b/rest/logger.go index 3128761..dc02da1 100644 --- a/rest/logger.go +++ b/rest/logger.go @@ -67,6 +67,7 @@ func (this *Logger) Init() { //日志需要自我备份,自我维护。明天第一秒触发 nextTime := FirstSecondOfDay(Tomorrow()) duration := nextTime.Sub(time.Now()) + go this.Info("%vs后将进行下一次日志维护 下次时间%v ", int64(duration/time.Second), nextTime) this.maintainTimer = time.AfterFunc(duration, func() { go this.maintain() }) @@ -100,12 +101,12 @@ func (this *Logger) maintain() { now := time.Now() nextTime := FirstSecondOfDay(Tomorrow()) duration := nextTime.Sub(now) + go this.Info("%vs后将进行下一次日志维护 下次时间维护时间:%v ", int64(duration/time.Second), nextTime) this.maintainTimer = time.AfterFunc(duration, func() { go this.maintain() }) } - //日志名称 func (this *Logger) fileName() string { return GetLogPath() + "/tank.log" diff --git a/rest/util_time.go b/rest/util_time.go index 6b137f9..f55d659 100644 --- a/rest/util_time.go +++ b/rest/util_time.go @@ -30,13 +30,13 @@ func FirstSecondOfDay(day time.Time) time.Time { //明天此刻的时间 func Tomorrow() time.Time { tomorrow := time.Now() - tomorrow.AddDate(0, 0, 1) + tomorrow = tomorrow.AddDate(0, 0, 1) return tomorrow } //昨天此刻的时间 func Yesterday() time.Time { tomorrow := time.Now() - tomorrow.AddDate(0, 0, -1) + tomorrow = tomorrow.AddDate(0, 0, -1) return tomorrow }