feat(auth): access token 缩到 2 小时 + refresh token 机制 #3

Merged
Blizzard merged 58 commits from feat/dev into main 2026-07-30 10:18:07 +00:00
2 changed files with 16 additions and 0 deletions
Showing only changes of commit de2b72221c - Show all commits
+4
View File
@@ -25,6 +25,10 @@ func New(cfg *config.Config) (*gorm.DB, error) {
TablePrefix: "sundynix_", TablePrefix: "sundynix_",
SingularTable: false, SingularTable: false,
}, },
// 关联在 Go 层管,不靠库级外键。迁移期建外键时 MySQL 会为外键列自动
// 补一个索引,和字段上的 `index` tag 撞成同名索引,父子表同迁时第二次
// 建索引报 1061 duplicate。关掉外键约束创建,索引就只由 index tag 建一次
DisableForeignKeyConstraintWhenMigrating: true,
Logger: logger.Default.LogMode(logLevel), Logger: logger.Default.LogMode(logLevel),
}) })
if err != nil { if err != nil {
+12
View File
@@ -126,6 +126,18 @@ func (h *Handler) UpdatePet(c *gin.Context) {
if req.Breed != "" { if req.Breed != "" {
fields["breed"] = req.Breed fields["breed"] = req.Breed
} }
// 生日和到家日期是日期列,得先解析成 time。之前漏了这两个,
// 导致编辑档案时改到家日期不落库(建档走 toInput 才正常)
if req.Birthday != "" {
if t, err := time.ParseInLocation("2006-01-02", req.Birthday, time.Local); err == nil {
fields["birthday"] = t
}
}
if req.ArrivedAt != "" {
if t, err := time.ParseInLocation("2006-01-02", req.ArrivedAt, time.Local); err == nil && !t.After(time.Now()) {
fields["arrived_at"] = t
}
}
if req.AvatarFileID != "" { if req.AvatarFileID != "" {
fields["avatar_file_id"] = req.AvatarFileID fields["avatar_file_id"] = req.AvatarFileID
} }