DeleteUser 删除用户
(ctx context.Context, username string, uid int64)
| 122 | |
| 123 | // DeleteUser 删除用户 |
| 124 | func (ur *userRepository) DeleteUser(ctx context.Context, username string, uid int64) error { |
| 125 | err := ur.dao.DeleteUser(ctx, username, uid) |
| 126 | if err != nil { |
| 127 | ur.l.Error("删除用户失败", zap.Error(err)) |
| 128 | return err |
| 129 | } |
| 130 | |
| 131 | // 异步删除缓存 |
| 132 | go func() { |
| 133 | ctx := context.Background() |
| 134 | du, err := ur.cache.Get(ctx, uid) |
| 135 | if err == nil { |
| 136 | if err := ur.cache.Set(ctx, domain.User{ID: du.ID, Deleted: true}); err != nil { |
| 137 | ur.l.Error("删除用户后更新缓存失败", zap.Error(err)) |
| 138 | } |
| 139 | } |
| 140 | }() |
| 141 | |
| 142 | return nil |
| 143 | } |
| 144 | |
| 145 | // UpdateProfile 更新用户资料 |
| 146 | func (ur *userRepository) UpdateProfile(ctx context.Context, profile domain.Profile) error { |
nothing calls this directly
no test coverage detected