|
|
|
@ -5,8 +5,10 @@ import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.jpa.dao.BaseMongoRepository;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.mongodb.BasicDBObject;
|
|
|
|
|
import com.mongodb.Block;
|
|
|
|
|
import com.mongodb.client.FindIterable;
|
|
|
|
|
import com.mongodb.client.model.CountOptions;
|
|
|
|
|
import com.mongodb.client.model.Filters;
|
|
|
|
|
import com.mongodb.client.model.Sorts;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -21,6 +23,7 @@ import org.springframework.data.mapping.context.MappingContext;
|
|
|
|
|
import org.springframework.data.mongodb.core.MongoOperations;
|
|
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
|
|
|
|
import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty;
|
|
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
|
import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
|
|
|
|
|
import org.springframework.data.mongodb.repository.support.SimpleMongoRepository;
|
|
|
|
|
|
|
|
|
@ -271,13 +274,9 @@ public class BaseMongoRepositoryImpl<T, ID extends Serializable> extends SimpleM
|
|
|
|
|
|
|
|
|
|
FindIterable findIter = null;
|
|
|
|
|
if(bson == null) {
|
|
|
|
|
findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find()
|
|
|
|
|
.skip(pager.getStartRow())
|
|
|
|
|
.limit(pager.getPageSize());
|
|
|
|
|
findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find();
|
|
|
|
|
}else{
|
|
|
|
|
findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find(bson)
|
|
|
|
|
.skip(pager.getStartRow())
|
|
|
|
|
.limit(pager.getPageSize());
|
|
|
|
|
findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find(bson);
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(orderByParam) && ascOrDesc != 0){
|
|
|
|
|
//排序
|
|
|
|
@ -286,8 +285,13 @@ public class BaseMongoRepositoryImpl<T, ID extends Serializable> extends SimpleM
|
|
|
|
|
}else{
|
|
|
|
|
findIter.sort(Sorts.descending(orderByParam));
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//根据id排序
|
|
|
|
|
findIter.sort(new BasicDBObject("_id", 1));
|
|
|
|
|
}
|
|
|
|
|
findIter.skip(pager.getStartRow()).limit(pager.getPageSize());
|
|
|
|
|
findIter.forEach(saveBlock);
|
|
|
|
|
|
|
|
|
|
return packObjectListFromDocument(dList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -310,9 +314,7 @@ public class BaseMongoRepositoryImpl<T, ID extends Serializable> extends SimpleM
|
|
|
|
|
dList.add(document);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
FindIterable findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find()
|
|
|
|
|
.skip(pager.getStartRow())
|
|
|
|
|
.limit(pager.getPageSize());
|
|
|
|
|
FindIterable findIter = mongoOperations.getCollection(this.entityInformation.getCollectionName()).find();
|
|
|
|
|
if(StringUtils.isNotBlank(orderByParam) && ascOrDesc != 0){
|
|
|
|
|
//排序
|
|
|
|
|
if(ascOrDesc == CommonEnumUtil.ASC_OR_DESC.ASC.getValue()){
|
|
|
|
@ -320,7 +322,11 @@ public class BaseMongoRepositoryImpl<T, ID extends Serializable> extends SimpleM
|
|
|
|
|
}else{
|
|
|
|
|
findIter.sort(Sorts.descending(orderByParam));
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//根据id排序
|
|
|
|
|
findIter.sort(new BasicDBObject("_id", 1));
|
|
|
|
|
}
|
|
|
|
|
findIter.skip(pager.getStartRow()).limit(pager.getPageSize());
|
|
|
|
|
findIter.forEach(saveBlock);
|
|
|
|
|
return packObjectListFromDocument(dList);
|
|
|
|
|
}
|
|
|
|
|