rdb新增用户添加时间 (#397)
* rdb资源增加volume * rdb用户增加创建时间 * rdb用户添加时间 Co-authored-by: alickliming <alickliming@didi.global.com>
This commit is contained in:
parent
dd67efe0f6
commit
1a71de851a
|
@ -19,6 +19,7 @@ CREATE TABLE `user`
|
||||||
`is_root` tinyint(1) not null,
|
`is_root` tinyint(1) not null,
|
||||||
`leader_id` int unsigned not null default 0,
|
`leader_id` int unsigned not null default 0,
|
||||||
`leader_name` varchar(32) not null default '',
|
`leader_name` varchar(32) not null default '',
|
||||||
|
`create_at` int unsigned not null default 0,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY (`username`),
|
UNIQUE KEY (`username`),
|
||||||
UNIQUE KEY (`uuid`)
|
UNIQUE KEY (`uuid`)
|
||||||
|
|
|
@ -41,6 +41,7 @@ type User struct {
|
||||||
IsRoot int `json:"is_root"`
|
IsRoot int `json:"is_root"`
|
||||||
LeaderId int64 `json:"leader_id"`
|
LeaderId int64 `json:"leader_id"`
|
||||||
LeaderName string `json:"leader_name"`
|
LeaderName string `json:"leader_name"`
|
||||||
|
CreateAt int64 `json:"create_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) CopyLdapAttr(sr *ldap.SearchResult) {
|
func (u *User) CopyLdapAttr(sr *ldap.SearchResult) {
|
||||||
|
@ -640,3 +641,13 @@ func GetUsersNameByIds(ids string) ([]string, error) {
|
||||||
}
|
}
|
||||||
return names, err
|
return names, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func UsersGet(where string, args ...interface{}) ([]User, error) {
|
||||||
|
var objs []User
|
||||||
|
err := DB["rdb"].Where(where, args...).Find(&objs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return objs, nil
|
||||||
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ func userAddPost(c *gin.Context) {
|
||||||
IsRoot: f.IsRoot,
|
IsRoot: f.IsRoot,
|
||||||
LeaderId: f.LeaderId,
|
LeaderId: f.LeaderId,
|
||||||
UUID: models.GenUUIDForUser(f.Username),
|
UUID: models.GenUUIDForUser(f.Username),
|
||||||
|
CreateAt: time.Now().Unix(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.LeaderId != 0 {
|
if f.LeaderId != 0 {
|
||||||
|
@ -272,7 +273,8 @@ func userInvitePost(c *gin.Context) {
|
||||||
inv, err := models.InviteGet("token=?", f.Token)
|
inv, err := models.InviteGet("token=?", f.Token)
|
||||||
dangerous(err)
|
dangerous(err)
|
||||||
|
|
||||||
if inv.Expire < time.Now().Unix() {
|
now := time.Now().Unix()
|
||||||
|
if inv.Expire < now {
|
||||||
dangerous("invite url already expired")
|
dangerous("invite url already expired")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,6 +285,7 @@ func userInvitePost(c *gin.Context) {
|
||||||
Email: f.Email,
|
Email: f.Email,
|
||||||
Im: f.Im,
|
Im: f.Im,
|
||||||
UUID: models.GenUUIDForUser(f.Username),
|
UUID: models.GenUUIDForUser(f.Username),
|
||||||
|
CreateAt: now,
|
||||||
}
|
}
|
||||||
|
|
||||||
u.Password, err = models.CryptoPass(f.Password)
|
u.Password, err = models.CryptoPass(f.Password)
|
||||||
|
|
Loading…
Reference in New Issue