资 源 简 介
package service;
import pojo.User;
import util.SessionUtil;
import vo.UserVO;
import dao.UserDao;
public class UserService {
private UserDao dao = SessionUtil.getSession().getMapper(UserDao.class);
/**
* 登陆方法
* @param username
* @param password
* @return
*/
public User login(String username,String password){
UserVO user = new UserVO(username, password);
return dao.getUserByUsername(user);
}
/**
* 注册的方法
* @param username
* @param password
* @param realname
* @param phone
* @return
*/
public boolean register(String username,String password,String realname,String phone){
//验证用户名是否已经存在
int count = dao.checkExists(username);
if(count > 0){
return false;
}
//继续调用数据层的新增方法
User user = new User(0,username,password,realname,phone);
int row = dao.save(user);
return row > 0;
}
public boolean check(String username){
int count = dao.checkExists(username);
ret