}
UserDao接口定义了对用户的相关操作:
public interface UserDao {
User queryForSignOn(String username);
User queryUser(String username);
void createUser(User user);
void updateUser(User user);
boolean updateEmailValidation(String username, int ticket);
String createPasswordTicket(User user);
boolean updatePassword(String username, String oldPassword, String newPassword);
boolean queryResetPassword(User user, String ticket);
boolean updateResetPassword(User user, String ticket, String password);
void updateLock(User user, long lockTime);
void updateUnlock(User user);
}
UserDaoImpl是其实现类:
public class UserDaoImpl implements UserDao {
public User queryForSignOn(String username) {
User user = queryUser(username);
if(user.getLocked())
throw new LockException(user.getLockDate());
return user;
}
public User queryUser(String username) {
return (User) HibernateUtil.query(User.class, username);
}
public void createUser(User user) {
user.setEmailValidation((int)(Math.random() * 1000000) + 0xf);
文章来源于领测软件测试网 https://www.ltesting.net/