CarServiceImpl.java
2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.glsx.publicservice.service.impl;
import com.alibaba.dubbo.config.annotation.Reference;
import com.glsx.biz.common.base.entity.CarBrandSelected;
import com.glsx.biz.common.base.entity.CarInfoSelected;
import com.glsx.biz.common.base.entity.Carbrand;
import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype;
import com.glsx.biz.common.base.service.CarbrandService;
import com.glsx.biz.common.base.service.CarseriesService;
import com.glsx.biz.common.base.service.CartypeService;
import com.glsx.publicservice.service.CarService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service
public class CarServiceImpl implements CarService {
@Reference(version = "2.2.0")
private CarbrandService carbrandService;
@Reference(version = "2.2.0")
private CarseriesService carseriesService;
@Reference(version = "2.2.0")
private CartypeService cartypeService;
@Override
public List<Carbrand> getCarbrandList() {
// TODO Auto-generated method stub
return carbrandService.getAllList();
}
@Override
public List<Carseries> getCarseriesList(Integer bid) {
// TODO Auto-generated method stub
return carseriesService.getByCarbrandId(bid);
}
@Override
public List<Cartype> getCartypeList(Integer seriesId) {
// TODO Auto-generated method stub
return cartypeService.getBySeiesId(seriesId);
}
@Override
public Carbrand getCarbrandById(Integer bid) {
// TODO Auto-generated method stub
return carbrandService.findById(bid);
}
@Override
public Carseries getCarseriesById(Integer seriesId) {
// TODO Auto-generated method stub
return carseriesService.findById(seriesId);
}
@Override
public Cartype getCartypeById(Integer seriesId, Integer cartypeId) {
// TODO Auto-generated method stub
return cartypeService.get(seriesId, cartypeId);
}
@Override
public Cartype getCarTypeDetail( Integer cartypeId) {
return cartypeService.get( cartypeId);
}
@Override
public List<CarBrandSelected> getCarbrandTree(Integer type) {
if (Objects.isNull(type)) {
type = 2;
}
List<CarBrandSelected> carInfoCompleteForSelected = carbrandService.getCarInfoCompleteForSelected();
int finalType = type;
carInfoCompleteForSelected.forEach(first -> {
List<CarInfoSelected> secondList = first.getChilds();
if (CollectionUtils.isNotEmpty(secondList)) {
secondList.forEach(second -> {
if (finalType == 2) {
second.setChilds(null);
} else if (finalType == 3) {
List<CarInfoSelected> thridList = second.getChilds();
if (CollectionUtils.isNotEmpty(thridList)) {
thridList.forEach(third -> {
third.setChilds(null);
});
}
}
});
}
});
return carInfoCompleteForSelected;
}
}