Commit 889a3088 by xiehx

v1.76.0版本代码合并到主干

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@36399 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent b9798412
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<dependency> <dependency>
<groupId>com.glsx.biz</groupId> <groupId>com.glsx.biz</groupId>
<artifactId>biz-base-service</artifactId> <artifactId>biz-base-service</artifactId>
<version>2.2.0-SNAPSHOT</version> <version>3.0.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.glxn</groupId> <groupId>net.glxn</groupId>
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -4,6 +4,7 @@ import java.util.HashMap; ...@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.glsx.biz.common.base.entity.CarBrandSelected;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
...@@ -33,6 +34,25 @@ public class CarController extends BaseController { ...@@ -33,6 +34,25 @@ public class CarController extends BaseController {
private CarService carService; private CarService carService;
/** /**
* 获取汽车品牌树(二级或者三级)
*
* @return
*/
@RequestMapping(value = "/getCarbrandTree", method = { RequestMethod.GET, RequestMethod.POST })
public ResultObject getCarbrandTree(Integer type) {
try {
Map<String, Object> result = new HashMap<String, Object>();
List<CarBrandSelected> list = carService.getCarbrandTree(type);
result.put("item", list);
return new ResultObject(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMsg(), result);
} catch (Exception e) {
logger.error("获取汽车品牌列表失败" + e.getMessage(), e);
return new ResultObject(ResultCodeEnum.ERROR.getCode(), ResultCodeEnum.ERROR.getMsg());
}
}
/**
* 获取品牌列表 * 获取品牌列表
* *
* @return * @return
......
...@@ -2,6 +2,7 @@ package com.glsx.publicservice.service; ...@@ -2,6 +2,7 @@ package com.glsx.publicservice.service;
import java.util.List; import java.util.List;
import com.glsx.biz.common.base.entity.CarBrandSelected;
import com.glsx.biz.common.base.entity.Carbrand; import com.glsx.biz.common.base.entity.Carbrand;
import com.glsx.biz.common.base.entity.Carseries; import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype; import com.glsx.biz.common.base.entity.Cartype;
...@@ -58,4 +59,11 @@ public interface CarService { ...@@ -58,4 +59,11 @@ public interface CarService {
Cartype getCartypeById(Integer seriesId, Integer cartypeId); Cartype getCartypeById(Integer seriesId, Integer cartypeId);
Cartype getCarTypeDetail( Integer cartypeId) ; Cartype getCarTypeDetail( Integer cartypeId) ;
/**
*
* @param type 品牌树层级 2:二级 3:三级
* @return
*/
List<CarBrandSelected> getCarbrandTree(Integer type);
} }
package com.glsx.publicservice.service.impl; package com.glsx.publicservice.service.impl;
import com.alibaba.dubbo.config.annotation.Reference; 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.Carbrand;
import com.glsx.biz.common.base.entity.Carseries; import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype; import com.glsx.biz.common.base.entity.Cartype;
...@@ -8,9 +10,11 @@ import com.glsx.biz.common.base.service.CarbrandService; ...@@ -8,9 +10,11 @@ import com.glsx.biz.common.base.service.CarbrandService;
import com.glsx.biz.common.base.service.CarseriesService; import com.glsx.biz.common.base.service.CarseriesService;
import com.glsx.biz.common.base.service.CartypeService; import com.glsx.biz.common.base.service.CartypeService;
import com.glsx.publicservice.service.CarService; import com.glsx.publicservice.service.CarService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Objects;
@Service @Service
public class CarServiceImpl implements CarService { public class CarServiceImpl implements CarService {
...@@ -60,4 +64,32 @@ public class CarServiceImpl implements CarService { ...@@ -60,4 +64,32 @@ public class CarServiceImpl implements CarService {
public Cartype getCarTypeDetail( Integer cartypeId) { public Cartype getCarTypeDetail( Integer cartypeId) {
return cartypeService.get( 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;
}
} }
...@@ -2,7 +2,7 @@ spring.application.name=car-service-publicservice ...@@ -2,7 +2,7 @@ spring.application.name=car-service-publicservice
server.port=8096 server.port=8096
#nacos\u914D\u7F6E #nacos\u914D\u7F6E
spring.cloud.nacos.config.group=BHG_GROUP spring.cloud.nacos.config.group=BHG_GROUP
spring.cloud.nacos.config.server-addr=192.168.0.63:8858 spring.cloud.nacos.config.server-addr=192.168.3.102:8858
#configClient #configClient
#spring.cloud.config.name=${spring.application.name} #spring.cloud.config.name=${spring.application.name}
#spring.cloud.config.profile=local #spring.cloud.config.profile=local
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!