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

Method UpdateProfile

internal/service/user.go:177–200  ·  view source on GitHub ↗

UpdateProfile 更新用户资料

(ctx context.Context, profile domain.Profile)

Source from the content-addressed store, hash-verified

175
176// UpdateProfile 更新用户资料
177func (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 获取用户资料
203func (us *userService) GetProfileByUserID(ctx context.Context, UserID int64) (domain.Profile, error) {

Callers

nothing calls this directly

Calls 3

FindByIDMethod · 0.65
InputUserMethod · 0.65
UpdateProfileMethod · 0.65

Tested by

no test coverage detected