com.litongjava.table.utils.TableResultUtils Maven / Gradle / Ivy
package com.litongjava.table.utils;
import java.util.List;
import com.jfinal.kit.Kv;
import com.litongjava.db.TableResult;
import com.litongjava.db.activerecord.Row;
import com.litongjava.kit.RowUtils;
import com.litongjava.model.page.DbPage;
import com.litongjava.model.page.Page;
public class TableResultUtils {
public static TableResult recordToKv(TableResult jsonBean) {
Row data = jsonBean.getData();
if (data == null) {
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg());
} else {
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg(), RowUtils.recordToKv(data, false));
}
}
public static TableResult recordToKv(TableResult jsonBean, boolean underscoreToCamel) {
Row data = jsonBean.getData();
if (data == null) {
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg());
} else {
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg(), RowUtils.recordToKv(data, underscoreToCamel));
}
}
public static TableResult> pageToDbPage(TableResult> jsonBean, boolean underscoreToCamel) {
int totalRow = jsonBean.getData().getTotalRow();
List list = jsonBean.getData().getList();
List newList = RowUtils.recordsToKv(list, underscoreToCamel);
DbPage pageData = new DbPage<>();
pageData.setTotal(totalRow);
pageData.setList(newList);
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg(), pageData);
}
public static TableResult> recordsToKv(TableResult> jsonBean, boolean underscoreToCamel) {
return new TableResult<>(jsonBean.getCode(), jsonBean.getMsg(), RowUtils.recordsToKv(jsonBean.getData(), underscoreToCamel));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy