MCPcopy Create free account
hub / github.com/astercloud/aster / UpdatePreference

Method UpdatePreference

pkg/memory/preference.go:230–249  ·  view source on GitHub ↗

UpdatePreference 更新偏好

(
	ctx context.Context,
	userID string,
	category PreferenceCategory,
	key string,
	value string,
)

Source from the content-addressed store, hash-verified

228
229// UpdatePreference 更新偏好
230func (pm *PreferenceManager) UpdatePreference(
231 ctx context.Context,
232 userID string,
233 category PreferenceCategory,
234 key string,
235 value string,
236) error {
237 pm.mu.Lock()
238 defer pm.mu.Unlock()
239
240 pref := pm.findExistingPreference(userID, category, key)
241 if pref == nil {
242 return errors.New("preference not found")
243 }
244
245 pref.Value = value
246 pref.UpdatedAt = time.Now()
247
248 return nil
249}
250
251// DeletePreference 删除偏好
252func (pm *PreferenceManager) DeletePreference(

Calls 1

Tested by 1