fix(be): 编辑档案补写到家日期/生日;关迁移期外键修复重复索引
- UpdatePet 的 fields map 之前漏了 birthday 和 arrived_at, 导致编辑档案改到家日期不落库(首页天数一直显示「-」) - DisableForeignKeyConstraintWhenMigrating:外键列自动索引和字段 index tag 撞成同名索引,父子表同迁时报 1061,关掉库级外键约束创建 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -126,6 +126,18 @@ func (h *Handler) UpdatePet(c *gin.Context) {
|
||||
if 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 != "" {
|
||||
fields["avatar_file_id"] = req.AvatarFileID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user