@Test public void testSaveUserInfo(){ ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"spring-common.xml","spring-datasource.xml"}); IUserInfoService userInfoService = (IUserInfoService) applicationContext.getBean("userInfoService"); try { UserInfo userInfo = new UserInfo(); userInfo.setUserId(201314070227L); userInfo.setUserName("曹建祥"); userInfo.setUserPassword("201314070227"); userInfo.setUserAge(22); userInfo.setUserGender(0); userInfo.setUserEmail("389715062@qq.com"); userInfo.setUserAddress("湖南郴州"); userInfo.setUserPhoneNumber("17373539152"); userInfo.setCollegeId(1002L); userInfo.setManager(1); userInfoService.saveUserInfo(userInfo); } catch (Exception e) { e.printStackTrace(); } }
public void saveUserInfo(UserInfo userInfo) throws Exception { UserInfo userInfo1 = null; try { userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 == null) { userInfo.setCreateDate(new Date()); userInfo.setRecStatus(1); userInfo.setUserPassword(MD5.getMD5Str(userInfo.getUserPassword())); userInfoDAO.insert(userInfo); } else { throw new RuntimeException("该用户已注册"); } } catch (Exception e) { log.error("新增用户失败", e); throw new RuntimeException(e.getMessage(), e); } }
UserInfoServiceImpl implements IUserInfoService { public void saveUserInfo(UserInfo userInfo) throws Exception { UserInfo userInfo1 = null; try { userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 == null) { userInfo.setCreateDate(new Date()); userInfo.setRecStatus(1); userInfo.setUserPassword(MD5.getMD5Str(userInfo.getUserPassword())); userInfoDAO.insert(userInfo); } else { throw new RuntimeException("该用户已注册"); } } catch (Exception e) { log.error("新增用户失败", e); throw new RuntimeException(e.getMessage(), e); } } }
UserInfoServiceImpl implements IUserInfoService { public void saveUserInfo(UserInfo userInfo) throws Exception { UserInfo userInfo1 = null; try { userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 == null) { userInfo.setCreateDate(new Date()); userInfo.setRecStatus(1); userInfo.setUserPassword(MD5.getMD5Str(userInfo.getUserPassword())); userInfoDAO.insert(userInfo); } else { throw new RuntimeException("该用户已注册"); } } catch (Exception e) { log.error("新增用户失败", e); throw new RuntimeException(e.getMessage(), e); } }  }
UserInfoServiceImpl implements IUserInfoService { public void saveUserInfo(UserInfo userInfo) throws Exception { UserInfo userInfo1 = null; try { userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 == null) { userInfo.setCreateDate(new Date()); userInfo.setRecStatus(1); userInfo.setUserPassword(MD5.getMD5Str(userInfo.getUserPassword())); userInfoDAO.insert(userInfo); } else { throw new RuntimeException("该用户已注册"); } } catch (Exception e) { log.error("新增用户失败", e); throw new RuntimeException(e.getMessage(), 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 void saveUserInfo(UserInfo userInfo) throws Exception { UserInfo userInfo1 = null; try { userInfo1 = userInfoDAO.get(userInfo); if (userInfo1 == null) { userInfo.setCreateDate(new Date()); userInfo.setRecStatus(1); userInfo.setUserPassword(MD5.getMD5Str(userInfo.getUserPassword())); userInfoDAO.insert(userInfo); } else { throw new RuntimeException("该用户已注册"); } } catch (Exception e) { log.error("新增用户失败", e); throw new RuntimeException(e.getMessage(), 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);  }