This commit is contained in:
oneao committed 2025-11-07 17:29:49 +08:00
1 parent d6dd5b032d
commit 8a6d29f5d0
16 files changed
+514 -69

No files matched your search

@@ -4,8 +4,10 @@ import (
"base-go-v2/internal/db"
response "base-go-v2/internal/reponse"
"base-go-v2/internal/router"
"base-go-v2/internal/routinex"
"base-go-v2/internal/utils/jwtx"
"base-go-v2/internal/utils/mapx"
"base-go-v2/internal/utils/timex"
"base-go-v2/internal/utils/uid"
)
@@ -102,10 +104,17 @@ func loginDefault(c *router.Context) error {
"username", user.GetString("username"),
"seqNo", user.GetInt("seq_no"),
"gender", user.GetInt("gender"),
"accessToken", accessToken,
"token", accessToken,
"refreshToken", refreshToken,
)
routinex.Go(func() {
kv := mapx.New().SetKV(
"last_login_time", timex.NowString(),
)
_, _ = db.UpdateOne("user_info", "id", userId, kv)
})
return response.Success(c).
Data(respData).
Send()
@@ -0,0 +1,39 @@
package timex
import "time"
// NowTime 返回当前时间对象(本地时区)
func NowTime() time.Time {
return time.Now()
}
// NowString 返回当前时间的字符串格式:YYYY-MM-DD HH:mm:ss
func NowString() string {
return time.Now().Format("2006-01-02 15:04:05")
}
// DateString 返回当前日期(年月日):YYYY-MM-DD
func DateString() string {
return time.Now().Format("2006-01-02")
}
// TimeString 返回当前时间(时分秒):HH:mm:ss
func TimeString() string {
return time.Now().Format("15:04:05")
}
// CustomFormat 返回指定格式的当前时间
// 例如:timeutil.CustomFormat("2006年01月02日 15时04分05秒")
func CustomFormat(format string) string {
return time.Now().Format(format)
}
// NowUnix 返回当前时间戳(秒)
func NowUnix() int64 {
return time.Now().Unix()
}
// NowUnixMilli 返回当前时间戳(毫秒)
func NowUnixMilli() int64 {
return time.Now().UnixMilli()
}