添加getAllUsers和getUsersByTenant方法
This commit is contained in:
parent
82cb9d79ba
commit
cff3b43983
@ -3,8 +3,12 @@ package org.cmh.backend.authentication.repository;
|
||||
import org.cmh.backend.authentication.model.UserHS;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserRepository extends JpaRepository<UserHS, Long> {
|
||||
UserHS findByUsername(String username);
|
||||
|
||||
boolean deleteByUsername(String username);
|
||||
|
||||
List<UserHS> findByTenant(String tenant);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Service
|
||||
@ -79,6 +80,14 @@ public class UserService {
|
||||
return userRepository.deleteByUsername(username);
|
||||
}
|
||||
|
||||
public List<UserHS> getAllUsers() {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
public List<UserHS> getUsersByTenant(String tenant){
|
||||
return userRepository.findByTenant(tenant);
|
||||
}
|
||||
|
||||
public boolean loginUser(String username, String password) {
|
||||
UserHS user = userRepository.findByUsername(username);
|
||||
return user != null && passwordEncoder.matches(password, user.getPassword());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user