use of com.mendmix.common.model.Page in project jeesuite-libs by vakinge.
the class ESLogStorageProvider method convertPage.
private Page<ActionLog> convertPage(SearchResponse response, PageParams pageParam) {
SearchHits hits = response.getHits();
List<ActionLog> datas = new ArrayList<>();
hits.forEach(e -> {
datas.add(JsonUtils.toObject(e.getSourceAsString(), ActionLog.class));
});
Page<ActionLog> page = new Page<>(pageParam, hits.getTotalHits().value - 1, datas);
return page;
}
use of com.mendmix.common.model.Page in project jeesuite-libs by vakinge.
the class PaginationHandler method onInterceptor.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Object onInterceptor(InvocationVals invocation) throws Throwable {
PageParams pageParams = invocation.getPageParam();
if (pageParams == null)
return null;
final MappedStatement orignMappedStatement = invocation.getMappedStatement();
if (!orignMappedStatement.getSqlCommandType().equals(SqlCommandType.SELECT))
return null;
if (invocation.getSql() == null) {
List<Object> list = new ArrayList<>(1);
list.add(new Page<Object>(invocation.getPageParam(), 0, null));
return list;
}
final ResultHandler resultHandler = (ResultHandler) invocation.getArgs()[3];
// 查询总数
Long total = executeQueryCount(invocation, resultHandler);
// 查询分页数据
List<?> datas = executeQuery(invocation, resultHandler);
Page<Object> page = new Page<Object>(pageParams, total, (List<Object>) datas);
List<Page<?>> list = new ArrayList<Page<?>>(1);
list.add(page);
return list;
}
use of com.mendmix.common.model.Page in project jeesuite-libs by vakinge.
the class RequestLogBuilder method responseLogMessage.
@SuppressWarnings("rawtypes")
public static String responseLogMessage(int statusCode, Object headers, Object body) {
StringBuilder builder = new StringBuilder();
builder.append("\n-----------response start-----------\n");
builder.append("statusCode :").append(statusCode).append("\n");
if (body != null) {
String bodyString;
if (body instanceof byte[]) {
byte[] bodyBytes = (byte[]) body;
if (bodyBytes.length > 1024)
bodyBytes = Arrays.copyOf(bodyBytes, 1024);
bodyString = new String(bodyBytes);
} else if (BeanUtils.isSimpleDataType(body)) {
bodyString = body.toString();
} else if (body instanceof Collection) {
Collection bodyList = (Collection) body;
bodyString = "itemNums:" + bodyList.size();
} else if (body instanceof Page) {
Page apge = (Page) body;
bodyString = String.format("{\"pageNo\":%s,\"pageSize\":%s,\"total\":%s}", apge.getPageNo(), apge.getPageSize(), apge.getTotal());
} else {
bodyString = JsonUtils.toJson(body);
}
builder.append("body :").append(bodyString).append("\n");
}
builder.append("-----------response end-----------\n");
return builder.toString();
}
Aggregations