use of com.diboot.core.binding.parser.EntityInfoCache in project diboot by dibo-software.
the class ContextHelper method getIServiceByEntity.
/**
* 根据Entity获取对应的IService实现
* @param entity
* @return
*/
public static IService getIServiceByEntity(Class entity) {
EntityInfoCache entityInfoCache = BindingCacheManager.getEntityInfoByClass(entity);
IService iService = entityInfoCache != null ? entityInfoCache.getService() : null;
if (iService == null) {
log.info("未能识别到Entity: " + entity.getName() + " 的IService实现!");
}
return iService;
}
use of com.diboot.core.binding.parser.EntityInfoCache in project diboot by dibo-software.
the class ContextHelper method getBaseServiceByEntity.
/**
* 根据Entity获取对应的BaseService实现
* @param entity
* @return
*/
public static BaseService getBaseServiceByEntity(Class entity) {
EntityInfoCache entityInfoCache = BindingCacheManager.getEntityInfoByClass(entity);
IService iService = entityInfoCache != null ? entityInfoCache.getService() : null;
if (iService == null) {
log.info("未能识别到Entity: " + entity.getName() + " 的Service实现!");
}
if (iService instanceof BaseService) {
return (BaseService) iService;
}
return null;
}
use of com.diboot.core.binding.parser.EntityInfoCache in project diboot by dibo-software.
the class ServiceAdaptor method convertToIPage.
/**
* 转换为IPage
* @param pagination 分页
* @return
*/
public static <E> Page<E> convertToIPage(Pagination pagination, Class entityClass) {
if (pagination == null) {
return null;
}
// 如果是默认id排序
if (pagination.isDefaultOrderBy()) {
// 优化排序
String pk = ContextHelper.getIdFieldName(entityClass);
// 主键非有序id字段,需要清空默认排序以免报错
if (!Cons.FieldName.id.name().equals(pk)) {
pagination.clearDefaultOrder();
// 设置时间排序
EntityInfoCache entityInfoCache = BindingCacheManager.getEntityInfoByClass(entityClass);
if (entityInfoCache.containsColumn(Cons.COLUMN_CREATE_TIME)) {
pagination.setDefaultCreateTimeOrderBy();
}
}
}
return pagination.toPage();
}
Aggregations