@Test public void testGetUserInfoService(){ ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"spring-common.xml","spring-datasource.xml"}); IUserInfoService userInfoService = (IUserInfoService) applicationContext.getBean("userInfoService"); try { userInfoService.login(1L,"123"); } catch (Exception e) { e.printStackTrace(); } }
public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != null) { if (userPassword != null && userPassword.equals(userInfo1.getUserPassword())) { return userInfo1; } else { log.error(userId + "用户密码错误"); throw new Exception("用户密码错误"); } } else { return null; } } catch (Exception e) { log.error("用户信息查询失败", e); throw new Exception("用户信息查询失败", e); } }
UserInfoServiceImpl implements IUserInfoService { public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != null) { if (userPassword != null && userPassword.equals(userInfo1.getUserPassword())) { return userInfo1; } else { log.error(userId + "用户密码错误"); throw new Exception("用户密码错误"); } } else { return null; } } catch (Exception e) { log.error("用户信息查询失败", e); throw new Exception("用户信息查询失败", e); } } }
UserInfoServiceImpl implements IUserInfoService { public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != null) { if (userPassword != null && userPassword.equals(userInfo1.getUserPassword())) { return userInfo1; } else { log.error(userId + "用户密码错误"); throw new Exception("用户密码错误"); } } else { return null; } } catch (Exception e) { log.error("用户信息查询失败", e); throw new Exception("用户信息查询失败", e); } }  }
UserInfoServiceImpl implements IUserInfoService { public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != null) { if (userPassword != null && userPassword.equals(userInfo1.getUserPassword())) { return userInfo1; } else { log.error(userId + "用户密码错误"); throw new Exception("用户密码错误"); } } else { return null; } } catch (Exception e) { log.error("用户信息查询失败", e); throw new Exception("用户信息查询失败", e); } }  UserInfo login(Long userId, String userPassword); UserInfo getUserInfo(UserInfo userInfo); @Override List<UserInfo> listUserInfo(UserInfo userInfo); @Override List<UserInfo> listUserInfo(UserInfo userInfo, PageParameter page); void saveUserInfo(UserInfo userInfo); void updateUserInfo(UserInfo userInfo); @Override void removeUserInfo(UserInfo userInfo); }
UserInfoServiceImpl implements IUserInfoService { public UserInfo login(Long userId, String userPassword) throws Exception { try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(userId); userPassword = MD5.getMD5Str(userPassword); UserInfo userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 != null) { if (userPassword != null && userPassword.equals(userInfo1.getUserPassword())) { return userInfo1; } else { log.error(userId + "用户密码错误"); throw new Exception("用户密码错误"); } } else { return null; } } catch (Exception e) { log.error("用户信息查询失败", e); throw new Exception("用户信息查询失败", e); } }  UserInfo login(Long userId, String userPassword); UserInfo getUserInfo(UserInfo userInfo); @Override List<UserInfo> listUserInfo(UserInfo userInfo); @Override List<UserInfo> listUserInfo(UserInfo userInfo, PageParameter page); void saveUserInfo(UserInfo userInfo); void updateUserInfo(UserInfo userInfo); @Override void removeUserInfo(UserInfo userInfo);  }