UpdateProfile 更新用户资料
(ctx context.Context, profile domain.Profile)
| 175 | |
| 176 | // UpdateProfile 更新用户资料 |
| 177 | func (us *userService) UpdateProfile(ctx context.Context, profile domain.Profile) error { |
| 178 | user, err := us.repo.FindByID(ctx, profile.UserID) |
| 179 | if err != nil { |
| 180 | return err |
| 181 | } |
| 182 | |
| 183 | if user.Profile.RealName != profile.RealName { |
| 184 | // 异步更新搜索索引 |
| 185 | go func() { |
| 186 | ctx := context.Background() |
| 187 | err := us.searchRepo.InputUser(ctx, domain.UserSearch{ |
| 188 | Id: profile.UserID, |
| 189 | Nickname: profile.RealName, |
| 190 | }) |
| 191 | if err != nil { |
| 192 | us.l.Error("更新用户搜索索引失败", |
| 193 | zap.Int64("用户ID", profile.UserID), |
| 194 | zap.Error(err)) |
| 195 | } |
| 196 | }() |
| 197 | } |
| 198 | |
| 199 | return us.repo.UpdateProfile(ctx, profile) |
| 200 | } |
| 201 | |
| 202 | // GetProfileByUserID 获取用户资料 |
| 203 | func (us *userService) GetProfileByUserID(ctx context.Context, UserID int64) (domain.Profile, error) { |
nothing calls this directly
no test coverage detected