@Test public void testGetAPageOfAction() { Map<String, String> args = new HashMap<>(); ActionInfo actionInfo = new ActionInfo(1, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100); ActionInfo actionInfo1 = new ActionInfo(2, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100); ActionInfo actionInfo2 = new ActionInfo(3, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100); ActionInfo actionInfo3 = new ActionInfo(4, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100); actionDao.insert(new ActionInfo[]{actionInfo, actionInfo1, actionInfo2, actionInfo3}); List<String> order = new ArrayList<>(); order.add("aid"); List<Boolean> desc = new ArrayList<>(); desc.add(false); Assert.assertTrue(actionDao.getAPageOfAction(2, 1, order, desc).get(0).equals(actionInfo2)); }
public List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy, List<Boolean> isDesc) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); boolean ifHasAid = false; String sql = "SELECT * FROM " + TABLE_NAME + " ORDER BY "; for (int i = 0; i < orderBy.size(); i++) { String ob = orderBy.get(i); if (!tableColumns.contains(ob)) { continue; } if (ob.equals("aid")) { ifHasAid = true; } if (ob.equals(RUNNING_TIME)) { sql = sql + "(finish_time - create_time)"; } else { sql = sql + ob; } if (isDesc.size() > i) { if (isDesc.get(i)) { sql = sql + " desc "; } sql = sql + ","; } } if (!ifHasAid) { sql = sql + "aid,"; } sql = sql.substring(0, sql.length() - 1); sql = sql + " LIMIT " + start + "," + offset + ";"; return jdbcTemplate.query(sql, new ActionRowMapper()); }
ActionDao { public List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy, List<Boolean> isDesc) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); boolean ifHasAid = false; String sql = "SELECT * FROM " + TABLE_NAME + " ORDER BY "; for (int i = 0; i < orderBy.size(); i++) { String ob = orderBy.get(i); if (!tableColumns.contains(ob)) { continue; } if (ob.equals("aid")) { ifHasAid = true; } if (ob.equals(RUNNING_TIME)) { sql = sql + "(finish_time - create_time)"; } else { sql = sql + ob; } if (isDesc.size() > i) { if (isDesc.get(i)) { sql = sql + " desc "; } sql = sql + ","; } } if (!ifHasAid) { sql = sql + "aid,"; } sql = sql.substring(0, sql.length() - 1); sql = sql + " LIMIT " + start + "," + offset + ";"; return jdbcTemplate.query(sql, new ActionRowMapper()); } }
ActionDao { public List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy, List<Boolean> isDesc) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); boolean ifHasAid = false; String sql = "SELECT * FROM " + TABLE_NAME + " ORDER BY "; for (int i = 0; i < orderBy.size(); i++) { String ob = orderBy.get(i); if (!tableColumns.contains(ob)) { continue; } if (ob.equals("aid")) { ifHasAid = true; } if (ob.equals(RUNNING_TIME)) { sql = sql + "(finish_time - create_time)"; } else { sql = sql + ob; } if (isDesc.size() > i) { if (isDesc.get(i)) { sql = sql + " desc "; } sql = sql + ","; } } if (!ifHasAid) { sql = sql + "aid,"; } sql = sql.substring(0, sql.length() - 1); sql = sql + " LIMIT " + start + "," + offset + ";"; return jdbcTemplate.query(sql, new ActionRowMapper()); } ActionDao(DataSource dataSource); }
ActionDao { public List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy, List<Boolean> isDesc) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); boolean ifHasAid = false; String sql = "SELECT * FROM " + TABLE_NAME + " ORDER BY "; for (int i = 0; i < orderBy.size(); i++) { String ob = orderBy.get(i); if (!tableColumns.contains(ob)) { continue; } if (ob.equals("aid")) { ifHasAid = true; } if (ob.equals(RUNNING_TIME)) { sql = sql + "(finish_time - create_time)"; } else { sql = sql + ob; } if (isDesc.size() > i) { if (isDesc.get(i)) { sql = sql + " desc "; } sql = sql + ","; } } if (!ifHasAid) { sql = sql + "aid,"; } sql = sql.substring(0, sql.length() - 1); sql = sql + " LIMIT " + start + "," + offset + ";"; return jdbcTemplate.query(sql, new ActionRowMapper()); } ActionDao(DataSource dataSource); List<ActionInfo> getAll(); Long getCountOfAction(); ActionInfo getById(long aid); List<ActionInfo> getByIds(List<Long> aids); List<ActionInfo> getByCid(long cid); List<ActionInfo> getByCondition(String aidCondition,
      String cidCondition); List<ActionInfo> getLatestActions(int size); List<ActionInfo> getLatestActions(String actionName, int size); List<ActionInfo> getLatestActions(String actionName, int size,
      boolean successful, boolean finished); List<ActionInfo> getLatestActions(String actionName, boolean successful,
      int size); List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy,
      List<Boolean> isDesc); List<ActionInfo> getAPageOfAction(long start, long offset); List<ActionInfo> searchAction(String path, long start, long offset, List<String> orderBy,
      List<Boolean> isDesc, long[] retTotalNumActions); List<ActionInfo> getLatestActions(String actionType, int size,
      boolean finished); void delete(long aid); void deleteCmdletActions(long cid); int[] batchDeleteCmdletActions(final List<Long> cids); void deleteAll(); void insert(ActionInfo actionInfo); void insert(ActionInfo[] actionInfos); int[] replace(final ActionInfo[] actionInfos); int update(final ActionInfo actionInfo); int[] update(final ActionInfo[] actionInfos); long getMaxId(); }
ActionDao { public List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy, List<Boolean> isDesc) { JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); boolean ifHasAid = false; String sql = "SELECT * FROM " + TABLE_NAME + " ORDER BY "; for (int i = 0; i < orderBy.size(); i++) { String ob = orderBy.get(i); if (!tableColumns.contains(ob)) { continue; } if (ob.equals("aid")) { ifHasAid = true; } if (ob.equals(RUNNING_TIME)) { sql = sql + "(finish_time - create_time)"; } else { sql = sql + ob; } if (isDesc.size() > i) { if (isDesc.get(i)) { sql = sql + " desc "; } sql = sql + ","; } } if (!ifHasAid) { sql = sql + "aid,"; } sql = sql.substring(0, sql.length() - 1); sql = sql + " LIMIT " + start + "," + offset + ";"; return jdbcTemplate.query(sql, new ActionRowMapper()); } ActionDao(DataSource dataSource); List<ActionInfo> getAll(); Long getCountOfAction(); ActionInfo getById(long aid); List<ActionInfo> getByIds(List<Long> aids); List<ActionInfo> getByCid(long cid); List<ActionInfo> getByCondition(String aidCondition,
      String cidCondition); List<ActionInfo> getLatestActions(int size); List<ActionInfo> getLatestActions(String actionName, int size); List<ActionInfo> getLatestActions(String actionName, int size,
      boolean successful, boolean finished); List<ActionInfo> getLatestActions(String actionName, boolean successful,
      int size); List<ActionInfo> getAPageOfAction(long start, long offset, List<String> orderBy,
      List<Boolean> isDesc); List<ActionInfo> getAPageOfAction(long start, long offset); List<ActionInfo> searchAction(String path, long start, long offset, List<String> orderBy,
      List<Boolean> isDesc, long[] retTotalNumActions); List<ActionInfo> getLatestActions(String actionType, int size,
      boolean finished); void delete(long aid); void deleteCmdletActions(long cid); int[] batchDeleteCmdletActions(final List<Long> cids); void deleteAll(); void insert(ActionInfo actionInfo); void insert(ActionInfo[] actionInfos); int[] replace(final ActionInfo[] actionInfos); int update(final ActionInfo actionInfo); int[] update(final ActionInfo[] actionInfos); long getMaxId();  }