zs 1 year ago
parent
commit
b29eafeaf8

+ 1 - 1
src/middleware/newsQuery.middleware.ts

@@ -18,7 +18,7 @@ export class newsQueryMiddleware implements IMiddleware<Context, NextFunction> {
           if (!Array.isArray(parsedQuery[paramName])) {
             parsedQuery[paramName] = [];
           }
-          parsedQuery[paramName].push(rawQuery[key]);
+          parsedQuery[paramName] = rawQuery[key];
         } else {
           // 非数组参数直接存储
           parsedQuery[key] = rawQuery[key];

+ 4 - 17
src/service/platform/demand.service.ts

@@ -20,23 +20,10 @@ export class DemandService extends BaseService<modelType> {
     const { skip = 0, limit = 0, is_use, status, ...condition } = query;
     const { one, two, thr, four } = condition;
     const info: any = { is_use, status };
-    // 如果 one 不是一个数组,你可能需要手动处理
-    if (one) {
-      if (!Array.isArray(one)) info.field = one;
-      else info.field = { $all: one };
-    }
-    if (two) {
-      if (!Array.isArray(two)) info.method = two;
-      else info.method = { $all: two };
-    }
-    if (thr) {
-      if (!Array.isArray(thr)) info.area = thr;
-      else info.area = { $all: thr };
-    }
-    if (four) {
-      if (!Array.isArray(four)) info.demand_status = four;
-      else info.demand_status = { $all: four };
-    }
+    if (one) info.field = { $in: one };
+    if (two) info.method = { $in: two };
+    if (thr) info.area = { $in: thr };
+    if (four) info.demand_status = { $in: four };
     const data = await this.model.find(info).skip(skip).limit(limit).lean();
     for (const val of data) {
       if (get(val, 'user')) {

+ 4 - 17
src/service/platform/project.service.ts

@@ -20,23 +20,10 @@ export class ProjectService extends BaseService<modelType> {
     const { skip = 0, limit = 0, is_use, status, ...condition } = query;
     const { one, two, thr, four } = condition;
     const info: any = { is_use, status };
-    // 如果 one 不是一个数组,你可能需要手动处理
-    if (one) {
-      if (!Array.isArray(one)) info.field = one;
-      else info.field = { $all: one };
-    }
-    if (two) {
-      if (!Array.isArray(two)) info.cooperate = two;
-      else info.cooperate = { $all: two };
-    }
-    if (thr) {
-      if (!Array.isArray(thr)) info.area = thr;
-      else info.area = { $all: thr };
-    }
-    if (four) {
-      if (!Array.isArray(four)) info.maturity = four;
-      else info.maturity = { $all: four };
-    }
+    if (one) info.field = { $in: one };
+    if (two) info.cooperate = { $in: two };
+    if (thr) info.area = { $in: thr };
+    if (four) info.maturity = { $in: four };
     const data = await this.model.find(info).skip(skip).limit(limit).lean();
     for (const val of data) {
       if (get(val, 'user')) {

+ 5 - 21
src/service/users/company.service.ts

@@ -19,27 +19,11 @@ export class CompanyService extends BaseService<modelType> {
     const { skip = 0, limit = 0, is_show, status, ...condition } = query;
     const { one, two, thr, four, five } = condition;
     const info: any = { is_show, status };
-    // 如果 one 不是一个数组,你可能需要手动处理
-    if (one) {
-      if (!Array.isArray(one)) info.scale = one;
-      else info.scale = { $all: one };
-    }
-    if (two) {
-      if (!Array.isArray(two)) info.pattern = two;
-      else info.pattern = { $all: two };
-    }
-    if (thr) {
-      if (!Array.isArray(thr)) info.area = thr;
-      else info.area = { $all: thr };
-    }
-    if (four) {
-      if (!Array.isArray(four)) info.type = four;
-      else info.type = { $all: four };
-    }
-    if (five) {
-      if (!Array.isArray(five)) info.companyStatus = five;
-      else info.companyStatus = { $all: five };
-    }
+    if (one) info.scale = { $in: one };
+    if (two) info.pattern = { $in: two };
+    if (thr) info.area = { $in: thr };
+    if (four) info.type = { $in: four };
+    if (five) info.companyStatus = { $in: five };
     const data = await this.model.find(info).skip(skip).limit(limit).lean();
     const total = await this.model.count(info);
     return { data, total };

+ 4 - 17
src/service/users/expert.service.ts

@@ -18,23 +18,10 @@ export class ExpertService extends BaseService<modelType> {
     const { skip = 0, limit = 0, is_show, status, ...condition } = query;
     const { one, two, thr, four } = condition;
     const info: any = { is_show, status };
-    // 如果 one 不是一个数组,你可能需要手动处理
-    if (one) {
-      if (!Array.isArray(one)) info.field = one;
-      else info.field = { $all: one };
-    }
-    if (two) {
-      if (!Array.isArray(two)) info.title = two;
-      else info.title = { $all: two };
-    }
-    if (thr) {
-      if (!Array.isArray(thr)) info.area = thr;
-      else info.area = { $all: thr };
-    }
-    if (four) {
-      if (!Array.isArray(four)) info.education = four;
-      else info.education = { $all: four };
-    }
+    if (one) info.field = { $in: one };
+    if (two) info.title = { $in: two };
+    if (thr) info.area = { $in: thr };
+    if (four) info.area = { $in: four };
     const data = await this.model.find(info).skip(skip).limit(limit).lean();
     const total = await this.model.count(info);
     return { data, total };