mirror of
https://github.com/FreeeBird/hotel.git
synced 2026-05-01 08:20:26 +08:00
完成UserService、UserMapper编写,通过单元测试
This commit is contained in:
@@ -7,18 +7,18 @@ import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
User selectById(int id);
|
||||
User selectById(int userId);
|
||||
|
||||
int register(User user);
|
||||
int insertUser(User user);
|
||||
|
||||
User login(String userName, String password);
|
||||
int deleteUser(int userId);
|
||||
|
||||
User selectByUserName(String userName);
|
||||
int updateUser(User user);
|
||||
|
||||
// int count();
|
||||
//
|
||||
// List<User> findAll();
|
||||
//
|
||||
// int updateProfile(User user);
|
||||
User selectByUsernameAndPassword(String username, String password);
|
||||
|
||||
User selectByUsername(String username);
|
||||
|
||||
List<User> selectAll();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.mafangui.hotel.service.impl;
|
||||
|
||||
import cn.mafangui.hotel.entity.User;
|
||||
import cn.mafangui.hotel.mapper.UserMapper;
|
||||
import cn.mafangui.hotel.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public User selectById(int userId) {
|
||||
return userMapper.selectByPrimaryKey(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertUser(User user) {
|
||||
return userMapper.insertSelective(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteUser(int userId) {
|
||||
return userMapper.deleteByPrimaryKey(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUser(User user) {
|
||||
return userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User selectByUsernameAndPassword(String username, String password) {
|
||||
return userMapper.selectByUsernameAndPassword(username,password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User selectByUsername(String username) {
|
||||
return userMapper.selectByUsername(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> selectAll() {
|
||||
return userMapper.selectAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user