fix: 使用 UUIDv7 生成 UUID,设置 create_time 和 update_time 为东八区时区
This commit is contained in:
@@ -41,7 +41,7 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
|
||||
}
|
||||
|
||||
// 创建用户
|
||||
userID := uuid.New()
|
||||
userID := uuid.NewV7()
|
||||
now := time.Now()
|
||||
|
||||
userQuery := "INSERT INTO user_main (id, deleted, create_time, update_time) VALUES ($1, $2, $3, $4)"
|
||||
@@ -51,7 +51,7 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
|
||||
}
|
||||
|
||||
// 创建登录账号
|
||||
accountID := uuid.New()
|
||||
accountID := uuid.NewV7()
|
||||
accountQuery := "INSERT INTO user_login_account (id, user_id, account, deleted, create_time, update_time) VALUES ($1, $2, $3, $4, $5, $6)"
|
||||
if _, err := tx.Exec(accountQuery, accountID, userID, req.Account, false, now, now); err != nil {
|
||||
tx.Rollback()
|
||||
@@ -66,7 +66,7 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
|
||||
}
|
||||
|
||||
// 创建密码记录
|
||||
passwordID := uuid.New()
|
||||
passwordID := uuid.NewV7()
|
||||
passwordQuery := "INSERT INTO user_login_password (id, user_id, password, deleted, create_time, update_time) VALUES ($1, $2, $3, $4, $5, $6)"
|
||||
if _, err := tx.Exec(passwordQuery, passwordID, userID, string(hashedPassword), false, now, now); err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
Reference in New Issue
Block a user