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
02aacb38
authored
Apr 25, 2026
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add user created_at and last_login_at
parent
a7c38ec8
Show 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 @
02aacb38
...
...
@@ -91,6 +91,7 @@ func Login(c *gin.Context) {
// setup session & cookies and then return user info
func
setupLogin
(
user
*
model
.
User
,
c
*
gin
.
Context
)
{
model
.
UpdateUserLastLoginAt
(
user
.
Id
)
session
:=
sessions
.
Default
(
c
)
session
.
Set
(
"id"
,
user
.
Id
)
session
.
Set
(
"username"
,
user
.
Username
)
...
...
model/user.go
View file @
02aacb38
...
...
@@ -50,6 +50,8 @@ type User struct {
Setting
string
`json:"setting" gorm:"type:text;column:setting"`
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"`
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
{
...
...
@@ -951,6 +953,12 @@ func GetRootUser() (user *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
)
{
if
common
.
BatchUpdateEnabled
{
addNewRecord
(
BatchUpdateTypeUsedQuota
,
id
,
quota
)
...
...
web/src/components/table/users/UsersColumnDefs.jsx
View file @
02aacb38
...
...
@@ -29,7 +29,14 @@ import {
Dropdown
,
}
from
'@douyinfe/semi-ui'
;
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
...
...
@@ -351,6 +358,16 @@ export const getUsersColumns = ({
render
:
(
text
,
record
,
index
)
=>
renderInviteInfo
(
text
,
record
,
t
),
},
{
title
:
t
(
'创建时间'
),
dataIndex
:
'created_at'
,
render
:
renderTimestamp
,
},
{
title
:
t
(
'最后登录'
),
dataIndex
:
'last_login_at'
,
render
:
renderTimestamp
,
},
{
title
:
''
,
dataIndex
:
'operate'
,
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