String strSQL = "select date_format(ctime,'%Y%m%d %H') as c,count(*) from ne_custom_access where user_id=@userid group by c;";
Sql sql = Sqls.create(strSQL);
sql.params().set("userid", userId);
sql.setCallback(new SqlCallback() {
@Override
public List<UserApiUsageData> invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<UserApiUsageData> data = new ArrayList<UserApiUsageData>();
while (rs.next()) {
UserApiUsageData d = new UserApiUsageData();
d.time = rs.getString(1);
d.value = new Double(rs.getLong(2));
data.add(d);
}
return data;
}
});
getDao().execute(sql);
return sql.getObject(List<UserApiUsageData>);
添加回复
请先登陆