コード例 #1
0
  @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);
  }
コード例 #2
0
 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;
 }
コード例 #3
0
  @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;
  }