mirror of
				https://github.com/FreeeBird/hotel.git
				synced 2025-11-04 14:34:47 +08:00 
			
		
		
		
	心得用户个人信息的查询和更改
This commit is contained in:
		@@ -17,11 +17,12 @@ public class UserController {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private UserService userService;
 | 
			
		||||
 | 
			
		||||
    @RequestMapping(value = "/getUser")
 | 
			
		||||
    public User getUser(int id){
 | 
			
		||||
        return userService.selectById(id);
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST,value = "/updateProfile")
 | 
			
		||||
    public int updateProfile(String userName, String password, String name,
 | 
			
		||||
                              String phone, String email, String address, String idNumber){
 | 
			
		||||
        User user = new User(userName,password,name,phone,email,address,idNumber);
 | 
			
		||||
        return userService.updateProfile(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 注册
 | 
			
		||||
     * @param userName
 | 
			
		||||
@@ -39,7 +40,6 @@ public class UserController {
 | 
			
		||||
        User user = new User(userName,password,name,phone,email,address,idNumber);
 | 
			
		||||
        return userService.register(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 登录
 | 
			
		||||
     * @param userName
 | 
			
		||||
@@ -53,5 +53,14 @@ public class UserController {
 | 
			
		||||
        }
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 查看用户资料
 | 
			
		||||
     * @param userName
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    @RequestMapping(method = RequestMethod.POST, value = "/getProfile")
 | 
			
		||||
    public User getProfile(String userName){
 | 
			
		||||
        return userService.selectByUserName(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,16 +6,12 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
@Component
 | 
			
		||||
public interface UserMapper {
 | 
			
		||||
    int deleteByPrimaryKey(Integer userId);
 | 
			
		||||
 | 
			
		||||
    int insert(User record);
 | 
			
		||||
 | 
			
		||||
    int insertSelective(User record);
 | 
			
		||||
 | 
			
		||||
    User selectByPrimaryKey(Integer userId);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKeySelective(User record);
 | 
			
		||||
 | 
			
		||||
    int updateByPrimaryKey(User record);
 | 
			
		||||
 | 
			
		||||
    User selectByUserNameAndPassword(User user);
 | 
			
		||||
    User selectByUserName(String userName);
 | 
			
		||||
    int updateByUserNameSelective(User record);
 | 
			
		||||
}
 | 
			
		||||
@@ -10,4 +10,8 @@ public interface UserService {
 | 
			
		||||
    int register(User user);
 | 
			
		||||
 | 
			
		||||
    User login(String userName, String password);
 | 
			
		||||
 | 
			
		||||
    User selectByUserName(String userName);
 | 
			
		||||
 | 
			
		||||
    int updateProfile(User user);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,5 +30,13 @@ public class UserServiceImpl implements UserService {
 | 
			
		||||
        return userMapper.selectByUserNameAndPassword(user);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public User selectByUserName(String userName) {
 | 
			
		||||
        return userMapper.selectByUserName(userName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int updateProfile(User user) {
 | 
			
		||||
        return userMapper.updateByUserNameSelective(user);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user