MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / UpdateProfile

Method UpdateProfile

internal/repository/user.go:146–165  ·  view source on GitHub ↗

UpdateProfile 更新用户资料

(ctx context.Context, profile domain.Profile)

Source from the content-addressed store, hash-verified

144
145// UpdateProfile 更新用户资料
146func (ur *userRepository) UpdateProfile(ctx context.Context, profile domain.Profile) error {
147 err := ur.dao.UpdateProfile(ctx, profile)
148 if err != nil {
149 return err
150 }
151
152 // 异步更新缓存
153 go func() {
154 ctx := context.Background()
155 du, err := ur.cache.Get(ctx, profile.UserID)
156 if err == nil {
157 du.Profile = profile
158 if err := ur.cache.Set(ctx, du); err != nil {
159 ur.l.Error("更新用户资料后更新缓存失败", zap.Error(err))
160 }
161 }
162 }()
163
164 return nil
165}
166
167// GetProfile 通过用户ID获取用户资料
168func (ur *userRepository) GetProfile(ctx context.Context, UserID int64) (domain.Profile, error) {

Callers

nothing calls this directly

Calls 3

UpdateProfileMethod · 0.65
GetMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected