@Override public long countUser(User user) { UserExample example = new UserExample(); Criteria createCriteria = example.createCriteria(); if (StringUtils.isNotBlank(user.getUsername())) { createCriteria.andUsernameLike(user.getUsername()); } if (StringUtils.isNotBlank(user.getRole())) { createCriteria.andRoleEqualTo(user.getRole()); } return userMapper.countByExample(example); }
private UserExample getUserExample(User u) { UserExample example = new UserExample(); com.salk.best.domain.UserExample.Criteria createCriteria = example.createCriteria(); if (StringUtils.isNotBlank(u.getUsername())) { createCriteria.andUsernameEqualTo(u.getUsername()); } if (StringUtils.isNotBlank(u.getPassword())) { createCriteria.andPasswordEqualTo(u.getPassword()); } if (StringUtils.isNotBlank(u.getRole())) { createCriteria.andRoleEqualTo(u.getRole()); } return example; }
@Override public List<User> queryUsers(User user) { // TODO Auto-generated method stub UserExample example = new UserExample(); Criteria createCriteria = example.createCriteria(); if (StringUtils.isNotBlank(user.getUsername())) { createCriteria.andUsernameLike(user.getUsername()); } if (StringUtils.isNotBlank(user.getRole())) { createCriteria.andRoleEqualTo(user.getRole()); } List<User> selectByExample = userMapper.selectByExample(example); return selectByExample; }