mirror of
https://github.com/FreeeBird/hotel.git
synced 2025-11-02 05:24:46 +08:00
完成UserService、UserMapper编写,通过单元测试
This commit is contained in:
@@ -36,7 +36,7 @@ public class AdminController {
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,4 +27,5 @@ public class OperatorController {
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package cn.mafangui.hotel.controller;
|
||||
|
||||
public class UserController {
|
||||
}
|
||||
@@ -113,6 +113,20 @@ public class User {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String username, String password, String name, String gender, String phone, String email, String address, String idcard) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.name = name;
|
||||
this.gender = gender;
|
||||
this.phone = phone;
|
||||
this.email = email;
|
||||
this.address = address;
|
||||
this.idcard = idcard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package cn.mafangui.hotel.mapper;
|
||||
|
||||
import cn.mafangui.hotel.entity.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public interface UserMapper {
|
||||
int deleteByPrimaryKey(Integer userId);
|
||||
@@ -16,4 +19,10 @@ public interface UserMapper {
|
||||
int updateByPrimaryKeySelective(User record);
|
||||
|
||||
int updateByPrimaryKey(User record);
|
||||
|
||||
User selectByUsernameAndPassword(@Param("username") String username,@Param("password") String password);
|
||||
|
||||
User selectByUsername(String username);
|
||||
|
||||
List<User> selectAll();
|
||||
}
|
||||
@@ -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