Browse Source

修改查询

zs 9 months ago
parent
commit
1032f756f9

+ 2 - 0
src/controller/platform/achievement.controller.ts

@@ -36,6 +36,8 @@ export class AchievementController implements BaseController {
     const qbr = this.service.queryBuilder({ id });
     const data = await this.service.fetch(qbr);
     const result = new FVO_achievement(data);
+    // 加浏览量
+    await this.service.fetchBrowse(data);
     return result;
   }
 

+ 12 - 0
src/controller/platform/footplate.controller.ts

@@ -6,6 +6,7 @@ import { omit, pick } from 'lodash';
 import { ServiceError, ErrorCode } from '../../error/service.error';
 import { BaseController } from '../../frame/BaseController';
 import { QVO_footplate, FVO_footplate, CVO_footplate, UVAO_footplate } from '../../interface/platform/footplate.interface';
+import { Context } from '@midwayjs/koa';
 const namePrefix = '中试平台';
 @ApiTags(['中试平台'])
 @Controller('/footplate', { tagName: namePrefix })
@@ -13,6 +14,9 @@ export class FootplateController implements BaseController {
   @Inject()
   service: FootplateService;
 
+  @Inject()
+  ctx: Context;
+
   @Get('/')
   @ApiTags('列表查询')
   @ApiQuery({ name: 'query' })
@@ -25,6 +29,14 @@ export class FootplateController implements BaseController {
     return result;
   }
 
+  @Get('/list')
+  async list() {
+    const list = await this.service.list(this.ctx.query);
+    const data = list.data;
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_footplate })

+ 12 - 0
src/controller/platform/support.controller.ts

@@ -6,6 +6,7 @@ import { omit, pick } from 'lodash';
 import { ServiceError, ErrorCode } from '../../error/service.error';
 import { BaseController } from '../../frame/BaseController';
 import { QVO_support, FVO_support, CVO_support, UVAO_support } from '../../interface/platform/support.interface';
+import { Context } from '@midwayjs/koa';
 const namePrefix = '服务支撑';
 @ApiTags(['服务支撑'])
 @Controller('/support', { tagName: namePrefix })
@@ -13,6 +14,9 @@ export class SupportController implements BaseController {
   @Inject()
   service: SupportService;
 
+  @Inject()
+  ctx: Context;
+
   @Get('/')
   @ApiTags('列表查询')
   @ApiQuery({ name: 'query' })
@@ -25,6 +29,14 @@ export class SupportController implements BaseController {
     return result;
   }
 
+  @Get('/list')
+  async list() {
+    const list = await this.service.list(this.ctx.query);
+    const data = list.data;
+    const total = list.total;
+    return { data, total };
+  }
+
   @Get('/:id')
   @ApiTags('单查询')
   @ApiResponse({ type: FVO_support })

+ 2 - 0
src/entity/platform/achievement.entity.ts

@@ -19,6 +19,8 @@ export class Achievement extends BaseModel {
   attribute: string;
   @Column({ type: 'character varying', nullable: true, comment: '出让方式' })
   sell: string;
+  @Column({ type: 'integer', nullable: true, comment: '浏览量' })
+  num: number;
   @Column({ type: 'character varying', nullable: true, comment: '成熟度' })
   mature: string;
   @Column({ type: 'character varying', nullable: true, comment: '行业领域' })

+ 1 - 1
src/entity/platform/support.entity.ts

@@ -9,7 +9,7 @@ export class Support extends BaseModel {
   file: Array<any>;
   @Column({ type: 'character varying', nullable: true, comment: '所属产业' })
   industry: string;
-  @Column({ type: 'jsonb', nullable: true, comment: '标签' , default: []})
+  @Column({ type: 'jsonb', nullable: true, comment: '标签', default: [] })
   tags: Array<any>;
   @Column({ type: 'character varying', nullable: true, comment: '名称' })
   name: string;

+ 1 - 1
src/entity/users/company.entity.ts

@@ -32,7 +32,7 @@ export class Company extends BaseModel {
   email: string;
   @Column({ type: 'integer', nullable: true, comment: '员工人数' })
   person: number;
-  @Column({ type: 'character varying', nullable: true, comment: '简介' })
+  @Column({ type: 'character varying', nullable: true, comment: '注册资本' })
   register: string;
   @Column({ type: 'timestamp without time zone', nullable: true, comment: '成立日期', transformer: { from: value => dayjs(value).format('YYYY-MM-DD HH:mm:ss'), to: value => value } })
   create_time: Date;

+ 7 - 0
src/interface/platform/achievement.interface.ts

@@ -21,6 +21,8 @@ export class FVO_achievement {
   'attribute': string = undefined;
   @ApiProperty({ description: '出让方式' })
   'sell': string = undefined;
+  @ApiProperty({ description: '浏览量' })
+  'num': number = undefined;
   @ApiProperty({ description: '成熟度' })
   'mature': string = undefined;
   @ApiProperty({ description: '行业领域' })
@@ -62,6 +64,8 @@ export class QDTO_achievement {
   'patent': string = undefined;
   @ApiProperty({ description: '名称' })
   'name': string = undefined;
+  @ApiProperty({ description: '浏览量' })
+  'num': number = undefined;
   @ApiProperty({ description: '属性' })
   'attribute': string = undefined;
   @ApiProperty({ description: '出让方式' })
@@ -111,6 +115,9 @@ export class CDTO_achievement {
   @ApiProperty({ description: '名称' })
   @Rule(RuleType['string']().empty(''))
   'name': string = undefined;
+  @ApiProperty({ description: '浏览量' })
+  @Rule(RuleType['number']().empty(''))
+  'num': number = undefined;
   @ApiProperty({ description: '属性' })
   @Rule(RuleType['string']().empty(''))
   'attribute': string = undefined;

+ 2 - 2
src/interface/system/tags.interface.ts

@@ -13,7 +13,7 @@ export class FVO_tags {
   @ApiProperty({ description: '排序' })
   'sort': number = undefined;
   @ApiProperty({ description: '搜索次数' })
-  'number': number = undefined;
+  'num': number = undefined;
   @ApiProperty({ description: '备注' })
   'remark': string = undefined;
   @ApiProperty({ description: '是否使用' })
@@ -24,7 +24,7 @@ export class QDTO_tags extends SearchBase {
   @ApiProperty({ description: '标题' })
   'title': string = undefined;
   @ApiProperty({ description: '搜索次数' })
-  'number': number = undefined;
+  'num': number = undefined;
   @ApiProperty({ description: '是否使用' })
   'is_use': string = undefined;
 }

+ 32 - 53
src/service/platform/achievement.service.ts

@@ -1,11 +1,11 @@
 import { Achievement } from '../../entity/platform/achievement.entity';
 import { Collection } from '../../entity/platform/collection.entity';
 import { User } from '../../entity/system/user.entity';
-import { get, pick } from 'lodash';
+import { get } from 'lodash';
 import { BaseService } from '../../frame/BaseService';
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Between, Equal, In, MoreThanOrEqual, Repository } from 'typeorm';
+import { Between, Equal, In, Like, MoreThanOrEqual, Repository } from 'typeorm';
 @Provide()
 export class AchievementService extends BaseService<Achievement> {
   @InjectEntityModel(Achievement)
@@ -14,64 +14,42 @@ export class AchievementService extends BaseService<Achievement> {
   cModel: Repository<Collection>;
   @InjectEntityModel(User)
   uModel: Repository<User>;
-  // 成果列表
+
+  // 加浏览量
+  async fetchBrowse(data) {
+    const { num = 0, id } = data;
+    await this.model.update({ id }, { num: num + 1 });
+  }
+
+  // 多条件查询列表
   async list(query) {
-    const { skip = 0, limit = 0, is_use, status, field, ...condition } = pick(query, ['skip', 'limit', 'is_use', 'field', 'status']);
-    const { one, two, thr, four, five, six } = pick(query, ['one', 'two', 'thr', 'four', 'five', 'six']);
-    const whereObject: any = { field };
-    // if (is_use) whereObject.is_use = Equal(is_use);
-    // if (status) whereObject.status = Equal(status);
-    if (one) whereObject.technology = In(one);
-    if (two) whereObject.field = In(two);
-    if (thr) whereObject.mature = In(thr);
-    if (four) whereObject.sell = In(four);
-    if (five) {
-      if (five === '1') whereObject.money = Equal('面议');
-      if (five === '2') whereObject.money = Between('1', '10');
-      if (five === '3') whereObject.money = Between('10', '20');
-      if (five === '4') whereObject.money = Between('20', '100');
-      if (five === '5') whereObject.money = Between('100', '500');
-      if (five === '6') whereObject.money = Between('500', '1000');
-      if (five === '7') whereObject.money = MoreThanOrEqual('1000');
+    const { skip = 0, limit = 0, is_use, status, name, cityList, fieldList, industryList, matureList, moneyList, sellList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (sellList) whereObject.sell = In(sellList);
+    if (matureList) whereObject.mature = In(matureList);
+    if (cityList) whereObject.area = In(cityList);
+    if (moneyList) {
+      const money = [];
+      for (const val of moneyList) {
+        if (val === '1') money.push(Equal('面议'));
+        if (val === '2') money.push(Between('1', '10'));
+        if (val === '3') money.push(Between('10', '20'));
+        if (val === '4') money.push(Between('20', '100'));
+        if (val === '5') money.push(Between('100', '500'));
+        if (val === '6') money.push(Between('500', '1000'));
+        if (val === '7') money.push(MoreThanOrEqual('1000'));
+      }
+      whereObject.money = In(money);
     }
-    if (six) whereObject.area = In(six);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();
-    for (const val of data) {
-      if (get(val, 'user')) {
-        // 查询成果发布者
-        const userData = await this.uModel.findOne({ where: { id: Equal(val.user) } });
-        if (userData) Object.assign(val, { userName: userData.nick_name });
-      }
-    }
     return { data, total };
-    // const info: any = { is_use, status };
-    // if (one) info.technology = { $in: one };
-    // if (two) info.field = { $in: two };
-    // if (thr) info.mature = { $in: thr };
-    // if (four) info.sell = { $in: four };
-    // if (five) {
-    //   if (five === '1') info.money = '面议';
-    //   if (five === '2') info.money = { $gte: '1', $lte: '10' };
-    //   if (five === '3') info.money = { $gte: '10', $lte: '20' };
-    //   if (five === '4') info.money = { $gte: '20', $lte: '100' };
-    //   if (five === '5') info.money = { $gte: '100', $lte: '500' };
-    //   if (five === '6') info.money = { $gte: '500', $lte: '1000' };
-    //   if (five === '7') info.money = { $gte: '1000' };
-    // }
-    // if (six) info.area = { $in: six };
-    // const data = await this.model.find(info).skip(skip).limit(limit).lean();
-    // for (const val of data) {
-    //   if (get(val, 'user')) {
-    //     // 查询成果发布者
-    //     const userData = await this.uModel.findById(val.user).lean();
-    //     if (userData) Object.assign(val, { userName: userData.nick_name });
-    //   }
-    // }
-    // const total = await this.model.count(info);
-    // return { data, total };
   }
+
   // 成果详情
   async detail(id) {
     const user = this.ctx.user;
@@ -89,6 +67,7 @@ export class AchievementService extends BaseService<Achievement> {
       const collection = await this.cModel.findOne({ where: { user: Equal(user.id), source: Equal(arr.id) } });
       if (collection) data.is_collection = true;
     }
+    await this.fetchBrowse(arr);
     return { ...arr, ...data };
   }
 }

+ 8 - 36
src/service/platform/demand.service.ts

@@ -4,7 +4,7 @@ import { User } from '../../entity/system/user.entity';
 import { get } from 'lodash';
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Equal, In, Repository } from 'typeorm';
+import { Equal, Like, In, Repository } from 'typeorm';
 import { BaseService } from '../../frame/BaseService';
 @Provide()
 export class DemandService extends BaseService<Demand> {
@@ -15,45 +15,17 @@ export class DemandService extends BaseService<Demand> {
   @InjectEntityModel(User)
   uModel: Repository<User>;
 
-  // 需求列表
+  // 多条件查询列表
   async list(query) {
-    // const { skip = 0, limit = 0, is_use, status, ...condition } = query;
-    const skip = get(query, 'skip', 0);
-    const limit = get(query, 'limit', 0);
-    const is_use = get(query, 'is_use');
-    const status = get(query, 'status');
-    // const { one, two, thr, four } = condition;
-    const one = get(query, 'one');
-    const two = get(query, 'two');
-    const thr = get(query, 'thr');
-    const four = get(query, 'four');
-    const field = get(query, 'field');
-
-    const whereObject: any = { field };
-    // if (is_use) whereObject.is_use = Equal(is_use);
-    // if (status) whereObject.status = Equal(status);
-    if (one) whereObject.field = In(one);
-    if (two) whereObject.method = In(two);
-    if (thr) whereObject.area = In(thr);
-    if (four) whereObject.demand_status = In(four);
+    const { skip = 0, limit = 0, name, is_use, status, cityList, fieldList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (cityList) whereObject.area = In(cityList);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();
-    // const info: any = { is_use, status };
-    // 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')) {
-        // 查询需求发布者
-        // const userData = await this.uModel.findById(val.user).lean();
-        const userData = await this.uModel.findOne({ where: { id: Equal(val.user) } });
-        if (userData) Object.assign(val, { userName: userData.nick_name });
-      }
-    }
-    // const total = await this.model.count(info);
     return { data, total };
   }
   // 需求详情

+ 14 - 1
src/service/platform/footplate.service.ts

@@ -1,10 +1,23 @@
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Repository } from 'typeorm';
+import { In, Like, Repository } from 'typeorm';
 import { Footplate } from '../../entity/platform/footplate.entity';
 import { BaseService } from '../../frame/BaseService';
 @Provide()
 export class FootplateService extends BaseService<Footplate> {
   @InjectEntityModel(Footplate)
   model: Repository<Footplate>;
+
+  // 多条件查询列表
+  async list(query) {
+    const { skip = 0, limit = 0, name, cityList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (cityList) whereObject.area = In(cityList);
+    const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
+    const data = await builder.getMany();
+    const total = await builder.getCount();
+    return { data, total };
+  }
 }

+ 12 - 29
src/service/platform/project.service.ts

@@ -1,10 +1,10 @@
 import { Project } from '../../entity/platform/project.entity';
 import { Collection } from '../../entity/platform/collection.entity';
 import { User } from '../../entity/system/user.entity';
-import { get, pick } from 'lodash';
+import { get } from 'lodash';
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Equal, In, Repository } from 'typeorm';
+import { Equal, In, Like, Repository } from 'typeorm';
 import { BaseService } from '../../frame/BaseService';
 @Provide()
 export class ProjectService extends BaseService<Project> {
@@ -14,39 +14,22 @@ export class ProjectService extends BaseService<Project> {
   cModel: Repository<Collection>;
   @InjectEntityModel(User)
   uModel: Repository<User>;
-  // 项目列表
-  async list(query) {
-    const { skip = 0, limit = 0, is_use, status, ...condition } = pick(query, ['skip', 'limit', 'is_use', 'status']);
-    const { one, two, thr, four } = pick(query, ['one', 'two', 'thr', 'four']);
 
-    const whereObject: any = {};
-    if (is_use) whereObject.is_show = Equal(is_use);
-    if (status) whereObject.status = Equal(status);
-    if (one) whereObject.field = In(one);
-    if (two) whereObject.cooperate = In(two);
-    if (thr) whereObject.area = In(thr);
-    if (four) whereObject.maturity = In(four);
+  // 多条件查询列表
+  async list(query) {
+    const { skip = 0, limit = 0, name, is_use, status, cityList, fieldList, maturityList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (cityList) whereObject.area = In(cityList);
+    if (maturityList) whereObject.maturity = In(maturityList);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();
-
-    // const info: any = { is_use, status };
-    // 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')) {
-        // 查询项目发布者
-        // const userData = await this.uModel.findById(val.user).lean();
-        const userData = await this.uModel.findOne({ where: { id: Equal(val.user) } });
-        if (userData) Object.assign(val, { userName: userData.nick_name });
-      }
-    }
-    // const total = await this.model.count(info);
     return { data, total };
   }
+
   //项目详情
   async detail(id) {
     const user = this.ctx.user;

+ 10 - 35
src/service/platform/supply.service.ts

@@ -4,7 +4,7 @@ import { User } from '../../entity/system/user.entity';
 import { get, pick } from 'lodash';
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Equal, In, Repository } from 'typeorm';
+import { Equal, In, Like, Repository } from 'typeorm';
 import { BaseService } from '../../frame/BaseService';
 @Provide()
 export class SupplyService extends BaseService<Supply> {
@@ -14,46 +14,21 @@ export class SupplyService extends BaseService<Supply> {
   cModel: Repository<Collection>;
   @InjectEntityModel(User)
   uModel: Repository<User>;
-  // 需求列表
-  async list(query) {
-    // const { skip = 0, limit = 0, is_use, status, ...condition } = query;
-    const skip = get(query, 'skip', 0);
-    const limit = get(query, 'limit', 0);
-    const is_use = get(query, 'is_use');
-    const status = get(query, 'status');
-    // const { one, two, thr, four } = condition;
-    const one = get(query, 'one');
-    const two = get(query, 'two');
-    const thr = get(query, 'thr');
-    const four = get(query, 'four');
 
-    const whereObject: any = {};
-    // if (is_use) whereObject.is_use = Equal(is_use);
-    // if (status) whereObject.status = Equal(status);
-    if (one) whereObject.field = In(one);
-    if (two) whereObject.method = In(two);
-    if (thr) whereObject.area = In(thr);
-    if (four) whereObject.demand_status = In(four);
+  // 多条件查询列表
+  async list(query) {
+    const { skip = 0, limit = 0, name, is_use, status, cityList, fieldList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (cityList) whereObject.area = In(cityList);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();
-    // const info: any = { is_use, status };
-    // 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')) {
-        // 查询需求发布者
-        // const userData = await this.uModel.findById(val.user).lean();
-        const userData = await this.uModel.findOne({ where: { id: Equal(val.user) } });
-        if (userData) Object.assign(val, { userName: userData.nick_name });
-      }
-    }
-    // const total = await this.model.count(info);
     return { data, total };
   }
+
   // 需求详情
   async detail(id) {
     const user = this.ctx.user;

+ 15 - 1
src/service/platform/support.service.ts

@@ -1,10 +1,24 @@
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Repository } from 'typeorm';
+import { In, Like, Repository } from 'typeorm';
 import { Support } from '../../entity/platform/support.entity';
 import { BaseService } from '../../frame/BaseService';
 @Provide()
 export class SupportService extends BaseService<Support> {
   @InjectEntityModel(Support)
   model: Repository<Support>;
+
+  // 多条件查询列表
+  async list(query) {
+    const { skip = 0, limit = 0, name, cityList, fieldList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (cityList) whereObject.area = In(cityList);
+    const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
+    const data = await builder.getMany();
+    const total = await builder.getCount();
+    return { data, total };
+  }
 }

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

@@ -1,10 +1,10 @@
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Equal, In, Repository } from 'typeorm';
+import { Equal, Like, In, Repository } from 'typeorm';
 import { BaseService } from '../../frame/BaseService';
 import { Company } from '../../entity/users/company.entity';
 import { Collection } from '../../entity/platform/collection.entity';
-import { get, pick } from 'lodash';
+import { get } from 'lodash';
 @Provide()
 export class CompanyService extends BaseService<Company> {
   @InjectEntityModel(Company)
@@ -12,29 +12,17 @@ export class CompanyService extends BaseService<Company> {
   @InjectEntityModel(Collection)
   cModel: Repository<Collection>;
 
-  // 企业列表
+  // 多条件查询列表
   async list(query) {
-    const { skip = 0, limit = 0, is_show, status, ...condition } = pick(query, ['skip', 'limit', 'is_show', 'status']);
-    const { one, two, thr, four, five } = pick(query, ['one', 'two', 'thr', 'four', 'five']);
-    const whereObject: any = {};
-    if (is_show) whereObject.is_show = Equal(is_show);
-    if (status) whereObject.status = Equal(status);
-    if (one) whereObject.scale = In(one);
-    if (two) whereObject.pattern = In(two);
-    if (thr) whereObject.area = In(thr);
-    if (four) whereObject.type = In(four);
-    if (five) whereObject.companyStatus = In(five);
+    const { skip = 0, limit = 0, name, is_use, status, cityList, patternList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (patternList) whereObject.pattern = In(patternList);
+    if (cityList) whereObject.area = In(cityList);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();
-    // const info: any = { is_show, status };
-    // 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 };
   }
 

+ 10 - 13
src/service/users/expert.service.ts

@@ -1,10 +1,10 @@
 import { Provide } from '@midwayjs/core';
 import { InjectEntityModel } from '@midwayjs/typeorm';
-import { Equal, In, Repository } from 'typeorm';
+import { Equal, Like, In, Repository } from 'typeorm';
 import { BaseService } from '../../frame/BaseService';
 import { Collection } from '../../entity/platform/collection.entity';
 import { Expert } from '../../entity/users/expert.entity';
-import { get, pick } from 'lodash';
+import { get } from 'lodash';
 @Provide()
 export class ExpertService extends BaseService<Expert> {
   @InjectEntityModel(Expert)
@@ -13,17 +13,14 @@ export class ExpertService extends BaseService<Expert> {
   @InjectEntityModel(Collection)
   cModel: Repository<Collection>;
 
-  // 企业列表
-  async list(query: any) {
-    const { skip = 0, limit = 0, is_show, status } = pick(query, ['skip', 'limit', 'is_show', 'status']);
-    const { one, two, thr, four } = pick(query, ['one', 'two', 'thr', 'four']);
-    const whereObject: any = {};
-    // if (is_show) whereObject.is_show = Equal(is_show);
-    // if (status) whereObject.status = Equal(status);
-    if (one) whereObject.field = In(one);
-    if (two) whereObject.title = In(two);
-    if (thr) whereObject.area = In(thr);
-    if (four) whereObject.area = In(four);
+  // 多条件查询列表
+  async list(query) {
+    const { skip = 0, limit = 0, name, is_use, status, cityList, fieldList, industryList, ...condition } = query;
+    const whereObject: any = condition;
+    if (name) whereObject.name = { name: Like(`%${name}%`) };
+    if (industryList) whereObject.industry = In(industryList);
+    if (fieldList) whereObject.field = In(fieldList);
+    if (cityList) whereObject.area = In(cityList);
     const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
     const data = await builder.getMany();
     const total = await builder.getCount();