Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-clickhouse
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
提交
打开侧边栏
com.pica.cloud.clickhouse
pica-cloud-clickhouse
提交
379362b2
提交
379362b2
编写于
6月 01, 2019
作者:
liugen.wen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add jar
上级
3813ac52
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
0 行增加
和
128 行删除
+0
-128
IConfigServiceClient.java
...khouse/clickhouse/server/client/IConfigServiceClient.java
+0
-22
ConfigServerClient.java
...use/clickhouse/server/client/impl/ConfigServerClient.java
+0
-12
BeanConfiguration.java
...se/clickhouse/server/configuration/BeanConfiguration.java
+0
-21
DemoController.java
...ickhouse/clickhouse/server/controller/DemoController.java
+0
-73
未找到文件。
server/src/main/java/com/pica/cloud/clickhouse/clickhouse/server/client/IConfigServiceClient.java
已删除
100644 → 0
浏览文件 @
3813ac52
package
com
.
pica
.
cloud
.
clickhouse
.
clickhouse
.
server
.
client
;
import
org.springframework.cloud.netflix.feign.FeignClient
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
/**
* CONFIG-SERVER: 服务名称
* 服务名称可以从eureka(http://192.168.110.120:7891/)上获得
*/
@FeignClient
(
value
=
"CONFIG-SERVER"
)
public
interface
IConfigServiceClient
{
/**
* 被调用服务的签名
*
* 注意,定义此接口时,@RequestParam("xxx")和@ReqeustHead("xxx")必须写value,
* 不同于springmvc自动根据参数名作为默认值,feign必须指定这个参数对应哪个服务提供端的参数
*/
@RequestMapping
(
value
=
"/beans"
,
method
=
RequestMethod
.
GET
)
String
beans
();
}
server/src/main/java/com/pica/cloud/clickhouse/clickhouse/server/client/impl/ConfigServerClient.java
已删除
100644 → 0
浏览文件 @
3813ac52
package
com
.
pica
.
cloud
.
clickhouse
.
clickhouse
.
server
.
client
.
impl
;
import
org.springframework.stereotype.Component
;
import
com.pica.cloud.clickhouse.clickhouse.server.client.IConfigServiceClient
;
@Component
public
class
ConfigServerClient
implements
IConfigServiceClient
{
@Override
public
String
beans
()
{
return
"Get bean failed!"
;
}
}
server/src/main/java/com/pica/cloud/clickhouse/clickhouse/server/configuration/BeanConfiguration.java
已删除
100644 → 0
浏览文件 @
3813ac52
package
com
.
pica
.
cloud
.
clickhouse
.
clickhouse
.
server
.
configuration
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
com.pica.cloud.foundation.redis.RedisClient
;
@Configuration
@RefreshScope
public
class
BeanConfiguration
{
@Value
(
"${spring.redis.config}"
)
private
String
configStr
;
@Bean
public
RedisClient
redisClient
()
{
System
.
out
.
println
(
configStr
);
return
new
RedisClient
(
configStr
);
}
}
server/src/main/java/com/pica/cloud/clickhouse/clickhouse/server/controller/DemoController.java
已删除
100644 → 0
浏览文件 @
3813ac52
package
com
.
pica
.
cloud
.
clickhouse
.
clickhouse
.
server
.
controller
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.redis.RedisClient
;
import
com.pica.cloud.clickhouse.clickhouse.server.client.IConfigServiceClient
;
import
com.pica.cloud.clickhouse.clickhouse.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.clickhouse.clickhouse.server.mapper.HospitalMapper
;
import
com.pica.cloud.clickhouse.clickhouse.server.entity.Hospital
;
@RestController
@RequestMapping
(
"/demo"
)
@Api
(
value
=
"冒烟测试"
,
description
=
"测试 db,redis,读取自定义配置 以及使用 feign 调用微服务"
)
public
class
DemoController
{
@Autowired
private
HospitalMapper
personMapper
;
@Autowired
private
RedisClient
redisClient
;
@Autowired
private
PropertiesConfiguration
properties
;
@Autowired
private
LoadBalancerClient
slb
;
@Autowired
private
IConfigServiceClient
client
;
@ApiOperation
(
value
=
"DB连接测试:更新Person对象"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/db"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
Hospital
>
saveToDB
()
{
// 创建一个ResponseBuilder
PicaResponse
.
Builder
<
Hospital
>
builder
=
new
PicaResponse
.
Builder
<>();
builder
.
setData
(
personMapper
.
selectByPrimaryKey
(
1008
));
// 返回Response
return
builder
.
build
();
}
@ApiOperation
(
value
=
"Redis连接测试:插入一个Person对象到Redis"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/redis"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
String
>
saveToCache
()
{
PicaResponse
.
Builder
<
String
>
builder
=
new
PicaResponse
.
Builder
<>();
redisClient
.
set
(
"keyname"
,
personMapper
.
selectByPrimaryKey
(
1008
));
return
builder
.
setData
(
redisClient
.
get
(
"keyname"
)).
build
();
}
@ApiOperation
(
value
=
"读取配置测试"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/config"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
PicaResponse
<
String
>
readFromConfiguration
()
{
PicaResponse
.
Builder
<
String
>
builder
=
new
PicaResponse
.
Builder
<>();
builder
.
setData
(
properties
.
toString
());
return
builder
.
build
();
}
@ApiOperation
(
value
=
"Feign调用微服务"
,
response
=
PicaResponse
.
class
)
@RequestMapping
(
value
=
"/beans"
,
method
=
RequestMethod
.
GET
,
produces
=
"application/json;charset=UTF-8"
)
public
String
beans
()
{
return
client
.
beans
();
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录