- 在 EditHostState 方法中添加了 Model(&model.GlobalLimit{}) 以指定更新的表 - 这样可以避免潜在的 SQL 错误,提高代码的健壮性
@@ -164,7 +164,7 @@ func (r *globalLimitRepository) GetNodeArea(ctx context.Context, nodeAreaName st
}
func (r *globalLimitRepository) EditHostState(ctx context.Context, hostId int64, state int) error {
- if err := r.DB(ctx).Where("host_id = ?", hostId).Update("state", state).Error; err != nil {
+ if err := r.DB(ctx).Model(&model.GlobalLimit{}).Where("host_id = ?", hostId).Update("state", state).Error; err != nil {
return err
return nil