Example #1
0
  @Override
  public List<Log> list(ListLogRequest logParam, int pageIndex, int pageSize) {

    DetachedCriteria criteria = DetachedCriteria.forClass(Log.class);

    // TODO 添加大小不敏感
    if (StringUtils.isNotBlank(logParam.getLoginName())) {
      criteria.add(Restrictions.like("loginName", "%" + logParam.getLoginName() + "%"));
    }

    if (logParam.getOperationUsers() != null && logParam.getOperationUsers().length > 0) {
      criteria.add(Restrictions.in("loginName", logParam.getOperationUsers()));
    }
    if (StringUtils.isNotBlank(logParam.getModule())) {
      criteria.add(Restrictions.eq("module", logParam.getModule()));
    }
    if (StringUtils.isNotBlank(logParam.getOperation())) {
      criteria.add(Restrictions.eq("operation", logParam.getOperation()));
    }

    if (logParam.getStartDate() != null) {
      criteria.add(Restrictions.ge("createdOn", logParam.getStartDate()));
    }
    if (logParam.getEndDate() != null) {
      criteria.add(Restrictions.le("createdOn", logParam.getEndDate()));
    }
    criteria.addOrder(Order.desc("createdOn"));

    List result = (List<Log>) findByCriteria(criteria, pageIndex, pageSize);

    return result;
  }
Example #2
0
  @Override
  public int count(ListLogRequest logParam) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Log.class);

    if (StringUtils.isNotBlank(logParam.getLoginName())) {
      criteria.add(Restrictions.eq("loginName", "%" + logParam.getLoginName() + "%"));
    }

    if (logParam.getOperationUsers() != null && logParam.getOperationUsers().length > 0) {
      criteria.add(Restrictions.in("loginName", logParam.getOperationUsers()));
    }

    if (StringUtils.isNotBlank(logParam.getModule())) {
      criteria.add(Restrictions.eq("module", logParam.getModule()));
    }
    if (StringUtils.isNotBlank(logParam.getOperation())) {
      criteria.add(Restrictions.eq("operation", logParam.getOperation()));
    }

    if (logParam.getStartDate() != null) {
      criteria.add(Restrictions.ge("createdOn", logParam.getStartDate()));
    }
    if (logParam.getEndDate() != null) {
      criteria.add(Restrictions.le("createdOn", logParam.getEndDate()));
    }
    return this.countByCriteria(criteria);
  }