perf: associate ghost user with posts on user deletion. (#3293)

#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

文章发布用户被删除后,设置这篇文章的发布人为Ghost

#### Which issue(s) this PR fixes:

Fixes #3265

```release-note
NONE
```
pull/3314/head^2
2023-02-15 13:36:14 +08:00 committed by GitHub
parent 26f29b20c7
commit e485acef66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -13,4 +13,11 @@ public class Contributor {
private String displayName;
private String avatar;
private String name;
public static Contributor getGhost() {
Contributor contributor = new Contributor();
contributor.setName("ghost");
contributor.setDisplayName("已删除用户");
return contributor;
}
}

View File

@ -231,7 +231,8 @@ public class PostServiceImpl extends AbstractContentService implements PostServi
contributor.setDisplayName(user.getSpec().getDisplayName());
contributor.setAvatar(user.getSpec().getAvatar());
return contributor;
});
})
.defaultIfEmpty(Contributor.getGhost());
}
@Override