zs 1 tahun lalu
induk
melakukan
6437ef3093

+ 2 - 2
src/controller/platform/demand.controller.ts

@@ -33,8 +33,8 @@ export class DemandController extends BaseController {
   }
 
   @Get('/list')
-  async list(@Query() filter) {
-    const list = await this.service.list(filter);
+  async list() {
+    const list = await this.service.list(this.ctx.filter);
     const data = list.data;
     const total = list.total;
     return { data, total };

+ 2 - 2
src/controller/platform/project.controller.ts

@@ -33,8 +33,8 @@ export class ProjectController extends BaseController {
   }
 
   @Get('/list')
-  async list(@Query() filter) {
-    const list = await this.service.list(filter);
+  async list() {
+    const list = await this.service.list(this.ctx.filter);
     const data = list.data;
     const total = list.total;
     return { data, total };

+ 8 - 0
src/controller/users/company.controller.ts

@@ -36,6 +36,14 @@ export class CompanyController extends BaseController {
     return { data, total };
   }
 
+  @Get('/list')
+  async list() {
+    const list = await this.service.list(this.ctx.filter);
+    const data = list.data;
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/:id')
   @ApiResponse({ type: FVO_company })
   async fetch(@Param('id') id: string) {

+ 8 - 0
src/controller/users/expert.controller.ts

@@ -36,6 +36,14 @@ export class ExpertController extends BaseController {
     return { data, total };
   }
 
+  @Get('/list')
+  async list() {
+    const list = await this.service.list(this.ctx.filter);
+    const data = list.data;
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/:id')
   @ApiResponse({ type: FVO_expert })
   async fetch(@Param('id') id: string) {

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

@@ -24,7 +24,7 @@ export class newsQueryMiddleware implements IMiddleware<Context, NextFunction> {
           parsedQuery[key] = rawQuery[key];
         }
       }
-      ctx.request.query = parsedQuery;
+      ctx.filter = parsedQuery;
       await next();
     };
   }

+ 22 - 3
src/service/platform/project.service.ts

@@ -17,8 +17,27 @@ export class ProjectService extends BaseService<modelType> {
   uModel: ReturnModelType<typeof User>;
   // 项目列表
   async list(query) {
-    const { skip = 0, limit = 0, ...condition } = query;
-    const data = await this.model.find(condition).skip(skip).limit(limit).lean();
+    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 };
+    }
+    const data = await this.model.find(info).skip(skip).limit(limit).lean();
     for (const val of data) {
       if (get(val, 'user')) {
         // 查询项目发布者
@@ -26,7 +45,7 @@ export class ProjectService extends BaseService<modelType> {
         if (userData) Object.assign(val, { userName: userData.nick_name });
       }
     }
-    const total = await this.model.count(condition);
+    const total = await this.model.count(info);
     return { data, total };
   }
   //项目详情

+ 31 - 0
src/service/users/company.service.ts

@@ -14,6 +14,37 @@ export class CompanyService extends BaseService<modelType> {
   @InjectEntityModel(Collection)
   cModel: ReturnModelType<typeof Collection>;
 
+  // 企业列表
+  async list(query) {
+    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 };
+    }
+    const data = await this.model.find(info).skip(skip).limit(limit).lean();
+    const total = await this.model.count(info);
+    return { data, total };
+  }
+
   // 企业详情
   async detail(id) {
     const user = this.ctx.user;

+ 27 - 0
src/service/users/expert.service.ts

@@ -13,6 +13,33 @@ export class ExpertService extends BaseService<modelType> {
   @InjectEntityModel(Collection)
   cModel: ReturnModelType<typeof Collection>;
 
+  // 专家列表
+  async list(query) {
+    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 };
+    }
+    const data = await this.model.find(info).skip(skip).limit(limit).lean();
+    const total = await this.model.count(info);
+    return { data, total };
+  }
+
   // 专家详情
   async detail(id) {
     const user = this.ctx.user;