数据模型使用指针类型字段以避免空值自动更新的问题

This commit is contained in:
2025-05-26 10:57:39 +08:00
parent 1e7b5777a2
commit c08d625975
43 changed files with 457 additions and 397 deletions

View File

@@ -39,10 +39,10 @@ func UpdateUser(c *fiber.Ctx) error {
_, err = q.User.
Where(q.User.ID.Eq(authCtx.Payload.Id)).
Updates(m.User{
Username: req.Username,
Email: req.Email,
ContactQQ: req.ContactQQ,
ContactWechat: req.ContactWechat,
Username: &req.Username,
Email: &req.Email,
ContactQQ: &req.ContactQQ,
ContactWechat: &req.ContactWechat,
})
if err != nil {
return err
@@ -78,8 +78,8 @@ func UpdateAccount(c *fiber.Ctx) error {
_, err = q.User.
Where(q.User.ID.Eq(authCtx.Payload.Id)).
Updates(m.User{
Username: req.Username,
Password: req.Password,
Username: &req.Username,
Password: &req.Password,
})
if err != nil {
return err