|
@@ -10,9 +10,40 @@ export class CarService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(Car)
|
|
|
model: modelType;
|
|
|
async queryList(filter) {
|
|
|
- const { skip = 0, limit, money, year, ...info } = filter;
|
|
|
+ const { skip = 0, limit, displacement, mileage, money, year, ...info } = filter;
|
|
|
+ // 处理排量
|
|
|
+ if (displacement) {
|
|
|
+ if (displacement.indexOf('下') !== -1) {
|
|
|
+ info.displacement = { $lte: displacement.match(/(\S*)及/)[1] };
|
|
|
+ } else if (displacement.indexOf('上') !== -1) {
|
|
|
+ info.displacement = { $gte: displacement.match(/(\S*)L/)[1] };
|
|
|
+ } else {
|
|
|
+ const mon = displacement.substr(0, year.length - 1);
|
|
|
+ info.displacement = { $gte: mon.match(/(\S*)-/)[1], $lte: mon.match(/-(\S*)/)[1] };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理里程
|
|
|
+ if (mileage) {
|
|
|
+ if (mileage.indexOf('下') !== -1) {
|
|
|
+ info.mileage = { $lte: mileage.match(/(\S*)万/)[1] };
|
|
|
+ } else if (mileage.indexOf('上') !== -1) {
|
|
|
+ info.mileage = { $gte: mileage.match(/(\S*)万/)[1] };
|
|
|
+ } else {
|
|
|
+ const mon = mileage.substr(0, year.length - 1);
|
|
|
+ info.mileage = { $gte: mon.match(/(\S*)-/)[1], $lte: mon.match(/-(\S*)/)[1] };
|
|
|
+ }
|
|
|
+ }
|
|
|
// 处理车龄
|
|
|
- if (year) info.age = { $lte: year.match(/(\S*)年/)[1] };
|
|
|
+ if (year) {
|
|
|
+ if (money.indexOf('下') !== -1) {
|
|
|
+ info.age = { $lte: year.match(/(\S*)年/)[1] };
|
|
|
+ } else if (money.indexOf('上') !== -1) {
|
|
|
+ info.age = { $gte: year.match(/(\S*)年/)[1] };
|
|
|
+ } else {
|
|
|
+ const mon = year.substr(0, year.length - 1);
|
|
|
+ info.age = { $gte: mon.match(/(\S*)-/)[1], $lte: mon.match(/-(\S*)/)[1] };
|
|
|
+ }
|
|
|
+ }
|
|
|
// 处理价格
|
|
|
if (money) {
|
|
|
if (money.indexOf('下') !== -1) {
|