Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
e36d191c
authored
Apr 26, 2026
by
Calcium-Ion
Committed by
GitHub
Apr 26, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4450 from feitianbubu/pr/7fa4a87ad953642a2f454ad0813a0c8b6ac361c6
增加用户创建时间和最后登录时间
parents
34afe9b4
02aacb38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
1 deletions
+27
-1
controller/user.go
+1
-0
model/user.go
+8
-0
web/src/components/table/users/UsersColumnDefs.jsx
+18
-1
No files found.
controller/user.go
View file @
e36d191c
...
@@ -91,6 +91,7 @@ func Login(c *gin.Context) {
...
@@ -91,6 +91,7 @@ func Login(c *gin.Context) {
// setup session & cookies and then return user info
// setup session & cookies and then return user info
func
setupLogin
(
user
*
model
.
User
,
c
*
gin
.
Context
)
{
func
setupLogin
(
user
*
model
.
User
,
c
*
gin
.
Context
)
{
model
.
UpdateUserLastLoginAt
(
user
.
Id
)
session
:=
sessions
.
Default
(
c
)
session
:=
sessions
.
Default
(
c
)
session
.
Set
(
"id"
,
user
.
Id
)
session
.
Set
(
"id"
,
user
.
Id
)
session
.
Set
(
"username"
,
user
.
Username
)
session
.
Set
(
"username"
,
user
.
Username
)
...
...
model/user.go
View file @
e36d191c
...
@@ -50,6 +50,8 @@ type User struct {
...
@@ -50,6 +50,8 @@ type User struct {
Setting
string
`json:"setting" gorm:"type:text;column:setting"`
Setting
string
`json:"setting" gorm:"type:text;column:setting"`
Remark
string
`json:"remark,omitempty" gorm:"type:varchar(255)" validate:"max=255"`
Remark
string
`json:"remark,omitempty" gorm:"type:varchar(255)" validate:"max=255"`
StripeCustomer
string
`json:"stripe_customer" gorm:"type:varchar(64);column:stripe_customer;index"`
StripeCustomer
string
`json:"stripe_customer" gorm:"type:varchar(64);column:stripe_customer;index"`
CreatedAt
int64
`json:"created_at" gorm:"autoCreateTime;column:created_at"`
LastLoginAt
int64
`json:"last_login_at" gorm:"default:0;column:last_login_at"`
}
}
func
(
user
*
User
)
ToBaseUser
()
*
UserBase
{
func
(
user
*
User
)
ToBaseUser
()
*
UserBase
{
...
@@ -951,6 +953,12 @@ func GetRootUser() (user *User) {
...
@@ -951,6 +953,12 @@ func GetRootUser() (user *User) {
return
user
return
user
}
}
func
UpdateUserLastLoginAt
(
id
int
)
{
if
err
:=
DB
.
Model
(
&
User
{})
.
Where
(
"id = ?"
,
id
)
.
Update
(
"last_login_at"
,
common
.
GetTimestamp
())
.
Error
;
err
!=
nil
{
common
.
SysLog
(
"failed to update user last_login_at: "
+
err
.
Error
())
}
}
func
UpdateUserUsedQuotaAndRequestCount
(
id
int
,
quota
int
)
{
func
UpdateUserUsedQuotaAndRequestCount
(
id
int
,
quota
int
)
{
if
common
.
BatchUpdateEnabled
{
if
common
.
BatchUpdateEnabled
{
addNewRecord
(
BatchUpdateTypeUsedQuota
,
id
,
quota
)
addNewRecord
(
BatchUpdateTypeUsedQuota
,
id
,
quota
)
...
...
web/src/components/table/users/UsersColumnDefs.jsx
View file @
e36d191c
...
@@ -29,7 +29,14 @@ import {
...
@@ -29,7 +29,14 @@ import {
Dropdown
,
Dropdown
,
}
from
'@douyinfe/semi-ui'
;
}
from
'@douyinfe/semi-ui'
;
import
{
IconMore
}
from
'@douyinfe/semi-icons'
;
import
{
IconMore
}
from
'@douyinfe/semi-icons'
;
import
{
renderGroup
,
renderNumber
,
renderQuota
}
from
'../../../helpers'
;
import
{
renderGroup
,
renderNumber
,
renderQuota
,
timestamp2string
,
}
from
'../../../helpers'
;
const
renderTimestamp
=
(
text
)
=>
(
text
?
timestamp2string
(
text
)
:
'-'
);
/**
/**
* Render user role
* Render user role
...
@@ -351,6 +358,16 @@ export const getUsersColumns = ({
...
@@ -351,6 +358,16 @@ export const getUsersColumns = ({
render
:
(
text
,
record
,
index
)
=>
renderInviteInfo
(
text
,
record
,
t
),
render
:
(
text
,
record
,
index
)
=>
renderInviteInfo
(
text
,
record
,
t
),
},
},
{
{
title
:
t
(
'创建时间'
),
dataIndex
:
'created_at'
,
render
:
renderTimestamp
,
},
{
title
:
t
(
'最后登录'
),
dataIndex
:
'last_login_at'
,
render
:
renderTimestamp
,
},
{
title
:
''
,
title
:
''
,
dataIndex
:
'operate'
,
dataIndex
:
'operate'
,
fixed
:
'right'
,
fixed
:
'right'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment