From ffc98f31c9430ae36ae8f3c133de5c87e577538c Mon Sep 17 00:00:00 2001 From: alick-liming Date: Fri, 13 Nov 2020 14:18:49 +0800 Subject: [PATCH] =?UTF-8?q?rdb=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4=E4=BB=A3=E7=A0=81=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20(#398)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * rdb资源增加volume * rdb用户增加创建时间 * rdb用户添加时间 * rdb新增添加用户时间代码调整 * test Co-authored-by: alickliming --- sql/n9e_rdb.sql | 2 +- src/models/user.go | 28 ++++++++++++++-------------- src/modules/rdb/http/router_user.go | 5 +---- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/sql/n9e_rdb.sql b/sql/n9e_rdb.sql index 53793ba0..ebefbe66 100644 --- a/sql/n9e_rdb.sql +++ b/sql/n9e_rdb.sql @@ -19,7 +19,7 @@ CREATE TABLE `user` `is_root` tinyint(1) not null, `leader_id` int unsigned not null default 0, `leader_name` varchar(32) not null default '', - `create_at` int unsigned not null default 0, + `create_at` timestamp not null default CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY (`username`), UNIQUE KEY (`uuid`) diff --git a/src/models/user.go b/src/models/user.go index 3cb8f1e1..5994a184 100644 --- a/src/models/user.go +++ b/src/models/user.go @@ -28,20 +28,20 @@ const ( ) type User struct { - Id int64 `json:"id"` - UUID string `json:"uuid" xorm:"'uuid'"` - Username string `json:"username"` - Password string `json:"-"` - Dispname string `json:"dispname"` - Phone string `json:"phone"` - Email string `json:"email"` - Im string `json:"im"` - Portrait string `json:"portrait"` - Intro string `json:"intro"` - IsRoot int `json:"is_root"` - LeaderId int64 `json:"leader_id"` - LeaderName string `json:"leader_name"` - CreateAt int64 `json:"create_at"` + Id int64 `json:"id"` + UUID string `json:"uuid" xorm:"'uuid'"` + Username string `json:"username"` + Password string `json:"-"` + Dispname string `json:"dispname"` + Phone string `json:"phone"` + Email string `json:"email"` + Im string `json:"im"` + Portrait string `json:"portrait"` + Intro string `json:"intro"` + IsRoot int `json:"is_root"` + LeaderId int64 `json:"leader_id"` + LeaderName string `json:"leader_name"` + CreateAt time.Time `json:"create_at" xorm:"<-"` } func (u *User) CopyLdapAttr(sr *ldap.SearchResult) { diff --git a/src/modules/rdb/http/router_user.go b/src/modules/rdb/http/router_user.go index 871543a5..c2cb5da0 100644 --- a/src/modules/rdb/http/router_user.go +++ b/src/modules/rdb/http/router_user.go @@ -64,7 +64,6 @@ func userAddPost(c *gin.Context) { IsRoot: f.IsRoot, LeaderId: f.LeaderId, UUID: models.GenUUIDForUser(f.Username), - CreateAt: time.Now().Unix(), } if f.LeaderId != 0 { @@ -273,8 +272,7 @@ func userInvitePost(c *gin.Context) { inv, err := models.InviteGet("token=?", f.Token) dangerous(err) - now := time.Now().Unix() - if inv.Expire < now { + if inv.Expire < time.Now().Unix() { dangerous("invite url already expired") } @@ -285,7 +283,6 @@ func userInvitePost(c *gin.Context) { Email: f.Email, Im: f.Im, UUID: models.GenUUIDForUser(f.Username), - CreateAt: now, } u.Password, err = models.CryptoPass(f.Password)