Commit 84dd6843 by zhanghj

V1.0.0--提交汽车品牌(通过dubbo调用其它部门的服务)相关接口功能

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@17402 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 3df49e91
package com.glsx.common.feign.client;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.alibaba.fastjson.JSONObject;
import com.glsx.common.config.FeignConfig;
/**
*
* @Title CarBrandClient.java
* @Package com.glsx.common.feign.client
* @Description TODO 汽车品牌相关接口feign
* @author zhanghj
* @date 2019年2月16日 下午3:12:54
* @version 1.0.0
*/
@FeignClient(name="car-service-publicservicer", configuration=FeignConfig.class)
public interface CarBrandClient {
/**
*
* @author zhanghj
* @Title: getCarbrandList
* @Description: TODO 获取汽车品牌列表
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/car/getCarbrandList", method=RequestMethod.GET)
public JSONObject getCarbrandList();
/**
*
* @author zhanghj
* @Title: getCarseriesList
* @Description: TODO 根据汽车品牌id,获取车系列表
* @param brandId
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/car/getCarseriesList", method=RequestMethod.GET)
public JSONObject getCarseriesList(Integer brandId);
/**
*
* @author zhanghj
* @Title: getCartypeList
* @Description: TODO 根据汽车车系id,获取车型列表
* @param seriesId
* @return
* JSONObject
*
*/
@RequestMapping(value="/carservice/publicservice/car/getCartypeList", method=RequestMethod.GET)
public JSONObject getCartypeList(Integer seriesId);
}
...@@ -19,9 +19,27 @@ import com.glsx.common.config.FeignConfig; ...@@ -19,9 +19,27 @@ import com.glsx.common.config.FeignConfig;
@FeignClient(name="car-service-usercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-usercenter", configuration=FeignConfig.class)
public interface MenuClient { public interface MenuClient {
/**
*
* @author zhanghj
* @Title: getUserPermissionAllMenuList
* @Description: TODO 获取该用户所拥有的权限菜单列表
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/sysMenu/getUserPermissionAllMenuList") @RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/sysMenu/getUserPermissionAllMenuList")
JSONObject getUserPermissionAllMenuList(); JSONObject getUserPermissionAllMenuList();
/**
*
* @author zhanghj
* @Title: getAllMenuList 获取所有菜单列表
* @Description: TODO
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/sysMenu/getAllMenuList") @RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/sysMenu/getAllMenuList")
JSONObject getAllMenuList(); JSONObject getAllMenuList();
} }
...@@ -23,6 +23,16 @@ import com.glsx.common.pojo.OperateLog; ...@@ -23,6 +23,16 @@ import com.glsx.common.pojo.OperateLog;
@FeignClient(name="car-service-manager", configuration=FeignConfig.class) @FeignClient(name="car-service-manager", configuration=FeignConfig.class)
public interface OperateLogClient { public interface OperateLogClient {
/**
*
* @author zhanghj
* @Title: save
* @Description: TODO 保存操作日志
* @param optLog
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.POST, value = "/carservice/manager/operateLog/save") @RequestMapping(method = RequestMethod.POST, value = "/carservice/manager/operateLog/save")
JSONObject save(@RequestBody OperateLog optLog); JSONObject save(@RequestBody OperateLog optLog);
} }
...@@ -21,7 +21,15 @@ import com.glsx.common.config.FeignConfig; ...@@ -21,7 +21,15 @@ import com.glsx.common.config.FeignConfig;
@FeignClient(name="car-service-usercenter", configuration=FeignConfig.class) @FeignClient(name="car-service-usercenter", configuration=FeignConfig.class)
public interface UserClient { public interface UserClient {
//@RequestLine("GET /carservice/usercenter/user/isLogin") /**
*
* @author zhanghj
* @Title: isLogin
* @Description: TODO 用户是否登录
* @return
* JSONObject
*
*/
@RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/user/isLogin") @RequestMapping(method = RequestMethod.GET, value = "/carservice/usercenter/user/isLogin")
JSONObject isLogin(); JSONObject isLogin();
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>car-service-publicservice</artifactId> <artifactId>car-service-publicservice</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
<packaging>war</packaging>
<name>car-service-publicservice</name> <name>car-service-publicservice</name>
<!-- FIXME change it to the project's website --> <!-- FIXME change it to the project's website -->
...@@ -20,6 +21,10 @@ ...@@ -20,6 +21,10 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<zkclient.version>0.1</zkclient.version>
<zookeeper.version>3.4.5</zookeeper.version>
<dubbo.version>2.5.3</dubbo.version>
<cloudframework.version>2.1.3.RELEASE</cloudframework.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -28,6 +33,10 @@ ...@@ -28,6 +33,10 @@
<artifactId>car-service-common</artifactId> <artifactId>car-service-common</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- spring-boot-devtools --> <!-- spring-boot-devtools -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -39,6 +48,63 @@ ...@@ -39,6 +48,63 @@
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.sgroschupf</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper.version}</version>
<exclusions>
<exclusion>
<artifactId>jmxtools</artifactId>
<groupId>com.sun.jdmk</groupId>
</exclusion>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
<exclusion>
<artifactId>jms</artifactId>
<groupId>javax.jms</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- 汽车品牌 相关dubbo -->
<dependency>
<groupId>com.glsx.biz</groupId>
<artifactId>biz-base-service</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.glxn</groupId>
<artifactId>qrgen</artifactId>
<version>1.4</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.glsx.publicservice.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
/**
*
* @Title BaseController.java
* @Package com.glsx.publicservice.controller
* @Description TODO
* @author zhanghj
* @date 2019年2月16日 上午10:55:47
* @version 1.0.0
*/
public class BaseController {
public Logger logger = LoggerFactory.getLogger(getClass());
/**
* hibernate-validator参数校验返回错误方法
* @param result
* @return
*/
public Map<String, String> getErrors(BindingResult result) {
Map<String, String> map = new HashMap<String, String>();
List<FieldError> list = result.getFieldErrors();
for (FieldError error : list) {
map.put(error.getField(), error.getDefaultMessage());
}
return map;
}
/**
* hibernate-validator对于特殊参数格式的校验方式
* @param object
* @return
*/
public Map<String, String> getErrors(Object object) {
Map<String, String> map = new HashMap<String, String>();
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object);
for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
String key = constraintViolation.getPropertyPath().toString();
String value = constraintViolation.getMessage();
map.put(key, value);
}
return map;
}
}
package com.glsx.publicservice.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
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.common.constants.ResultCodeEnum;
import com.glsx.common.constants.ResultObject;
import com.glsx.publicservice.service.CarService;
/**
*
* @Title CarController.java
* @Package com.glsx.publicservice.controller
* @Description TODO
* @author zhanghj
* @date 2019年2月16日 上午10:54:58
* @version 1.0.0
*/
@RestController
@RequestMapping(value="/car")
public class CarController extends BaseController{
@Autowired
private CarService carService;
/**
* 获取品牌列表
* @return
*/
@RequestMapping(value="/getCarbrandList", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject getCarbrandList(){
try{
Map<String, Object> result = new HashMap<String, Object>();
List<Carbrand> list = carService.getCarbrandList();
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());
}
}
/**
* 根据汽车品牌id,获取车系列表
* @param bid
* @return
*/
@RequestMapping(value="/getCarseriesList", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject getCarseriesList(Integer brandId){
try{
if (brandId == null) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
Map<String, Object> result = new HashMap<String, Object>();
List<Carseries> list = carService.getCarseriesList(brandId);
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());
}
}
/**
* 根据汽车车系id,获取车型列表
* @param bid
* @return
*/
@RequestMapping(value="/getCartypeList", method={RequestMethod.GET, RequestMethod.POST})
public ResultObject getCartypeList(Integer seriesId){
try{
if (seriesId == null) {
return new ResultObject(ResultCodeEnum.PARAM_ERROR.getCode(), ResultCodeEnum.PARAM_ERROR.getMsg());
}
Map<String, Object> result = new HashMap<String, Object>();
List<Cartype> list = carService.getCartypeList(seriesId);
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());
}
}
}
package com.glsx.publicservice.service;
import java.util.List;
import com.glsx.biz.common.base.entity.Carbrand;
import com.glsx.biz.common.base.entity.Carseries;
import com.glsx.biz.common.base.entity.Cartype;
/**
*
* @Title CarbrandService.java
* @Package com.glsx.publicservice.service
* @Description TODO 汽车品牌
* @author zhanghj
* @date 2018年7月24日 下午8:39:03
* @version
*/
public interface CarService {
/**
* 获取所有的汽车品牌
* @return
*/
List<Carbrand> getCarbrandList();
/**
* 根据汽车品牌id,获取车系列表
* @param bid
* @return
*/
List<Carseries> getCarseriesList(Integer bid);
/**
* 通过车系id,获取车型列表
* @param bid
* @return
*/
List<Cartype> getCartypeList(Integer seriesId);
/**
* 根据品牌id获取品牌信息
* @param bid
* @return
*/
Carbrand getCarbrandById(Integer bid);
/**
* 根据车系id获取车系信息
* @param seriesId
* @return
*/
Carseries getCarseriesById(Integer seriesId);
/**
* 根据车型id获取车型信息
* @param cartypeId
* @return
*/
Cartype getCartypeById(Integer seriesId, Integer cartypeId);
}
package com.glsx.publicservice.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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;
@Service
public class CarServiceImpl implements CarService {
@Autowired
private CarbrandService carbrandService;
@Autowired
private CarseriesService carseriesService;
@Autowired
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);
}
}
...@@ -5,12 +5,7 @@ spring.application.name=car-service-publicservice ...@@ -5,12 +5,7 @@ spring.application.name=car-service-publicservice
server.servlet.context-path=/carservice/publicservice server.servlet.context-path=/carservice/publicservice
server.port=8096 server.port=8096
#eurekaClient
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
#\u5fc3\u8df3
#eureka.instance.lease-renewal-interval-in-seconds=5
##\u65e5\u5fd7 test ##\u65e5\u5fd7 test
logging.level.com.glsx.usercenter=DEBUG logging.level.com.glsx.usercenter=DEBUG
logging.path=/data/java_log/jetty/car-service-publicservice logging.path=/data/java_log/jetty/car-service-publicservice
logging.config=classpath:logback-spring.xml logging.config=classpath:logback-spring.xml
\ No newline at end of file \ No newline at end of file
...@@ -62,6 +62,17 @@ spring.redis.ssl=false ...@@ -62,6 +62,17 @@ spring.redis.ssl=false
# Connection timeout. # Connection timeout.
spring.redis.timeout=6000ms spring.redis.timeout=6000ms
#eurekaClient
eureka.client.enabled=true
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
#\u5fc3\u8df3
#eureka.instance.lease-renewal-interval-in-seconds=5
##feign\u914d\u7f6e
feign.client.config.default.connectTimeout=30000
feign.client.config.default.readTimeout=30000
feign.client.config.default.loggerLevel=basic
#\u77ed\u4fe1 #\u77ed\u4fe1
#sms.url=http://192.168.3.206:8118/router111 #sms.url=http://192.168.3.206:8118/router111
#sms.url=http://qcdidicb.glsx.net:7060/router #sms.url=http://qcdidicb.glsx.net:7060/router
...@@ -76,14 +87,7 @@ fdfs.trackerList=192.168.0.63:22122 ...@@ -76,14 +87,7 @@ fdfs.trackerList=192.168.0.63:22122
#fdfs_tracker_nginx_port=80 #fdfs_tracker_nginx_port=80
fdfs_tracker_nginx_domain=http://192.168.0.63 fdfs_tracker_nginx_domain=http://192.168.0.63
##freemarker #dubbo\u914d\u7f6e
spring.freemarker.cache=false dubbo.application.owner=common_merchant
spring.freemarker.charset=UTF-8 dubbo.registry.address=zookeeper://192.168.1.36:2181
spring.freemarker.check-template-location=true dubbo.application.name=biz-merchant-service-provider
spring.freemarker.content-type=text/html
spring.freemarker.enabled=true
spring.freemarker.suffix=.ftl
spring.freemarker.template-loader-path=classpath:/templates
#\u9759\u6001\u8d44\u6e90\u8def\u5f84
spring.mvc.static-path-pattern=/**
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
">
<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样hhx_gps_consumer -->
<dubbo:application name="biz-merchant-service-provider"/>
<!--使用zookeeper注册中心暴露服务地址
<dubbo:registry address="multicast://224.5.6.7:1234" />-->
<!-- dubbo接口去除注册中心,采用直连的方式 -->
<!-- <dubbo:registry address="${dubbo.registry.address}"/> -->
<dubbo:registry address="zookeeper://192.168.1.36:2181"/>
<dubbo:consumer timeout="20000"/>
<!-- 汽车品牌 dev-->
<dubbo:reference id="carbrandService" interface="com.glsx.biz.common.base.service.CarbrandService" version="2.2.0" timeout="100000" retries="0"/>
<dubbo:reference id="carseriesService" interface="com.glsx.biz.common.base.service.CarseriesService" version="2.2.0" timeout="100000" retries="0"/>
<dubbo:reference id="cartypeService" interface="com.glsx.biz.common.base.service.CartypeService" version="2.2.0" timeout="100000" retries="0"/>
<!-- 汽车品牌 test-->
<!-- <dubbo:reference id="carbrandService" interface="com.glsx.biz.common.base.service.CarbrandService" url="dubbo://183.62.222.182:9968" version="2.2.0" timeout="100000" retries="0"/>
<dubbo:reference id="carseriesService" interface="com.glsx.biz.common.base.service.CarseriesService" url="dubbo://183.62.222.182:9968" version="2.2.0" timeout="100000" retries="0"/>
<dubbo:reference id="cartypeService" interface="com.glsx.biz.common.base.service.CartypeService" url="dubbo://183.62.222.182:9968" version="2.2.0" timeout="100000" retries="0"/>
-->
</beans>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.glsx.usercenter.mapper.TestMapper" >
<resultMap id="baseUserResultMap" type="com.glsx.usercenter.pojo.Test" >
<id column="id" property="id"/>
<result column="username" property="username"/>
</resultMap>
<select id="get" parameterType="com.glsx.usercenter.pojo.Test" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
where id = #{id}
</select>
<select id="list" resultMap="baseUserResultMap">
select
u.id, u.username
from sys_user u
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!