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

Method DeleteUser

internal/service/user.go:147–174  ·  view source on GitHub ↗

DeleteUser 删除用户

(ctx context.Context, username string, password string, uid int64)

Source from the content-addressed store, hash-verified

145
146// DeleteUser 删除用户
147func (us *userService) DeleteUser(ctx context.Context, username string, password string, uid int64) error {
148 u, err := us.repo.FindByUsername(ctx, username)
149 if err != nil {
150 return err
151 }
152
153 if err := u.VerifyPassword(password); err != nil {
154 return ErrInvalidUserOrPassword
155 }
156
157 u.MarkAsDeleted()
158
159 if err := us.repo.DeleteUser(ctx, username, uid); err != nil {
160 return err
161 }
162
163 // 异步删除搜索索引
164 go func() {
165 ctx := context.Background()
166 if err := us.searchRepo.DeleteUserIndex(ctx, uid); err != nil {
167 us.l.Error("从搜索引擎中删除用户失败",
168 zap.Int64("用户ID", uid),
169 zap.Error(err))
170 }
171 }()
172
173 return nil
174}
175
176// UpdateProfile 更新用户资料
177func (us *userService) UpdateProfile(ctx context.Context, profile domain.Profile) error {

Callers

nothing calls this directly

Calls 5

VerifyPasswordMethod · 0.80
MarkAsDeletedMethod · 0.80
FindByUsernameMethod · 0.65
DeleteUserMethod · 0.65
DeleteUserIndexMethod · 0.65

Tested by

no test coverage detected