@Test public void getUserByNameTest() throws Exception { SysUser sysUser = new SysUser(); sysUser.setUserName("user_name"); sysUser.setRealName("real_name"); sysUser.setPassword("password"); sysUser.setAvatar("avatar"); sysUser.setDeleted(1); sysUser.setPhone("123456789"); sysUser.setRoleCode("roleCode"); sysUser.setEmail("test@submarine.org"); sysUser.setBirthday(new Date()); sysUser.setCreateTime(new Date()); sysUser.setUpdateTime(new Date()); Boolean ret = userService.add(sysUser); assertTrue(ret); SysUser user = userService.getUserByName("user_name", "password"); assertEquals(sysUser.getRealName(), user.getRealName()); assertEquals(sysUser.getUserName(), user.getUserName()); assertEquals(sysUser.getId(), user.getId()); }
public SysUser getUserByName(String name, String password) throws Exception { SysUser sysUser = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { HashMap<String, Object> mapParams = new HashMap<>(); mapParams.put("name", name); mapParams.put("password", password); Map<String, Object> params = new HashMap<>(); params.put("mapParams", mapParams); sysUser = sqlSession.selectOne(GET_USER_BY_NAME_STATEMENT, params); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return sysUser; }
SysUserService { public SysUser getUserByName(String name, String password) throws Exception { SysUser sysUser = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { HashMap<String, Object> mapParams = new HashMap<>(); mapParams.put("name", name); mapParams.put("password", password); Map<String, Object> params = new HashMap<>(); params.put("mapParams", mapParams); sysUser = sqlSession.selectOne(GET_USER_BY_NAME_STATEMENT, params); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return sysUser; } }
SysUserService { public SysUser getUserByName(String name, String password) throws Exception { SysUser sysUser = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { HashMap<String, Object> mapParams = new HashMap<>(); mapParams.put("name", name); mapParams.put("password", password); Map<String, Object> params = new HashMap<>(); params.put("mapParams", mapParams); sysUser = sqlSession.selectOne(GET_USER_BY_NAME_STATEMENT, params); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return sysUser; }  }
SysUserService { public SysUser getUserByName(String name, String password) throws Exception { SysUser sysUser = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { HashMap<String, Object> mapParams = new HashMap<>(); mapParams.put("name", name); mapParams.put("password", password); Map<String, Object> params = new HashMap<>(); params.put("mapParams", mapParams); sysUser = sqlSession.selectOne(GET_USER_BY_NAME_STATEMENT, params); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return sysUser; }  SysUser getUserByName(String name, String password); SysUser login(HashMap<String, String> mapParams); List<SysUser> queryPageList(String userName,
                                     String email,
                                     String deptCode,
                                     String column,
                                     String field,
                                     int pageNo,
                                     int pageSize); boolean add(SysUser sysUser); boolean edit(SysUser sysUser); boolean delete(String id); boolean changePassword(SysUser user); }
SysUserService { public SysUser getUserByName(String name, String password) throws Exception { SysUser sysUser = null; try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { HashMap<String, Object> mapParams = new HashMap<>(); mapParams.put("name", name); mapParams.put("password", password); Map<String, Object> params = new HashMap<>(); params.put("mapParams", mapParams); sysUser = sqlSession.selectOne(GET_USER_BY_NAME_STATEMENT, params); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return sysUser; }  SysUser getUserByName(String name, String password); SysUser login(HashMap<String, String> mapParams); List<SysUser> queryPageList(String userName,
                                     String email,
                                     String deptCode,
                                     String column,
                                     String field,
                                     int pageNo,
                                     int pageSize); boolean add(SysUser sysUser); boolean edit(SysUser sysUser); boolean delete(String id); boolean changePassword(SysUser user);  }