Search in sources :

Example 1 with User

use of com.kedou.entity.User in project KeDou by XiaoBai518.

the class UserController method verify.

/*
	 * 
	 * 激活
	 */
@RequestMapping(value = "verify", method = RequestMethod.GET)
public String verify(@RequestParam("verifyNum") String userVerifyNum, HttpSession session) {
    // 获取到系统随机生成的验证码
    String verifyNum = (String) session.getAttribute("verifyNum");
    // 获取到用户的注册邮箱
    String emailAddress = (String) session.getAttribute("emailAddress");
    // 获取到用户的密码
    String pwd = (String) session.getAttribute("password");
    if (verifyNum.equals(userVerifyNum)) {
        // 用户点击的链接所带的验证码与系统随机生成的验证码一致
        User u = new User(emailAddress, pwd);
        // 将用户的注册信息查到数据库中
        this.userServiceImpl.saveUser(u);
        return "跳转首页";
    } else {
        // 用户点击的链接所带的验证码与系统随机生成的验证码不一致
        return "提示激活地址错误,请使用正确的激活地址";
    }
}
Also used : User(com.kedou.entity.User) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with User

use of com.kedou.entity.User in project KeDou by XiaoBai518.

the class UserDaoImpl method findByUsername.

/**
 * @desc 通过电话或者邮箱查询用户
 * @author zhangtianrun
 * @createDate 2018年3月29日
 * @return User
 * @throws Exception
 */
public User findByUsername(String teloremail) throws Exception {
    SessionFactory sessionFactory = super.getSessionFactory();
    String hql = "from User where userTel=:tel or userEmail=:mail";
    Query query = sessionFactory.getCurrentSession().createQuery(hql);
    query.setParameter("tel", teloremail);
    query.setParameter("mail", teloremail);
    return (User) query.uniqueResult();
}
Also used : SessionFactory(org.hibernate.SessionFactory) User(com.kedou.entity.User) Query(org.hibernate.query.Query)

Aggregations

User (com.kedou.entity.User)2 SessionFactory (org.hibernate.SessionFactory)1 Query (org.hibernate.query.Query)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1