UsersService层添加
This commit is contained in:
parent
632c7b96e6
commit
8180141994
@ -0,0 +1,21 @@
|
||||
package com.example.springdemo.service;
|
||||
|
||||
import com.example.springdemo.entities.Users;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UsersService {
|
||||
|
||||
Users insetUsers(Users user);
|
||||
|
||||
void deleteUsersById(Long id);
|
||||
|
||||
Users updateUsers(Users user);
|
||||
|
||||
List<Users> findAllUsers();
|
||||
|
||||
Optional<Users> findById(Long id);
|
||||
|
||||
Users findByName(String name);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.example.springdemo.service;
|
||||
|
||||
import com.example.springdemo.dao.UsersRepository;
|
||||
import com.example.springdemo.entities.Users;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class UsersServiceImpl implements UsersService {
|
||||
@Resource
|
||||
private UsersRepository usersRepository;
|
||||
|
||||
@Override
|
||||
public Users insetUsers(Users user) {
|
||||
return usersRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUsersById(Long id) {
|
||||
usersRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Users updateUsers(Users user) {
|
||||
return usersRepository.save(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Users> findAllUsers() {
|
||||
return usersRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Users> findById(Long id) {
|
||||
return usersRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Users findByName(String name) {
|
||||
return usersRepository.findByName(name);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user