feat: update

This commit is contained in:
yanghao05
2025-04-29 14:22:55 +08:00
parent c9740e6403
commit dfb3d8674c
9 changed files with 185 additions and 19 deletions

View File

@@ -343,3 +343,21 @@ func (m *usersModel) Count(ctx context.Context, cond BoolExpression) (int64, err
return cnt.Cnt, nil
}
// UpdateUsername
func (m *usersModel) UpdateUsername(ctx context.Context, id int64, username string) error {
tbl := table.Users
stmt := tbl.
UPDATE(tbl.Username).
SET(String(username)).
WHERE(
tbl.ID.EQ(Int64(id)),
)
m.log.Infof("sql: %s", stmt.DebugSql())
if _, err := stmt.ExecContext(ctx, db); err != nil {
m.log.Errorf("error updating username: %v", err)
return err
}
return nil
}