use of com.zsm.ssh.model.User in project Resource by lovelifeming.
the class UserAction method execute.
// @Action(value="login")
@Action(value = "login", results = { @Result(name = "success", location = "/success.jsp", params = { "resultJson", "resultJson" }), @Result(name = "error", location = "/error.jsp") })
public String execute() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request = ServletActionContext.getRequest();
JSONObject result = new JSONObject();
User user = userService.getByName(username);
result.put("user", user);
if (user != null && user.getUser_name().equals(username) && user.getPassword().equals(password)) {
result.put("message", "登录成功");
result.put("status", "true");
resultJson = result.toString();
request.setAttribute("resultJson", resultJson);
writeResponseData(request, response, result);
return "success";
}
result.put("message", "登录失败");
result.put("status", "false");
resultJson = result.toString();
writeResponseData(request, response, result);
return "error";
}
use of com.zsm.ssh.model.User in project Resource by lovelifeming.
the class UserDaoImpl method getByName.
@Override
@Transactional(propagation = Propagation.REQUIRED)
public User getByName(String name) {
Session session = sessionFactory.getCurrentSession();
// 根据id查询,结果返回 User.class
User user = (User) session.get(User.class, 2);
// 将所有的数据查询出来并放到List集合里 User是表对应的实例名称
List users = session.createQuery("from User where user_name='" + name + "'").list();
return (User) users.get(0);
}
use of com.zsm.ssh.model.User in project Resource by lovelifeming.
the class UserDaoImplTest method saveOrUpdateEntity.
@Test
public void saveOrUpdateEntity() throws Exception {
User user = getUser();
user.setId(10);
userDao.saveOrUpdateEntity(user);
}
use of com.zsm.ssh.model.User in project Resource by lovelifeming.
the class UserDaoImplTest method getByNo.
@Test
public void getByNo() throws Exception {
User user = userDao.getByNo("114");
Assert.assertEquals("李元芳", user.getUser_name());
}
use of com.zsm.ssh.model.User in project Resource by lovelifeming.
the class UserDaoImpl method findAllUser.
@Override
@Transactional(propagation = Propagation.REQUIRED)
public List<User> findAllUser() {
Session session = sessionFactory.openSession();
// 将所有的数据查询出来并放到List集合里 User是表对应的实例名称
List<User> list = session.createQuery("from User").list();
session.close();
return list;
}
Aggregations