mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-09-26 20:11:11 +08:00
feat: 日期、时间 Now实现
This commit is contained in:
@@ -45,7 +45,7 @@ type AdminClaims struct {
|
||||
// 管理员Seeder
|
||||
func (model *Admin) Seeder() {
|
||||
seeders := []Admin{
|
||||
{Username: "administrator", Nickname: "超级管理员", Email: "admin@yourweb.com", Phone: "10086", Password: hash.Make("123456"), Sex: 1, Status: 1, LastLoginTime: datetime.Time{Time: time.Now()}},
|
||||
{Username: "administrator", Nickname: "超级管理员", Email: "admin@yourweb.com", Phone: "10086", Password: hash.Make("123456"), Sex: 1, Status: 1, LastLoginTime: datetime.TimeNow()},
|
||||
}
|
||||
|
||||
db.Client.Create(&seeders)
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package logins
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/form/rule"
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/icon"
|
||||
@@ -125,7 +123,7 @@ func (p *Index) Handle(ctx *builder.Context) error {
|
||||
}
|
||||
|
||||
// 更新登录信息
|
||||
(&model.Admin{}).UpdateLastLogin(adminInfo.Id, ctx.ClientIP(), datetime.Time{Time: time.Now()})
|
||||
(&model.Admin{}).UpdateLastLogin(adminInfo.Id, ctx.ClientIP(), datetime.TimeNow())
|
||||
|
||||
// 获取token字符串
|
||||
tokenString, err := ctx.JwtToken((&model.Admin{}).GetClaims(adminInfo))
|
||||
|
@@ -61,7 +61,7 @@ func (model *User) Seeder() {
|
||||
db.Client.Create(&menuSeeders)
|
||||
|
||||
seeders := []User{
|
||||
{Username: "tangtanglove", Nickname: "默认用户", Email: "tangtanglove@yourweb.com", Phone: "10086", Password: hash.Make("123456"), Sex: 1, Status: 1, LastLoginTime: datetime.Time{Time: time.Now()}},
|
||||
{Username: "tangtanglove", Nickname: "默认用户", Email: "tangtanglove@yourweb.com", Phone: "10086", Password: hash.Make("123456"), Sex: 1, Status: 1, LastLoginTime: datetime.TimeNow()},
|
||||
}
|
||||
|
||||
db.Client.Create(&seeders)
|
||||
|
@@ -11,6 +11,13 @@ type Date struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
// 当前日期
|
||||
func DateNow() Date {
|
||||
return Date{
|
||||
Time: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
// 编码为自定义的Json格式
|
||||
func (t Date) MarshalJSON() ([]byte, error) {
|
||||
|
||||
|
@@ -11,6 +11,13 @@ type Time struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
// 当前时间
|
||||
func TimeNow() Time {
|
||||
return Time{
|
||||
Time: time.Now(),
|
||||
}
|
||||
}
|
||||
|
||||
// 编码为自定义的Json格式
|
||||
func (t Time) MarshalJSON() ([]byte, error) {
|
||||
|
||||
@@ -83,4 +90,4 @@ func (t *Time) Scan(i interface{}) error {
|
||||
// 返回字符串
|
||||
func (t *Time) String() string {
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user