|
@@ -1,7 +1,7 @@
|
|
import { Achievement } from '../../entity/platform/achievement.entity';
|
|
import { Achievement } from '../../entity/platform/achievement.entity';
|
|
import { Collection } from '../../entity/platform/collection.entity';
|
|
import { Collection } from '../../entity/platform/collection.entity';
|
|
import { User } from '../../entity/system/user.entity';
|
|
import { User } from '../../entity/system/user.entity';
|
|
-import { get, pick } from 'lodash';
|
|
|
|
|
|
+import { get, isArray } from 'lodash';
|
|
import { Provide } from '@midwayjs/core';
|
|
import { Provide } from '@midwayjs/core';
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
import { Between, Equal, In, Like, MoreThanOrEqual, Repository } from 'typeorm';
|
|
import { Between, Equal, In, Like, MoreThanOrEqual, Repository } from 'typeorm';
|
|
@@ -23,26 +23,53 @@ export class AchievementService extends BaseServiceV2 {
|
|
|
|
|
|
// 多条件查询列表
|
|
// 多条件查询列表
|
|
async list(query) {
|
|
async list(query) {
|
|
- const { skip = 0, limit = 0, is_use, status, name, cityList, fieldList, industryList, matureList, moneyList, sellList, ...condition } = query;
|
|
|
|
|
|
+ const { skip = 0, limit = 0, is_use, status, name, area, field, industry, mature, money, sell, ...condition } = query;
|
|
const whereObject: any = condition;
|
|
const whereObject: any = condition;
|
|
if (name) whereObject.name = { name: Like(`%${name}%`) };
|
|
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'));
|
|
|
|
|
|
+ if (industry) {
|
|
|
|
+ if (!isArray(industry)) whereObject.industry = Equal(industry);
|
|
|
|
+ else whereObject.industry = In(industry);
|
|
|
|
+ }
|
|
|
|
+ if (field) {
|
|
|
|
+ if (!isArray(field)) whereObject.field = Equal(field);
|
|
|
|
+ else whereObject.field = In(field);
|
|
|
|
+ }
|
|
|
|
+ if (sell) {
|
|
|
|
+ if (!isArray(sell)) whereObject.sell = Equal(sell);
|
|
|
|
+ else whereObject.sell = In(sell);
|
|
|
|
+ }
|
|
|
|
+ if (mature) {
|
|
|
|
+ if (!isArray(mature)) whereObject.mature = Equal(mature);
|
|
|
|
+ else whereObject.mature = In(mature);
|
|
|
|
+ }
|
|
|
|
+ if (area) {
|
|
|
|
+ if (!isArray(area)) whereObject.area = Equal(area);
|
|
|
|
+ else whereObject.area = In(area);
|
|
|
|
+ }
|
|
|
|
+ if (money) {
|
|
|
|
+ if (!isArray(money)) {
|
|
|
|
+ let money_title;
|
|
|
|
+ if (money === '1') money_title = Equal('面议');
|
|
|
|
+ if (money === '2') money_title = Between('1', '10');
|
|
|
|
+ if (money === '3') money_title = Between('10', '20');
|
|
|
|
+ if (money === '4') money_title = Between('20', '100');
|
|
|
|
+ if (money === '5') money_title = Between('100', '500');
|
|
|
|
+ if (money === '6') money_title = Between('500', '1000');
|
|
|
|
+ if (money === '7') money_title = MoreThanOrEqual('1000');
|
|
|
|
+ whereObject.money = money_title;
|
|
|
|
+ } else {
|
|
|
|
+ const moneylist = [];
|
|
|
|
+ for (const val of money) {
|
|
|
|
+ if (val === '1') moneylist.push(Equal('面议'));
|
|
|
|
+ if (val === '2') moneylist.push(Between('1', '10'));
|
|
|
|
+ if (val === '3') moneylist.push(Between('10', '20'));
|
|
|
|
+ if (val === '4') moneylist.push(Between('20', '100'));
|
|
|
|
+ if (val === '5') moneylist.push(Between('100', '500'));
|
|
|
|
+ if (val === '6') moneylist.push(Between('500', '1000'));
|
|
|
|
+ if (val === '7') moneylist.push(MoreThanOrEqual('1000'));
|
|
|
|
+ }
|
|
|
|
+ whereObject.money = In(moneylist);
|
|
}
|
|
}
|
|
- whereObject.money = In(money);
|
|
|
|
}
|
|
}
|
|
const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
|
|
const builder = this.model.createQueryBuilder().setFindOptions({ where: whereObject, skip, take: limit });
|
|
const data = await builder.getMany();
|
|
const data = await builder.getMany();
|