Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gorm查询出来的结构体COPY 的时候ID,CreatedAt,UpdatedAt没有成功, #221

Open
hjw33210 opened this issue Oct 31, 2024 · 0 comments
Assignees

Comments

@hjw33210
Copy link

value := &sysV1.Users{}
err := copier.Copy(value, record)
if err != nil {
return nil, err
}

value.Dept.Id = record.Dept.ID
for i, role := range value.Roles {
	role.Id = record.Roles[i].ID
	role.CreatedAt = record.Roles[i].CreatedAt.Format(time.RFC3339)
	role.UpdatedAt = record.Roles[i].UpdatedAt.Format(time.RFC3339)
}
value.Id = record.ID
value.Dept.CreatedAt = record.Dept.CreatedAt.Format(time.RFC3339)
value.Dept.UpdatedAt = record.Dept.UpdatedAt.Format(time.RFC3339)
value.CreatedAt = record.CreatedAt.Format(time.RFC3339)
value.UpdatedAt = record.UpdatedAt.Format(time.RFC3339)

需要自行再次添加

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants