UpdateProfile 更新用户资料
(ctx context.Context, profile domain.Profile)
| 144 | |
| 145 | // UpdateProfile 更新用户资料 |
| 146 | func (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获取用户资料 |
| 168 | func (ur *userRepository) GetProfile(ctx context.Context, UserID int64) (domain.Profile, error) { |
nothing calls this directly
no test coverage detected