Fix service_user logic
Some checks failed
Backend Check Build (NixCN CMS) TeamCity build finished
Client CMS Check Build (NixCN CMS) TeamCity build failed

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-29 21:14:54 +08:00
parent 12a02d13dc
commit 9016b21464
3 changed files with 125 additions and 88 deletions

View File

@@ -127,12 +127,20 @@ func (self *User) Create(ctx context.Context) error {
return nil
}
func (self *User) UpdateByUserID(ctx context.Context, userId *uuid.UUID) error {
func (self *User) UpdateByUserID(ctx context.Context, userId *uuid.UUID, updates map[string]any) error {
return Database.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
if err := tx.Model(&User{}).Where("user_id = ?", userId).Updates(&self).Error; err != nil {
if err := tx.Model(&User{}).
Where("user_id = ?", userId).
Updates(updates).Error; err != nil {
return err
}
return nil
var updatedUser User
if err := tx.Where("user_id = ?", userId).First(&updatedUser).Error; err != nil {
return err
}
return updatedUser.UpdateSearchIndex(&ctx)
})
}