|
|
@@ -9,6 +9,11 @@ const compleClassModel = mongoose.model('complementary_glj_section');
|
|
|
import counter from "../../../public/counter/counter";
|
|
|
import async from "async";
|
|
|
import STDGLJLibGLJListModel from "../../common/std/std_glj_lib_glj_list_model";
|
|
|
+const gljType = {
|
|
|
+ stdGLJ: 1,
|
|
|
+ complementaryGLJs: 2
|
|
|
+};
|
|
|
+const limitCount = 50;
|
|
|
|
|
|
class GljDao {
|
|
|
getGljTypes (gljLibId, callback){
|
|
|
@@ -41,8 +46,35 @@ class GljDao {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async getGLJPaging ({type, replace, index, search, withinClass}) {
|
|
|
+ getQueryByType ({userID, compilationId, gljLibId, type, classList, search}) {
|
|
|
+ let rst = {
|
|
|
+ model: null,
|
|
|
+ query: {}
|
|
|
+ };
|
|
|
+ if (type === gljType.stdGLJ) {
|
|
|
+ rst.model = stdGljModel;
|
|
|
+ rst.query.repositoryId = gljLibId;
|
|
|
+ } else {
|
|
|
+ rst.model = complementaryGljModel;
|
|
|
+ rst.query.userId = userID;
|
|
|
+ rst.query.compilationId = compilationId;
|
|
|
+ }
|
|
|
+ if (classList.length) {
|
|
|
+ rst.query.gljClass = {$in: classList};
|
|
|
+ }
|
|
|
+ if (search) {
|
|
|
+ rst.query.$or = [{code: {'$regex': search, $options: '$i'}}, {name: {'$regex': search, $options: '$i'}}];
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
|
|
|
+ async getGLJPaging (data) {
|
|
|
+ let queryData = this.getQueryByType(data);
|
|
|
+ let gljs = await queryData.model.find(queryData.query).lean().sort({code: 1}).skip(data.index).limit(limitCount),
|
|
|
+ total = await queryData.model.find(queryData.query).count();
|
|
|
+ return data.type === gljType.stdGLJ
|
|
|
+ ? {stdGljs: gljs, complementaryGljs: [], total: total}
|
|
|
+ : {stdGljs: [], complementaryGljs: gljs, total: total}
|
|
|
}
|
|
|
|
|
|
//获得用户的补充工料机和用户当前所在编办的标准工料机
|