mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 22:50:51 +08:00
Allow fetching user info by id
This commit is contained in:
@@ -91,6 +91,17 @@ public class UserService {
|
||||
return userRepository.findByUsername(username);
|
||||
}
|
||||
|
||||
public Optional<User> findById(Long id) {
|
||||
return userRepository.findById(id);
|
||||
}
|
||||
|
||||
public Optional<User> findByIdentifier(String identifier) {
|
||||
if (identifier.matches("\\d+")) {
|
||||
return userRepository.findById(Long.parseLong(identifier));
|
||||
}
|
||||
return userRepository.findByUsername(identifier);
|
||||
}
|
||||
|
||||
public User updateAvatar(String username, String avatarUrl) {
|
||||
User user = userRepository.findByUsername(username)
|
||||
.orElseThrow(() -> new IllegalArgumentException("User not found"));
|
||||
|
||||
Reference in New Issue
Block a user