记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
4440ad17
Commit
4440ad17
authored
May 08, 2021
by
洪全海
Browse files
Options
Browse Files
Download
Plain Diff
合并代码
parents
ad094a81
75b8d4f3
Changes
59
Show whitespace changes
Inline
Side-by-side
Showing
59 changed files
with
1184 additions
and
806 deletions
+1184
-806
pom.xml
liquidnet-bus-common/liquidnet-common-base/pom.xml
+4
-0
BsonUtil.java
...c/main/java/com/liquidnet/commons/lang/util/BsonUtil.java
+29
-0
SqlMapping.java
...main/java/com/liquidnet/commons/lang/util/SqlMapping.java
+79
-0
SqlMessage.java
...main/java/com/liquidnet/commons/lang/util/SqlMessage.java
+46
-0
pom.xml
liquidnet-bus-common/liquidnet-common-mq/pom.xml
+8
-0
MQProperties.java
...ain/java/com/liquidnet/common/mq/config/MQProperties.java
+3
-3
RabbitMQConfigration.java
.../com/liquidnet/common/mq/config/RabbitMQConfigration.java
+149
-138
MQConst.java
...c/main/java/com/liquidnet/common/mq/constant/MQConst.java
+11
-0
application-common-service.yml
...us-config/liquidnet-config/application-common-service.yml
+1
-1
application-dev.yml
liquidnet-bus-config/liquidnet-config/application-dev.yml
+3
-1
application-prod.yml
liquidnet-bus-config/liquidnet-config/application-prod.yml
+1
-1
liquidnet-service-adam-dev.yml
...us-config/liquidnet-config/liquidnet-service-adam-dev.yml
+2
-1
liquidnet-service-adam.yml
...et-bus-config/liquidnet-config/liquidnet-service-adam.yml
+3
-2
liquidnet-service-consumer-dev.yml
...onfig/liquidnet-config/liquidnet-service-consumer-dev.yml
+22
-0
liquidnet-service-consumer.yml
...us-config/liquidnet-config/liquidnet-service-consumer.yml
+86
-0
liquidnet-service-kylin-dev.yml
...s-config/liquidnet-config/liquidnet-service-kylin-dev.yml
+4
-2
liquidnet-service-kylin.yml
...t-bus-config/liquidnet-config/liquidnet-service-kylin.yml
+4
-2
liquidnet-support-zuul-dev.yml
...us-config/liquidnet-config/liquidnet-support-zuul-dev.yml
+8
-0
liquidnet-support-zuul-prod.yml
...s-config/liquidnet-config/liquidnet-support-zuul-prod.yml
+8
-0
liquidnet-support-zuul-test.yml
...s-config/liquidnet-config/liquidnet-support-zuul-test.yml
+9
-0
liquidnet-support-zuul.yml
...et-bus-config/liquidnet-config/liquidnet-support-zuul.yml
+79
-52
AdamEntersVo.java
.../java/com/liquidnet/service/adam/dto/vo/AdamEntersVo.java
+8
-5
IAdamEntersService.java
...om/liquidnet/service/adam/service/IAdamEntersService.java
+2
-0
pom.xml
...iquidnet-service-adam/liquidnet-service-adam-impl/pom.xml
+7
-2
AdamSwagger2Config.java
...com/liquidnet/service/adam/config/AdamSwagger2Config.java
+0
-156
AdamSwaggerApiTags.java
...idnet/service/adam/config/swagger/AdamSwaggerApiTags.java
+0
-1
AdamSwaggerApiVersionConstant.java
...ce/adam/config/swagger/AdamSwaggerApiVersionConstant.java
+0
-14
AdamEntersController.java
...quidnet/service/adam/controller/AdamEntersController.java
+13
-18
AdamEntersServiceImpl.java
...dnet/service/adam/service/impl/AdamEntersServiceImpl.java
+130
-22
enters.properties
...ice-adam-impl/src/main/resources/sqlmap/enters.properties
+4
-0
pom.xml
liquidnet-bus-service/liquidnet-service-consumer/pom.xml
+28
-0
ServiceConsumerApplication.java
...ava/com/liquidnet/service/ServiceConsumerApplication.java
+8
-0
IBaseDao.java
...java/com/liquidnet/service/consumer/service/IBaseDao.java
+32
-0
BaseDao.java
.../com/liquidnet/service/consumer/service/impl/BaseDao.java
+114
-0
ConsumerProcessor.java
...service/consumer/service/processor/ConsumerProcessor.java
+32
-10
bootstrap-dev.yml
...net-service-consumer/src/main/resources/bootstrap-dev.yml
+14
-0
bootstrap-prod.yml
...et-service-consumer/src/main/resources/bootstrap-prod.yml
+14
-0
bootstrap-service-consumer.yml
...onsumer/src/main/resources/bootstrap-service-consumer.yml
+17
-0
bootstrap-test.yml
...et-service-consumer/src/main/resources/bootstrap-test.yml
+14
-0
bootstrap.yml
...quidnet-service-consumer/src/main/resources/bootstrap.yml
+5
-0
pom.xml
liquidnet-bus-support/liquidnet-support-zuul/pom.xml
+9
-0
SupportZuulApplication.java
...va/com/liquidnet/support/zuul/SupportZuulApplication.java
+34
-3
ZuulDocumentationConfig.java
.../support/zuul/config/swagger/ZuulDocumentationConfig.java
+45
-0
ZuulSwagger2Config.java
...idnet/support/zuul/config/swagger/ZuulSwagger2Config.java
+26
-0
ErrorExtFilter.java
...m/liquidnet/support/zuul/filter/error/ErrorExtFilter.java
+0
-38
ErrorFilter.java
.../com/liquidnet/support/zuul/filter/error/ErrorFilter.java
+0
-45
ThrowExceptionPostFilter.java
...et/support/zuul/filter/post/ThrowExceptionPostFilter.java
+0
-39
ThrowExceptionFilter.java
...quidnet/support/zuul/filter/pre/ThrowExceptionFilter.java
+0
-48
application-test.yml
...dnet-support-zuul/src/main/resources/application-test.yml
+0
-8
application-zuul.yml
...dnet-support-zuul/src/main/resources/application-zuul.yml
+0
-67
application.yml
...liquidnet-support-zuul/src/main/resources/application.yml
+0
-3
banner.txt
...port/liquidnet-support-zuul/src/main/resources/banner.txt
+0
-14
bootstrap-dev.yml
...quidnet-support-zuul/src/main/resources/bootstrap-dev.yml
+14
-0
bootstrap-prod.yml
...uidnet-support-zuul/src/main/resources/bootstrap-prod.yml
+14
-18
bootstrap-support-zuul.yml
...upport-zuul/src/main/resources/bootstrap-support-zuul.yml
+17
-0
bootstrap-test.yml
...uidnet-support-zuul/src/main/resources/bootstrap-test.yml
+14
-18
bootstrap.yml
...t/liquidnet-support-zuul/src/main/resources/bootstrap.yml
+5
-14
logback.xml
...ort/liquidnet-support-zuul/src/main/resources/logback.xml
+0
-60
pom.xml
liquidnet-bus-support/pom.xml
+5
-0
No files found.
liquidnet-bus-common/liquidnet-common-base/pom.xml
View file @
4440ad17
...
...
@@ -35,6 +35,10 @@
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
</dependency>
<dependency>
<groupId>
org.mongodb
</groupId>
<artifactId>
bson
</artifactId>
</dependency>
</dependencies>
...
...
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/BsonUtil.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
commons
.
lang
.
util
;
import
org.bson.Document
;
import
org.bson.json.Converter
;
import
org.bson.json.JsonWriterSettings
;
import
org.bson.json.StrictJsonWriter
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.TimeZone
;
public
class
BsonUtil
{
private
static
final
JsonWriterSettings
build
=
JsonWriterSettings
.
builder
().
dateTimeConverter
(
new
Converter
<
Long
>()
{
@Override
public
void
convert
(
Long
aLong
,
StrictJsonWriter
strictJsonWriter
)
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
);
dateFormat
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
if
(
aLong
>=
-
59014396800000L
&&
aLong
<=
253399536000000L
)
{
strictJsonWriter
.
writeRaw
(
String
.
format
(
"\"%s\""
,
dateFormat
.
format
(
new
Date
(
aLong
))));
}
else
{
strictJsonWriter
.
writeRaw
(
String
.
format
(
"new Date(%d)"
,
aLong
));
}
}
}).
build
();
public
static
<
T
>
T
toBean
(
Document
document
,
Class
<
T
>
clzss
){
return
JsonUtils
.
fromJson
(
document
.
toJson
(
build
),
clzss
);
}
}
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/SqlMapping.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
commons
.
lang
.
util
;
import
org.apache.logging.log4j.util.PropertiesUtil
;
import
org.springframework.core.io.support.PropertiesLoaderUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
java.util.Properties
;
public
class
SqlMapping
{
private
static
final
String
sqlMapDir
=
"sqlmap"
;
private
static
Map
<
String
,
Object
>
sqlPropertiesMap
=
new
HashMap
<>();
static
{
try
{
URL
url
=
PropertiesUtil
.
class
.
getClassLoader
().
getResource
(
sqlMapDir
);
if
(
null
!=
url
)
{
File
file
=
new
File
(
url
.
getFile
());
if
(
file
.
exists
()
&&
file
.
isDirectory
())
{
File
[]
files
=
file
.
listFiles
();
for
(
File
f
:
files
)
{
if
(
f
.
isFile
()
&&
f
.
getName
().
endsWith
(
"properties"
))
{
Properties
props
=
PropertiesLoaderUtils
.
loadAllProperties
(
sqlMapDir
.
concat
(
"/"
)
+
f
.
getName
());
for
(
Object
key
:
props
.
keySet
())
{
String
keyStr
=
key
.
toString
();
String
value
=
props
.
getProperty
(
keyStr
);
sqlPropertiesMap
.
put
(
keyStr
,
value
);
}
}
}
}
}
System
.
out
.
printf
(
"sqlPropertiesMap init count: %s\n"
,
sqlPropertiesMap
.
size
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
public
static
Object
get
(
String
sql
)
{
return
sqlPropertiesMap
.
get
(
sql
);
}
public
static
String
get
(
String
sql
,
Object
...
params
)
{
LinkedList
<
String
>
sqls
=
new
LinkedList
<>();
sqls
.
add
(
sqlPropertiesMap
.
get
(
sql
).
toString
());
LinkedList
<
Object
[]>
paramsList
=
new
LinkedList
<>();
paramsList
.
add
(
params
);
LinkedList
<
Object
[]>[]
args
=
new
LinkedList
[]{
paramsList
};
SqlMessage
sqlMessage
=
SqlMessage
.
getInstance
();
sqlMessage
.
setSqls
(
sqls
);
sqlMessage
.
setArgs
(
args
);
return
JsonUtils
.
toJson
(
sqlMessage
);
}
public
static
String
get
(
String
sql
,
LinkedList
<
Object
[]>
paramsList
)
{
LinkedList
<
String
>
sqls
=
new
LinkedList
<>();
sqls
.
add
(
sqlPropertiesMap
.
get
(
sql
).
toString
());
LinkedList
<
Object
[]>[]
args
=
new
LinkedList
[]{
paramsList
};
SqlMessage
sqlMessage
=
SqlMessage
.
getInstance
();
sqlMessage
.
setSqls
(
sqls
);
sqlMessage
.
setArgs
(
args
);
return
JsonUtils
.
toJson
(
sqlMessage
);
}
public
static
String
get
(
LinkedList
<
String
>
sqls
,
LinkedList
<
Object
[]>
paramsList
)
{
LinkedList
<
Object
[]>[]
args
=
new
LinkedList
[]{
paramsList
};
SqlMessage
sqlMessage
=
SqlMessage
.
getInstance
();
sqlMessage
.
setSqls
(
sqls
);
sqlMessage
.
setArgs
(
args
);
return
JsonUtils
.
toJson
(
sqlMessage
);
}
}
liquidnet-bus-common/liquidnet-common-base/src/main/java/com/liquidnet/commons/lang/util/SqlMessage.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
commons
.
lang
.
util
;
import
java.io.Serializable
;
import
java.util.LinkedList
;
public
class
SqlMessage
implements
Cloneable
,
Serializable
{
private
static
final
long
serialVersionUID
=
2208924091512163151L
;
private
LinkedList
<
String
>
sqls
;
private
LinkedList
<
Object
[]>[]
args
;
public
SqlMessage
()
{
}
public
SqlMessage
(
String
json
)
{
SqlMessage
sqlMessage
=
JsonUtils
.
fromJson
(
json
,
SqlMessage
.
class
);
this
.
sqls
=
sqlMessage
.
getSqls
();
this
.
args
=
sqlMessage
.
getArgs
();
}
public
LinkedList
<
String
>
getSqls
()
{
return
sqls
;
}
public
void
setSqls
(
LinkedList
<
String
>
sqls
)
{
this
.
sqls
=
sqls
;
}
public
LinkedList
<
Object
[]>[]
getArgs
()
{
return
args
;
}
public
void
setArgs
(
LinkedList
<
Object
[]>[]
args
)
{
this
.
args
=
args
;
}
private
final
static
SqlMessage
instance
=
new
SqlMessage
();
public
static
SqlMessage
getInstance
()
{
try
{
return
(
SqlMessage
)
instance
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
e
.
printStackTrace
();
}
return
new
SqlMessage
();
}
}
\ No newline at end of file
liquidnet-bus-common/liquidnet-common-mq/pom.xml
View file @
4440ad17
...
...
@@ -18,5 +18,13 @@
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
</dependency>
</dependencies>
</project>
liquidnet-bus-common/liquidnet-common-mq/src/main/java/com/liquidnet/common/mq/config/MQProperties.java
View file @
4440ad17
...
...
@@ -11,9 +11,9 @@ import org.springframework.stereotype.Component;
* @packname com.liquidnet.service.config.mq
*/
@Data
@ConfigurationProperties
(
prefix
=
MQProperties
.
MQCONFIG_PREFIX
)
@Component
//
@Data
//
@ConfigurationProperties(prefix = MQProperties.MQCONFIG_PREFIX)
//
@Component
public
class
MQProperties
{
public
static
final
String
MQCONFIG_PREFIX
=
"mq.config"
;
...
...
liquidnet-bus-common/liquidnet-common-mq/src/main/java/com/liquidnet/common/mq/config/RabbitMQConfigration.java
View file @
4440ad17
package
com
.
liquidnet
.
common
.
mq
.
config
;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.PropertyAccessor
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.core.*
;
...
...
@@ -28,147 +33,153 @@ import org.springframework.stereotype.Component;
public
class
RabbitMQConfigration
{
Logger
logger
=
LoggerFactory
.
getLogger
(
RabbitMQConfigration
.
class
);
@Autowired
private
MQProperties
mqProperties
;
@Autowired
private
ConnectionFactory
rabbitConnectionFactory
;
@Bean
(
"rabbitAdmin"
)
@ConditionalOnSingleCandidate
(
ConnectionFactory
.
class
)
public
RabbitAdmin
rabbitAdmin
()
{
return
new
RabbitAdmin
(
rabbitConnectionFactory
);
}
//
@Autowired
//
private MQProperties mqProperties;
//
//
@Autowired
//
private ConnectionFactory rabbitConnectionFactory;
//
//
@Bean("rabbitAdmin")
//
@ConditionalOnSingleCandidate(ConnectionFactory.class)
//
public RabbitAdmin rabbitAdmin() {
//
return new RabbitAdmin(rabbitConnectionFactory);
//
}
@Bean
(
"rabbitTemplate"
)
@Scope
(
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
//必须是prototype类型
public
RabbitTemplate
rabbitTemplate
()
{
public
RabbitTemplate
rabbitTemplate
(
ConnectionFactory
connectionFactory
)
{
logger
.
info
(
"########################初始化rabitTemplate################################"
);
RabbitTemplate
r
=
new
RabbitTemplate
(
rabbitConnectionFactory
);
r
.
setExchange
(
mqProperties
.
getDefaultTopicExchange
());
// r.setMessageConverter(new Jackson2JsonMessageConverter());
RabbitTemplate
r
=
new
RabbitTemplate
(
connectionFactory
);
// r.setExchange(mqProperties.getDefaultTopicExchange());
ObjectMapper
om
=
new
ObjectMapper
();
om
.
setVisibility
(
PropertyAccessor
.
ALL
,
JsonAutoDetect
.
Visibility
.
ANY
);
om
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
om
.
registerModule
(
new
JavaTimeModule
());
om
.
activateDefaultTyping
(
om
.
getPolymorphicTypeValidator
(),
ObjectMapper
.
DefaultTyping
.
NON_FINAL
);
Jackson2JsonMessageConverter
jackson2JsonMessageConverter
=
new
Jackson2JsonMessageConverter
(
om
);
r
.
setMessageConverter
(
jackson2JsonMessageConverter
);
return
r
;
}
@Bean
(
"rabbitListenerContainerFactory"
)
public
SimpleRabbitListenerContainerFactory
rabbitListenerContainerFactory
()
{
logger
.
info
(
"########################初始化rabbitListenerContainerFactory################################"
);
SimpleRabbitListenerContainerFactory
factory
=
new
SimpleRabbitListenerContainerFactory
();
factory
.
setConnectionFactory
(
rabbitConnectionFactory
);
factory
.
setMessageConverter
(
new
Jackson2JsonMessageConverter
());
return
factory
;
}
/**
* 针对消费者配置
* FanoutExchange: 将消息分发到所有的绑定队列,无routingkey的概念
* HeadersExchange :通过添加属性key-value匹配
* DirectExchange:按照routingkey分发到指定队列
* TopicExchange:多关键字匹配
*/
@ConditionalOnProperty
(
name
=
"mq.config.default-direct-exchange"
)
public
DirectExchange
defaultDirectExchange
()
{
logger
.
info
(
"初始化defaultDirectExchange:{}"
,
mqProperties
.
getDefaultDirectExchange
());
return
new
DirectExchange
(
mqProperties
.
getDefaultDirectExchange
(),
true
,
false
);
}
@ConditionalOnProperty
(
name
=
"mq.config.default-topic-exchange"
)
public
TopicExchange
defaltTopicExchange
()
{
logger
.
info
(
"初始化defaultTopicExchange:{}"
,
mqProperties
.
getDefaultTopicExchange
());
return
new
TopicExchange
(
mqProperties
.
getDefaultTopicExchange
(),
true
,
false
);
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.data-send-queue"
)
public
Queue
dataSendQueue
(){
logger
.
info
(
"创建打点数据监听队列:{}"
,
mqProperties
.
getDataSendQueue
());
return
new
Queue
(
mqProperties
.
getDataSendQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"dataSendQueue"
)
public
Binding
bindDataSend
(){
logger
.
info
(
"绑定打点数据队列,exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getDataSendRoutingKey
(),
mqProperties
.
getDataSendQueue
());
return
BindingBuilder
.
bind
(
dataSendQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getDataSendRoutingKey
());
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.overdue-signinfo-queue"
)
public
Queue
overdueSigninfoQueue
(){
logger
.
info
(
"创建签约信息监听队列:{}"
,
mqProperties
.
getOverdueSigninfoQueue
());
return
new
Queue
(
mqProperties
.
getOverdueSigninfoQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"overdueSigninfoQueue"
)
public
Binding
bindOverdueSigninfo
(){
logger
.
info
(
"绑定签约信息队列,exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getOverdueSigninfoRoutingKey
(),
mqProperties
.
getOverdueSigninfoQueue
());
return
BindingBuilder
.
bind
(
overdueSigninfoQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getOverdueSigninfoRoutingKey
());
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.overdue-repayment-queue"
)
public
Queue
overdueRepaymentQueue
(){
logger
.
info
(
"创建还款推送监听队列:{}"
,
mqProperties
.
getOverdueRepaymentQueue
());
return
new
Queue
(
mqProperties
.
getOverdueRepaymentQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"overdueRepaymentQueue"
)
public
Binding
bindOverdueRepayment
(){
logger
.
info
(
"绑定还款推送监听队列,exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getOverdueRepaymentRoutingKey
(),
mqProperties
.
getOverdueRepaymentQueue
());
return
BindingBuilder
.
bind
(
overdueRepaymentQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getOverdueRepaymentRoutingKey
());
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.overdue-penaltymoney-queue"
)
public
Queue
overduePenaltymoneyQueue
(){
logger
.
info
(
"创建逾期违约金额推送监听队列:{}"
,
mqProperties
.
getOverduePenaltymoneyQueue
());
return
new
Queue
(
mqProperties
.
getOverduePenaltymoneyQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"overduePenaltymoneyQueue"
)
public
Binding
bindOverduePenaltymoney
(){
logger
.
info
(
"绑定逾期违约金额推送监听队列,exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getOverduePenaltymoneyRoutingKey
(),
mqProperties
.
getOverduePenaltymoneyQueue
());
return
BindingBuilder
.
bind
(
overduePenaltymoneyQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getOverduePenaltymoneyRoutingKey
());
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.loan-repaymentplan-queue"
)
public
Queue
loanRepaymentplanQueue
(){
logger
.
info
(
"创建三方数据推送监听队列:{}"
,
mqProperties
.
getLoanRepaymentplanQueue
());
return
new
Queue
(
mqProperties
.
getLoanRepaymentplanQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"loanRepaymentplanQueue"
)
public
Binding
bindLoanRepaymentplanQueue
(){
logger
.
info
(
"三方数据推送监听队列, exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getLoanRepaymentplanRoutingKey
(),
mqProperties
.
getLoanRepaymentplanQueue
());
return
BindingBuilder
.
bind
(
loanRepaymentplanQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getLoanRepaymentplanRoutingKey
());
}
@Bean
@ConditionalOnProperty
(
name
=
"mq.config.loan-pushdata-queue"
)
public
Queue
loanPushDataQueue
(){
logger
.
info
(
"创建接收冲账成功数据推送监听队列:{}"
,
mqProperties
.
getLoanPushdataQueue
());
return
new
Queue
(
mqProperties
.
getLoanPushdataQueue
());
}
@Bean
@ConditionalOnBean
(
name
=
"loanPushDataQueue"
)
public
Binding
bindLoanPushDataQueue
(){
logger
.
info
(
"三方数据推送监听队列, exchange:{},routingKey:{},queueName:{}"
,
mqProperties
.
getDefaultTopicExchange
(),
mqProperties
.
getLoanPushdataRoutingKey
(),
mqProperties
.
getLoanPushdataQueue
());
return
BindingBuilder
.
bind
(
loanPushDataQueue
()).
to
(
defaltTopicExchange
()).
with
(
mqProperties
.
getLoanPushdataRoutingKey
());
}
//
@Bean("rabbitListenerContainerFactory")
//
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
//
logger.info("########################初始化rabbitListenerContainerFactory################################");
//
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//
factory.setConnectionFactory(rabbitConnectionFactory);
//
factory.setMessageConverter(new Jackson2JsonMessageConverter());
//
return factory;
//
}
//
//
/**
//
* 针对消费者配置
//
* FanoutExchange: 将消息分发到所有的绑定队列,无routingkey的概念
//
* HeadersExchange :通过添加属性key-value匹配
//
* DirectExchange:按照routingkey分发到指定队列
//
* TopicExchange:多关键字匹配
//
*/
//
@ConditionalOnProperty(name = "mq.config.default-direct-exchange")
//
public DirectExchange defaultDirectExchange() {
//
logger.info("初始化defaultDirectExchange:{}", mqProperties.getDefaultDirectExchange());
//
return new DirectExchange(mqProperties.getDefaultDirectExchange(), true, false);
//
}
//
//
@ConditionalOnProperty(name = "mq.config.default-topic-exchange")
//
public TopicExchange defaltTopicExchange() {
//
logger.info("初始化defaultTopicExchange:{}", mqProperties.getDefaultTopicExchange());
//
return new TopicExchange(mqProperties.getDefaultTopicExchange(), true, false);
//
}
//
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.data-send-queue")
//
public Queue dataSendQueue(){
//
logger.info("创建打点数据监听队列:{}",mqProperties.getDataSendQueue());
//
return new Queue(mqProperties.getDataSendQueue());
//
}
//
//
@Bean
//
@ConditionalOnBean(name = "dataSendQueue")
//
public Binding bindDataSend(){
//
logger.info("绑定打点数据队列,exchange:{},routingKey:{},queueName:{}", mqProperties.getDefaultTopicExchange(), mqProperties.getDataSendRoutingKey(), mqProperties.getDataSendQueue());
//
return BindingBuilder.bind(dataSendQueue()).to(defaltTopicExchange()).with(mqProperties.getDataSendRoutingKey());
//
}
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.overdue-signinfo-queue")
//
public Queue overdueSigninfoQueue(){
//
logger.info("创建签约信息监听队列:{}",mqProperties.getOverdueSigninfoQueue());
//
return new Queue(mqProperties.getOverdueSigninfoQueue());
//
}
//
//
@Bean
//
@ConditionalOnBean(name = "overdueSigninfoQueue")
//
public Binding bindOverdueSigninfo(){
//
logger.info("绑定签约信息队列,exchange:{},routingKey:{},queueName:{}", mqProperties.getDefaultTopicExchange(), mqProperties.getOverdueSigninfoRoutingKey(), mqProperties.getOverdueSigninfoQueue());
//
return BindingBuilder.bind(overdueSigninfoQueue()).to(defaltTopicExchange()).with(mqProperties.getOverdueSigninfoRoutingKey());
//
}
//
//
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.overdue-repayment-queue")
//
public Queue overdueRepaymentQueue(){
//
logger.info("创建还款推送监听队列:{}",mqProperties.getOverdueRepaymentQueue());
//
return new Queue(mqProperties.getOverdueRepaymentQueue());
//
}
//
//
@Bean
//
@ConditionalOnBean(name = "overdueRepaymentQueue")
//
public Binding bindOverdueRepayment(){
//
logger.info("绑定还款推送监听队列,exchange:{},routingKey:{},queueName:{}", mqProperties.getDefaultTopicExchange(), mqProperties.getOverdueRepaymentRoutingKey(), mqProperties.getOverdueRepaymentQueue());
//
return BindingBuilder.bind(overdueRepaymentQueue()).to(defaltTopicExchange()).with(mqProperties.getOverdueRepaymentRoutingKey());
//
}
//
//
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.overdue-penaltymoney-queue")
//
public Queue overduePenaltymoneyQueue(){
//
logger.info("创建逾期违约金额推送监听队列:{}",mqProperties.getOverduePenaltymoneyQueue());
//
return new Queue(mqProperties.getOverduePenaltymoneyQueue());
//
}
//
//
@Bean
//
@ConditionalOnBean(name = "overduePenaltymoneyQueue")
//
public Binding bindOverduePenaltymoney(){
//
logger.info("绑定逾期违约金额推送监听队列,exchange:{},routingKey:{},queueName:{}", mqProperties.getDefaultTopicExchange(), mqProperties.getOverduePenaltymoneyRoutingKey(), mqProperties.getOverduePenaltymoneyQueue());
//
return BindingBuilder.bind(overduePenaltymoneyQueue()).to(defaltTopicExchange()).with(mqProperties.getOverduePenaltymoneyRoutingKey());
//
}
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.loan-repaymentplan-queue")
//
public Queue loanRepaymentplanQueue(){
//
logger.info("创建三方数据推送监听队列:{}",mqProperties.getLoanRepaymentplanQueue());
//
return new Queue(mqProperties.getLoanRepaymentplanQueue());
//
}
//
//
//
@Bean
//
@ConditionalOnBean(name = "loanRepaymentplanQueue")
//
public Binding bindLoanRepaymentplanQueue(){
//
logger.info("三方数据推送监听队列, exchange:{},routingKey:{},queueName:{}",mqProperties.getDefaultTopicExchange(),mqProperties.getLoanRepaymentplanRoutingKey(),mqProperties.getLoanRepaymentplanQueue());
//
return BindingBuilder.bind(loanRepaymentplanQueue()).to(defaltTopicExchange()).with(mqProperties.getLoanRepaymentplanRoutingKey());
//
}
//
//
//
@Bean
//
@ConditionalOnProperty(name = "mq.config.loan-pushdata-queue")
//
public Queue loanPushDataQueue(){
//
logger.info("创建接收冲账成功数据推送监听队列:{}",mqProperties.getLoanPushdataQueue());
//
return new Queue(mqProperties.getLoanPushdataQueue());
//
}
//
//
//
@Bean
//
@ConditionalOnBean(name = "loanPushDataQueue")
//
public Binding bindLoanPushDataQueue(){
//
logger.info("三方数据推送监听队列, exchange:{},routingKey:{},queueName:{}",mqProperties.getDefaultTopicExchange(),mqProperties.getLoanPushdataRoutingKey(),mqProperties.getLoanPushdataQueue());
//
return BindingBuilder.bind(loanPushDataQueue()).to(defaltTopicExchange()).with(mqProperties.getLoanPushdataRoutingKey());
//
}
}
liquidnet-bus-common/liquidnet-common-mq/src/main/java/com/liquidnet/common/mq/constant/MQConst.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
common
.
mq
.
constant
;
public
class
MQConst
{
public
static
final
String
EXCHANGES_LIQUIDNET_SQL
=
"liquidnet.sql"
;
public
static
final
String
ROUTING_KEY_SQL
=
"sql"
;
public
static
final
String
QUEUES_SQL_MAIN
=
"queue.sql.main"
;
}
liquidnet-bus-config/liquidnet-config/application-common-service.yml
View file @
4440ad17
liquidnet-bus-config/liquidnet-config/application-dev.yml
View file @
4440ad17
...
...
@@ -21,8 +21,10 @@ liquidnet:
port
:
6380
password
:
PO@B!Iud32
mongodb
:
host
:
172.16.2.196
host
:
39.106.122.201
port
:
27017
user
:
root
pwd
:
S&y$6d*JwJ
# gfsdatabasename: liquidnet_mgdb
#以下为各应用需要用到的ip及端口设置
#涉及到ip的地方尽量都放入公共变量,方便统一修改
...
...
liquidnet-bus-config/liquidnet-config/application-prod.yml
View file @
4440ad17
...
...
@@ -15,7 +15,7 @@ liquidnet:
username
:
liquidnet
password
:
LiquidNet!@#4
knife4j
:
disable
:
fals
e
disable
:
tru
e
redis
:
host
:
192.168.31.205
port
:
6379
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-adam-dev.yml
View file @
4440ad17
...
...
@@ -79,9 +79,10 @@ spring:
transportMode
:
"
NIO"
data
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_adam_mdb
#
uri: mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_adam_mdb
#本地测试证书
sslEnabled
:
false
database
:
ln_adam_mdb
trustStore
:
trustStorePassword
:
# uri: mongodb://smartnet:a43ljKmK8oqdOO902P@smartnet-nonprod-docdb-docdb.cluster-cgjsqu7tuka2.ap-southeast-1.docdb.amazonaws.com:27017/liquidnet_mgdb?ssl=true&ssl_ca_certs=/Users/anjiabin/Downloads/rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false
liquidnet-bus-config/liquidnet-config/liquidnet-service-adam.yml
View file @
4440ad17
...
...
@@ -8,7 +8,7 @@ server:
knife4j
:
production
:
${liquidnet.knife4j.disable}
basic
:
enable
:
tru
e
enable
:
fals
e
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
...
...
@@ -70,8 +70,9 @@ spring:
password
:
${liquidnet.rabbitmq.password}
data
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.
host}:${liquidnet.mongodb.port}/${liquidnet.mongodb.gfsdatabasename}
uri
:
mongodb://${liquidnet.mongodb.
user}:${liquidnet.mongodb.pwd}@${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/?authSource=admin
sslEnabled
:
false
database
:
${spring.data.mongodb.database}
datasource
:
name
:
${liquidnet.mysql.database-name}
url
:
jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-consumer-dev.yml
0 → 100644
View file @
4440ad17
liquidnet
:
system
:
updating
:
switch
:
false
info
:
port
:
9999
context
:
# context: /service-consumer
name
:
liquidnet-service-consumer
logfile
:
path
:
./logs
name
:
service-consumer
config
:
classpath:logback-spring.xml
file-max-size
:
200MB
pattern-file
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
pattern-console
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
pattern-rolling-file-name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level-root
:
info
mysql
:
database-name
:
ln_adam
#以下为spring各环境个性配置
\ No newline at end of file
liquidnet-bus-config/liquidnet-config/liquidnet-service-consumer.yml
0 → 100644
View file @
4440ad17
server
:
port
:
${liquidnet.info.port}
tomcat
:
uri-encoding
:
UTF-8
servlet
:
context-path
:
${liquidnet.info.context}
# -----------------------------------------------------------
knife4j
:
production
:
${liquidnet.knife4j.disable}
basic
:
enable
:
true
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
logging
:
# config: ${liquidnet.logfile.config}
file
:
name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}.log
max-size
:
200MB
pattern
:
file
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
console
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
rolling-file-name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level
:
root
:
info
#以下是为指定包设置日志级别
com
:
liquidnet
:
info
# -----------------------------------------------------------
eureka
:
# client:
# register-with-eureka: true
# fetch-registry: true
# serviceUrl:
# defaultZone: http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
instance
:
hostname
:
${spring.cloud.client.ip-address}
lease-expiration-duration-in-seconds
:
15
#服务过期时间配置,超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除
lease-renewal-interval-in-seconds
:
5
#服务刷新时间配置,每隔这个时间会主动心跳一次
prefer-ip-address
:
true
instance-id
:
${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
# -----------------------------------------------------------
#actuator/info
info
:
app
:
name
:
${liquidnet.info.name}
company
:
name
:
lightnet.io
build
:
groupId
:
'
@project.groupId@'
artifactId
:
'
@project.artifactId@'
version
:
'
@project.version@'
# -----------------------------------------------------------
spring
:
application
:
name
:
${liquidnet.info.name}
profiles
:
include
:
common-service
#这里加载management相关公共配置
rabbitmq
:
addresses
:
${liquidnet.rabbitmq.host}
port
:
${liquidnet.rabbitmq.port}
username
:
${liquidnet.rabbitmq.username}
password
:
${liquidnet.rabbitmq.password}
datasource
:
name
:
${liquidnet.mysql.database-name}
url
:
jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
username
:
${liquidnet.mysql.username}
password
:
${liquidnet.mysql.password}
# type: org.apache.tomcat.jdbc.pool.DataSource
driver-class-name
:
com.mysql.cj.jdbc.Driver
filters
:
stat
maxActive
:
20
initialSize
:
1
maxWait
:
60000
minIdle
:
1
timeBetweenEvictionRunsMillis
:
60000
minEvictableIdleTimeMillis
:
300000
validationQuery
:
select 'x'
testWhileIdle
:
true
testOnBorrow
:
false
testOnReturn
:
false
poolPreparedStatements
:
true
maxOpenPreparedStatements
:
20
# -----------------------------------------------------------
# -----------------------------------------------------------
liquidnet-bus-config/liquidnet-config/liquidnet-service-kylin-dev.yml
View file @
4440ad17
...
...
@@ -3,7 +3,7 @@ liquidnet:
updating
:
switch
:
false
info
:
port
:
900
1
port
:
900
2
context
:
# context: /service-kylin
name
:
liquidnet-service-kylin
...
...
@@ -79,9 +79,11 @@ spring:
transportMode
:
"
NIO"
data
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_kylin_mdb
#
uri: mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_kylin_mdb
#本地测试证书
# uri: mongodb://${liquidnet.mongodb.user}:${liquidnet.mongodb.pwd}@${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/?authSource=admin
sslEnabled
:
false
database
:
ln_kylin_mdb
trustStore
:
trustStorePassword
:
# uri: mongodb://smartnet:a43ljKmK8oqdOO902P@smartnet-nonprod-docdb-docdb.cluster-cgjsqu7tuka2.ap-southeast-1.docdb.amazonaws.com:27017/liquidnet_mgdb?ssl=true&ssl_ca_certs=/Users/anjiabin/Downloads/rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false
liquidnet-bus-config/liquidnet-config/liquidnet-service-kylin.yml
View file @
4440ad17
...
...
@@ -8,7 +8,7 @@ server:
knife4j
:
production
:
${liquidnet.knife4j.disable}
basic
:
enable
:
tru
e
enable
:
fals
e
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
...
...
@@ -70,8 +70,10 @@ spring:
password
:
${liquidnet.rabbitmq.password}
data
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_kylin_mdb
uri
:
mongodb://${liquidnet.mongodb.user}:${liquidnet.mongodb.pwd}@${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/?authSource=admin
# uri: mongodb://root:S&y$6d*JwJ@39.106.122.201:27017/ln_kylin_mdb
sslEnabled
:
false
database
:
${spring.data.mongodb.database}
datasource
:
name
:
${liquidnet.mysql.database-name}
url
:
jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-dev.yml
0 → 100755
View file @
4440ad17
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-prod.yml
0 → 100755
View file @
4440ad17
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
\ No newline at end of file
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-test.yml
0 → 100755
View file @
4440ad17
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul.yml
View file @
4440ad17
spring
:
application
:
name
:
liquidnet-gateway-zuul
server
:
port
:
8040
server
:
port
:
${liquidnet.info.port}
tomcat
:
accept-count
:
500
max-threads
:
500
min-spare-threads
:
100
max-connections
:
1000
connection-timeout
:
5000
uri-encoding
:
UTF-8
servlet
:
context-path
:
# context-path: ${liquidnet.info.context}
# server:
# tomcat:
# accept-count: 500
# max-threads: 500
# min-spare-threads: 100
# max-connections: 1000
# connection-timeout: 5000
# -----------------------------------------------------------
knife4j
:
production
:
${liquidnet.knife4j.disable}
basic
:
enable
:
true
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
logging
:
file
:
name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}.log
max-size
:
200MB
pattern
:
file
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
console
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
rolling-file-name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level
:
root
:
info
#以下是为指定包设置日志级别
com.netflix
:
info
# -----------------------------------------------------------
spring
:
application
:
name
:
${liquidnet.info.name}
autoconfigure
:
exclude
:
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
profiles
:
include
:
common-service
# cloud:
# bus:
# destination: springCloudBus.${liquidnet.info.name}.port${liquidnet.info.port}
# trace:
# enabled: true
# -----------------------------------------------------------
eureka
:
client
:
healthcheck
:
enabled
:
true
serviceUrl
:
defaultZone
:
${liquidnet.eureka.serviceUrl}
#
client:
# register-with-eureka: true
# fetch-registry
: true
#
serviceUrl:
# defaultZone: http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
instance
:
hostname
:
${spring.cloud.client.ip-address}
lease-expiration-duration-in-seconds
:
15
#服务过期时间配置,超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除
lease-renewal-interval-in-seconds
:
5
#服务刷新时间配置,每隔这个时间会主动心跳一次
prefer-ip-address
:
true
instance-id
:
${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
lease-renewal-interval-in-seconds
:
15
lease-expiration-duration-in-seconds
:
30
metadata-map
:
zone
:
YGZX
# eureka可以理解的元数据
liquidnet
:
YGZX
# 不会影响客户端行为
server
:
eviction-interval-timer-in-ms
:
30000
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds
:
60000
ribbon
:
ConnectTimeout
:
3000
ReadTimeout
:
60000
eureka
:
enabled
:
true
instance-id
:
${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
# -----------------------------------------------------------
zuul
:
prefix
:
/
host
:
max-per-route-connections
:
1000
max-total-connections
:
2000
routes
:
liquidnet-provider-sms
:
/sms/**
liquidnet-provider-sequence
:
/sequence/**
liquidnet-provider-data
:
/data/**
liquidnet-provider-user
:
/user/**
liquidnet-provider-p2m
:
/p2m/**
liquidnet-provider-activity
:
/activity/**
pay-third-charge
:
/pay_charge/**
liquidnet-pay-query
:
/pay_query/**
liquidnet-client-app
:
/app_api/**
zuul.ThrowExceptionPostFilter.post.disable
:
true
logging
:
level
:
com.netflix
:
debug
liquidnet-service-adam
:
/adam/**
liquidnet-service-kylin
:
/kylin/**
# 忽略的服务,有些后端服务是不需要让网管代理的,防止服务侵入
ignored-services
:
"
*"
# 忽略的接口,屏蔽接口
# ignored-patterns: /**/div/**
# 以下为禁用某个过滤器
# XXXFilter: # 类的名字
# pre: # 类型
# disable: true
#zuul:
# prefix: /api
# strip-prefix: false
#解决错误 com.netflix.client.ClientException: Load balancer does not have available server for client:panfeng-item-service
#这样就可以即指定path与URL,又不破坏Zuul的Hystrix与Ribbon特性了。
#开启eureka负载均衡策略
ribbon
:
eureka
:
enabled
:
true
# 为Ribbon禁用Eureka
#liquidnet-service-sequence:
# ribbon:
# listOfServers: 192.168.137.1:9001
# -----------------------------------------------------------
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-api/src/main/java/com/liquidnet/service/adam/dto/vo/AdamEntersVo.java
View file @
4440ad17
...
...
@@ -9,15 +9,17 @@ import lombok.Data;
@Data
public
class
AdamEntersVo
implements
java
.
io
.
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
5258094625450569125L
;
@ApiModelProperty
(
position
=
10
,
value
=
"入场人名称[50]"
)
@ApiModelProperty
(
position
=
10
,
value
=
"入场人ID[64]"
)
private
String
entersId
;
@ApiModelProperty
(
position
=
11
,
value
=
"入场人名称[50]"
)
private
String
name
;
@ApiModelProperty
(
position
=
1
1
,
value
=
"入场人手机号[11]"
)
@ApiModelProperty
(
position
=
1
2
,
value
=
"入场人手机号[11]"
)
private
String
mobile
;
@ApiModelProperty
(
position
=
1
2
,
value
=
"证件类型:1-大陆身份证,2-港澳通行证,3-台胞证,4-护照,5-军官证"
)
@ApiModelProperty
(
position
=
1
3
,
value
=
"证件类型:1-大陆身份证,2-港澳通行证,3-台胞证,4-护照,5-军官证"
)
private
Integer
type
;
@ApiModelProperty
(
position
=
1
3
,
value
=
"入场人证件号[11]"
)
@ApiModelProperty
(
position
=
1
4
,
value
=
"入场人证件号[11]"
)
private
String
idCard
;
@ApiModelProperty
(
position
=
1
4
,
value
=
"是否是默认入场人:0-否,1-是"
)
@ApiModelProperty
(
position
=
1
5
,
value
=
"是否是默认入场人:0-否,1-是"
)
private
Boolean
isDefault
;
private
static
final
AdamEntersVo
obj
=
new
AdamEntersVo
();
...
...
@@ -32,6 +34,7 @@ public class AdamEntersVo implements java.io.Serializable, Cloneable {
}
public
AdamEntersVo
copy
(
AdamEnters
source
)
{
this
.
setEntersId
(
source
.
getEntersId
());
this
.
setName
(
source
.
getName
());
this
.
setIdCard
(
source
.
getIdCard
());
this
.
setMobile
(
source
.
getMobile
());
...
...
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-api/src/main/java/com/liquidnet/service/adam/service/IAdamEntersService.java
View file @
4440ad17
...
...
@@ -21,4 +21,6 @@ public interface IAdamEntersService extends IService<AdamEnters> {
AdamEnters
query
(
String
uid
,
String
entersId
);
void
edit
(
AdamEnters
info
);
void
remove
(
String
uid
,
String
entersId
);
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/pom.xml
View file @
4440ad17
...
...
@@ -26,8 +26,9 @@
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-mq
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
...
...
@@ -37,6 +38,10 @@
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-mongodb
</artifactId>
</dependency>
</dependencies>
<build>
...
...
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/config/AdamSwagger2Config.java
View file @
4440ad17
package
com
.
liquidnet
.
service
.
adam
.
config
;
import
com.liquidnet.common.swagger.config.Swagger2Config
;
import
com.liquidnet.common.swagger.config.SwaggerApiVersion
;
import
com.liquidnet.service.adam.config.swagger.AdamSwaggerApiVersionConstant
;
import
io.swagger.annotations.Api
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ParameterBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.schema.ModelRef
;
import
springfox.documentation.service.Parameter
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* @author AnJiabin <jiabin.an@lightnet.io>
...
...
@@ -30,145 +15,4 @@ import java.util.List;
@Configuration
class
AdamSwagger2Config
extends
Swagger2Config
{
@Override
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
.
forCodeGeneration
(
true
).
select
()
.
apis
(
RequestHandlerSelectors
.
withClassAnnotation
(
Api
.
class
))
.
paths
(
PathSelectors
.
any
())
.
build
();
// return new Docket(DocumentationType.SWAGGER_2)
// .apiInfo(this.apiInfo())
// .groupName(AdamSwaggerApiVersionConstant.WEB_1_1)
// .select()
// .apis(input -> {
// SwaggerApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(SwaggerApiVersion.class);
// return apiVersion != null && Arrays.asList(apiVersion.group()).contains(AdamSwaggerApiVersionConstant.WEB_1_1);
// })
// .paths(PathSelectors.any())
// .build();
}
@Bean
public
Docket
api_admin
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
.
groupName
(
AdamSwaggerApiVersionConstant
.
ADMIN
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
ADMIN
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
api_feign
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
.
groupName
(
AdamSwaggerApiVersionConstant
.
FEIGN
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
FEIGN
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
api_task
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
.
groupName
(
AdamSwaggerApiVersionConstant
.
TASK
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
TASK
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
web_sys
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
.
groupName
(
AdamSwaggerApiVersionConstant
.
WEB_SYS
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
WEB_SYS
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
web_1_0
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
// .globalOperationParameters(headParamDefault())
.
groupName
(
AdamSwaggerApiVersionConstant
.
WEB_1_0
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
WEB_1_0
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
web_1_1
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
// .globalOperationParameters(headParamDefault())
.
groupName
(
AdamSwaggerApiVersionConstant
.
WEB_1_1
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
WEB_1_1
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
@Bean
public
Docket
web_1_2
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
this
.
apiInfo
())
// .globalOperationParameters(headParamDefault())
.
groupName
(
AdamSwaggerApiVersionConstant
.
WEB_1_2
)
.
select
()
.
apis
(
input
->
{
SwaggerApiVersion
apiVersion
=
input
.
getHandlerMethod
().
getMethodAnnotation
(
SwaggerApiVersion
.
class
);
return
apiVersion
!=
null
&&
Arrays
.
asList
(
apiVersion
.
group
()).
contains
(
AdamSwaggerApiVersionConstant
.
WEB_1_2
);
})
.
paths
(
PathSelectors
.
any
())
.
build
();
}
/**
* 设置默认请求头部 参数
* sid
*/
private
List
<
Parameter
>
headParamDefault
()
{
List
<
Parameter
>
pars
=
new
ArrayList
<>();
// ParameterBuilder ticketPar = new ParameterBuilder();
// ticketPar.name("token").description("user token")
// .modelRef(new ModelRef("string")).parameterType("header")
// .required(true).build(); //header中的ticket参数非必填,传空也可以
// pars.add(ticketPar.build()); //根据每个方法名也知道当前方法在设置什么参数
return
pars
;
}
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/config/swagger/AdamSwaggerApiTags.java
View file @
4440ad17
...
...
@@ -7,6 +7,5 @@ import com.liquidnet.common.swagger.config.SwaggerApiTags;
* @author Li Chen
*/
public
interface
AdamSwaggerApiTags
extends
SwaggerApiTags
{
String
COM
=
"com"
;
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/config/swagger/AdamSwaggerApiVersionConstant.java
View file @
4440ad17
...
...
@@ -9,18 +9,4 @@ import com.liquidnet.common.swagger.config.SwaggerApiVersionConstant;
*/
public
interface
AdamSwaggerApiVersionConstant
extends
SwaggerApiVersionConstant
{
String
ADMIN
=
"admin"
;
String
FEIGN
=
"fegin"
;
String
TASK
=
"task"
;
String
WEB_SYS
=
"web sys"
;
String
WEB_1_0
=
"web 1.0"
;
String
WEB_1_1
=
"web 1.1"
;
String
WEB_1_2
=
"web 1.2"
;
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamEntersController.java
View file @
4440ad17
...
...
@@ -10,8 +10,6 @@ import com.liquidnet.service.adam.service.IAdamEntersService;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.AmqpException
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -35,20 +33,6 @@ import java.util.List;
public
class
AdamEntersController
{
@Autowired
IAdamEntersService
adamEntersService
;
@Autowired
AmqpTemplate
amqpTemplate
;
@ApiOperationSupport
(
order
=
0
)
@ApiOperation
(
value
=
"Producer"
)
@PostMapping
(
"producer"
)
public
ResponseDto
<
Object
>
producer
()
{
try
{
amqpTemplate
.
convertAndSend
(
"queue_test"
,
"queue_key"
,
"select * from x "
+
System
.
currentTimeMillis
());
}
catch
(
AmqpException
e
)
{
e
.
printStackTrace
();
}
return
ResponseDto
.
success
();
}
@ApiOperationSupport
(
order
=
1
)
@ApiOperation
(
value
=
"入场人列表"
)
...
...
@@ -58,7 +42,6 @@ public class AdamEntersController {
String
uid
=
"1"
;
List
<
AdamEntersVo
>
voList
=
new
ArrayList
<>();
adamEntersService
.
list
(
uid
).
forEach
(
i
->
{
voList
.
add
(
AdamEntersVo
.
getNew
().
copy
(
i
));
...
...
@@ -116,4 +99,16 @@ public class AdamEntersController {
return
ResponseDto
.
success
();
}
@ApiOperationSupport
(
order
=
5
)
@ApiOperation
(
value
=
"入场人删除"
)
@PostMapping
(
"del/{id}"
)
public
ResponseDto
<
Object
>
del
(
@PathVariable
(
name
=
"id"
)
String
entersId
)
{
// TODO: 2021/4/28 校验、获取登录UID
String
uid
=
"1"
;
adamEntersService
.
remove
(
uid
,
entersId
);
return
ResponseDto
.
success
();
}
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/service/impl/AdamEntersServiceImpl.java
View file @
4440ad17
package
com
.
liquidnet
.
service
.
adam
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.common.mq.constant.MQConst
;
import
com.liquidnet.commons.lang.util.BsonUtil
;
import
com.liquidnet.commons.lang.util.SqlMapping
;
import
com.liquidnet.service.adam.constant.AdamRedisConst
;
import
com.liquidnet.service.adam.dto.vo.AdamEntersVo
;
import
com.liquidnet.service.adam.entity.AdamEnters
;
import
com.liquidnet.service.adam.mapper.AdamEntersMapper
;
import
com.liquidnet.service.adam.service.IAdamEntersService
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.client.model.FindOneAndUpdateOptions
;
import
com.mongodb.client.model.ReturnDocument
;
import
com.mongodb.client.result.UpdateResult
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.convert.MongoConverter
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.time.LocalDateTime
;
import
java.util.*
;
/**
* <p>
...
...
@@ -37,18 +44,22 @@ public class AdamEntersServiceImpl extends ServiceImpl<AdamEntersMapper, AdamEnt
@Autowired
AdamEntersMapper
adamEntersMapper
;
@Autowired
MongoConverter
mongoConverter
;
@Autowired
MongoTemplate
mongoTemplate
;
@Autowired
RabbitTemplate
rabbitTemplate
;
@Autowired
RedisUtil
redisUtil
;
@Override
public
List
<
AdamEnters
>
list
(
String
uid
)
{
List
<
AdamEnters
>
infoList
=
n
ull
;
List
<
AdamEnters
>
infoList
=
n
ew
ArrayList
<>()
;
Map
<
Object
,
Object
>
map
=
redisUtil
.
hmget
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
uid
));
if
(
CollectionUtils
.
isEmpty
(
map
))
{
infoList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"uid"
).
is
(
uid
)),
AdamEnters
.
class
,
AdamEnters
.
class
.
getSimpleName
());
infoList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"uid"
).
is
(
uid
)
.
and
(
"state"
).
is
(
1
)
),
AdamEnters
.
class
,
AdamEnters
.
class
.
getSimpleName
());
}
else
{
for
(
Object
o
:
map
.
values
())
{
infoList
.
add
((
AdamEnters
)
o
);
...
...
@@ -59,22 +70,59 @@ public class AdamEntersServiceImpl extends ServiceImpl<AdamEntersMapper, AdamEnt
}
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
add
(
AdamEnters
info
)
{
mongoTemplate
.
insert
(
Collections
.
singletonList
(
info
),
AdamEnters
.
class
.
getSimpleName
());
if
(
info
.
getIsDefault
())
{
Set
<
Object
>
keys
=
(
Set
<
Object
>)
redisUtil
.
hkeys
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
info
.
getUid
()));
if
(!
CollectionUtils
.
isEmpty
(
keys
))
{
AdamEnters
deaultEnters
=
new
AdamEnters
();
deaultEnters
.
setIsDefault
(
false
);
deaultEnters
.
setUpdatedAt
(
info
.
getCreatedAt
());
deaultEnters
.
setUid
(
info
.
getUid
());
BasicDBObject
object
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
deaultEnters
));
Document
doc
=
mongoTemplate
.
getCollection
(
AdamEnters
.
class
.
getSimpleName
()).
findOneAndUpdate
(
Query
.
query
(
Criteria
.
where
(
"uid"
).
is
(
deaultEnters
.
getUid
()).
and
(
"isDefault"
).
is
(
true
)).
getQueryObject
(),
object
,
new
FindOneAndUpdateOptions
().
returnDocument
(
ReturnDocument
.
AFTER
)
);
if
(
null
!=
doc
)
{
List
<
Object
>
paramList
=
new
ArrayList
<>();
paramList
.
add
(
deaultEnters
.
getIsDefault
());
paramList
.
add
(
deaultEnters
.
getUpdatedAt
());
paramList
.
add
(
doc
.
get
(
"uid"
));
rabbitTemplate
.
convertAndSend
(
MQConst
.
EXCHANGES_LIQUIDNET_SQL
,
MQConst
.
ROUTING_KEY_SQL
,
SqlMapping
.
get
(
"adam_enters.update.is_default"
,
paramList
.
toArray
()));
AdamEnters
enters
=
BsonUtil
.
toBean
(
doc
,
AdamEnters
.
class
);
redisUtil
.
hset
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
enters
.
getUid
()),
enters
.
getEntersId
(),
enters
);
}
}
}
// TODO: 2021/4/28 放入MQ
mongoTemplate
.
insert
(
Collections
.
singletonList
(
info
),
AdamEnters
.
class
.
getSimpleName
());
List
<
Object
>
paramList
=
new
ArrayList
<>();
paramList
.
add
(
info
.
getEntersId
());
paramList
.
add
(
info
.
getUid
());
paramList
.
add
(
info
.
getType
());
paramList
.
add
(
info
.
getName
());
paramList
.
add
(
info
.
getMobile
());
paramList
.
add
(
info
.
getIdCard
());
paramList
.
add
(
info
.
getIsDefault
());
paramList
.
add
(
info
.
getState
());
paramList
.
add
(
info
.
getCreatedAt
());
paramList
.
add
(
info
.
getUpdatedAt
());
paramList
.
add
(
info
.
getDeletedAt
());
paramList
.
add
(
info
.
getComment
());
rabbitTemplate
.
convertAndSend
(
MQConst
.
EXCHANGES_LIQUIDNET_SQL
,
MQConst
.
ROUTING_KEY_SQL
,
SqlMapping
.
get
(
"adam_enters.add"
,
paramList
.
toArray
()));
// TODO: 2021/4/28 同步REDIS
redisUtil
.
hset
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
info
.
getUid
()),
info
.
getEntersId
(),
info
);
}
@Override
public
AdamEnters
query
(
String
uid
,
String
entersId
)
{
AdamEnters
info
=
null
;
// TODO: 2021/4/28 REDIS:QUERY
info
=
(
AdamEnters
)
redisUtil
.
hget
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
uid
),
entersId
);
AdamEnters
info
=
(
AdamEnters
)
redisUtil
.
hget
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
uid
),
entersId
);
if
(
null
==
info
)
{
info
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"entersId"
).
is
(
entersId
)),
AdamEnters
.
class
,
AdamEnters
.
class
.
getSimpleName
());
...
...
@@ -84,15 +132,75 @@ public class AdamEntersServiceImpl extends ServiceImpl<AdamEntersMapper, AdamEnt
}
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
edit
(
AdamEnters
info
)
{
BasicDBObject
object
=
new
BasicDBObject
(
"$set"
,
JSON
.
parse
(
JsonUtils
.
toJson
(
info
)));
mongoTemplate
.
getCollection
(
AdamEnters
.
class
.
getSimpleName
())
.
updateOne
(
Query
.
query
(
Criteria
.
where
(
"entersId"
).
is
(
info
.
getEntersId
())).
getQueryObject
(),
object
);
// TODO: 2021/4/28 放入MQ
AdamEnters
oldEnters
=
(
AdamEnters
)
redisUtil
.
hget
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
info
.
getUid
()),
info
.
getEntersId
());
if
(
null
==
oldEnters
)
return
;
if
(
info
.
getIsDefault
()
&&
!
oldEnters
.
getIsDefault
())
{
AdamEnters
deaultEnters
=
new
AdamEnters
();
deaultEnters
.
setIsDefault
(
false
);
deaultEnters
.
setUpdatedAt
(
info
.
getUpdatedAt
());
deaultEnters
.
setUid
(
info
.
getUid
());
BasicDBObject
object
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
deaultEnters
));
Document
doc
=
mongoTemplate
.
getCollection
(
AdamEnters
.
class
.
getSimpleName
()).
findOneAndUpdate
(
Query
.
query
(
Criteria
.
where
(
"uid"
).
is
(
deaultEnters
.
getUid
()).
and
(
"isDefault"
).
is
(
true
)).
getQueryObject
(),
object
,
new
FindOneAndUpdateOptions
().
returnDocument
(
ReturnDocument
.
AFTER
)
);
if
(
null
!=
doc
)
{
List
<
Object
>
paramList
=
new
ArrayList
<>();
paramList
.
add
(
deaultEnters
.
getIsDefault
());
paramList
.
add
(
deaultEnters
.
getUpdatedAt
());
paramList
.
add
(
doc
.
get
(
"uid"
));
rabbitTemplate
.
convertAndSend
(
MQConst
.
EXCHANGES_LIQUIDNET_SQL
,
MQConst
.
ROUTING_KEY_SQL
,
SqlMapping
.
get
(
"adam_enters.update.is_default"
,
paramList
.
toArray
()));
AdamEnters
enters
=
BsonUtil
.
toBean
(
doc
,
AdamEnters
.
class
);
redisUtil
.
hset
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
enters
.
getUid
()),
enters
.
getEntersId
(),
enters
);
}
}
BasicDBObject
object
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
info
));
Document
doc
=
mongoTemplate
.
getCollection
(
AdamEnters
.
class
.
getSimpleName
()).
findOneAndUpdate
(
Query
.
query
(
Criteria
.
where
(
"entersId"
).
is
(
info
.
getEntersId
())).
getQueryObject
(),
object
,
new
FindOneAndUpdateOptions
().
returnDocument
(
ReturnDocument
.
AFTER
)
);
List
<
Object
>
paramList
=
new
ArrayList
<>();
paramList
.
add
(
info
.
getType
());
paramList
.
add
(
info
.
getName
());
paramList
.
add
(
info
.
getMobile
());
paramList
.
add
(
info
.
getIdCard
());
paramList
.
add
(
info
.
getIsDefault
());
paramList
.
add
(
info
.
getState
());
paramList
.
add
(
info
.
getUpdatedAt
());
paramList
.
add
(
info
.
getEntersId
());
rabbitTemplate
.
convertAndSend
(
MQConst
.
EXCHANGES_LIQUIDNET_SQL
,
MQConst
.
ROUTING_KEY_SQL
,
SqlMapping
.
get
(
"adam_enters.edit"
,
paramList
.
toArray
()));
redisUtil
.
hset
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
info
.
getUid
()),
info
.
getEntersId
(),
BsonUtil
.
toBean
(
doc
,
AdamEnters
.
class
));
}
// TODO: 2021/4/28 同步REDIS
redisUtil
.
hset
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
info
.
getUid
()),
info
.
getEntersId
(),
info
);
@Override
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
public
void
remove
(
String
uid
,
String
entersId
)
{
AdamEnters
oldEnters
=
(
AdamEnters
)
redisUtil
.
hget
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
uid
),
entersId
);
if
(
null
==
oldEnters
)
return
;
oldEnters
.
setUpdatedAt
(
LocalDateTime
.
now
());
oldEnters
.
setState
(
2
);
BasicDBObject
object
=
new
BasicDBObject
(
"$set"
,
mongoConverter
.
convertToMongoType
(
oldEnters
));
UpdateResult
updateResult
=
mongoTemplate
.
getCollection
(
AdamEnters
.
class
.
getSimpleName
())
.
updateOne
(
Query
.
query
(
Criteria
.
where
(
"entersId"
).
is
(
entersId
)).
getQueryObject
(),
object
);
List
<
Object
>
paramList
=
new
ArrayList
<>();
paramList
.
add
(
oldEnters
.
getState
());
paramList
.
add
(
oldEnters
.
getUpdatedAt
());
paramList
.
add
(
oldEnters
.
getUpdatedAt
());
paramList
.
add
(
entersId
);
rabbitTemplate
.
convertAndSend
(
MQConst
.
EXCHANGES_LIQUIDNET_SQL
,
MQConst
.
ROUTING_KEY_SQL
,
SqlMapping
.
get
(
"adam_enters.remove"
,
paramList
.
toArray
()));
redisUtil
.
hdel
(
AdamRedisConst
.
INFO_ENTERS
.
concat
(
uid
),
entersId
);
}
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/resources/sqlmap/enters.properties
0 → 100644
View file @
4440ad17
adam_enters.add
=
INSERT INTO adam_enters (enters_id, `uid`, `type`,`name`, mobile, id_card, is_default, `state`, created_at, updated_at, deleted_at, `comment`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)
adam_enters.edit
=
UPDATE adam_enters SET `type`=?, `name`=?, mobile=?, id_card=?, is_default=?, `state`=?, updated_at=? where enters_id=?
adam_enters.update.is_default
=
UPDATE adam_enters set is_default=?, updated_at=? where enters_id=?
adam_enters.remove
=
UPDATE adam_enters SET `state`=?, updated_at=?, deleted_at=? where enters_id=?
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer/pom.xml
View file @
4440ad17
...
...
@@ -16,4 +16,32 @@
<maven.compiler.target>
8
</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-service-base
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-mq
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer/src/main/java/com/liquidnet/service/ServiceConsumerApplication.java
View file @
4440ad17
...
...
@@ -4,7 +4,12 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
;
import
org.springframework.cloud.bus.BusAutoConfiguration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
...
...
@@ -15,6 +20,9 @@ import java.net.UnknownHostException;
import
java.util.Arrays
;
@Slf4j
@EnableAutoConfiguration
(
exclude
=
{
BusAutoConfiguration
.
class
,
MongoAutoConfiguration
.
class
,
RedisAutoConfiguration
.
class
}
)
@SpringBootApplication
(
scanBasePackages
=
{
"com.liquidnet"
})
public
class
ServiceConsumerApplication
implements
CommandLineRunner
{
@Autowired
...
...
liquidnet-bus-service/liquidnet-service-consumer/src/main/java/com/liquidnet/service/consumer/service/IBaseDao.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
service
.
consumer
.
service
;
import
java.util.LinkedList
;
public
interface
IBaseDao
{
/**
* 批量执行sql
*
* @param sql
* @param values
* @return
*/
Boolean
batchSql
(
String
sql
,
LinkedList
<
Object
[]>
values
);
/**
* 批量执行不定量sql
*
* @param sql
* @param values
* @return
*/
Boolean
batchSqls
(
LinkedList
<
String
>
sql
,
LinkedList
<
Object
[]>...
values
);
/**
* xs 新增一条记录且返回主键Id
*
* @param sql 新增待执行sql
* @param param 参数
* @return 主键ID
*/
int
insertSqlAndReturnKeyId
(
final
String
sql
,
final
Object
[]
param
);
}
liquidnet-bus-service/liquidnet-service-consumer/src/main/java/com/liquidnet/service/consumer/service/impl/BaseDao.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
service
.
consumer
.
service
.
impl
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.consumer.service.IBaseDao
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.dao.DataAccessException
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.PreparedStatementCreator
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.jdbc.support.GeneratedKeyHolder
;
import
org.springframework.jdbc.support.KeyHolder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.TransactionStatus
;
import
org.springframework.transaction.support.TransactionCallback
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
javax.annotation.Resource
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.LinkedList
;
import
java.util.List
;
@Service
public
class
BaseDao
implements
IBaseDao
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BaseDao
.
class
);
@Resource
public
JdbcTemplate
jdbcTemplate
;
@Resource
(
name
=
"transactionManager"
)
public
DataSourceTransactionManager
transactionManager
;
@Override
public
Boolean
batchSql
(
final
String
sql
,
final
LinkedList
<
Object
[]>
values
)
{
TransactionCallback
<
Boolean
>
callback
=
new
TransactionCallback
<
Boolean
>()
{
@Override
public
Boolean
doInTransaction
(
final
TransactionStatus
transactionStatus
)
{
if
(
values
.
size
()
>
0
)
{
jdbcTemplate
.
batchUpdate
(
sql
,
values
);
}
return
true
;
}
};
try
{
TransactionTemplate
tt
=
new
TransactionTemplate
(
transactionManager
);
return
tt
.
execute
(
callback
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"###SQL.Preparing:{}\nParameters:{}"
,
JsonUtils
.
toJson
(
sql
),
JsonUtils
.
toJson
(
values
),
ex
);
return
false
;
}
}
@Override
public
Boolean
batchSqls
(
final
LinkedList
<
String
>
sql
,
final
LinkedList
<
Object
[]>...
values
)
{
TransactionCallback
<
Boolean
>
callback
=
new
TransactionCallback
<
Boolean
>()
{
@Override
public
Boolean
doInTransaction
(
final
TransactionStatus
transactionStatus
)
{
int
i
=
0
;
for
(
LinkedList
<
Object
[]>
o
:
values
)
{
if
(
sql
.
size
()
<
i
+
1
)
{
break
;
}
if
(!
o
.
isEmpty
())
{
jdbcTemplate
.
batchUpdate
(
sql
.
get
(
i
),
o
);
}
i
++;
}
return
true
;
}
};
try
{
TransactionTemplate
tt
=
new
TransactionTemplate
(
transactionManager
);
return
tt
.
execute
(
callback
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"###SQL.Preparing:{}\nParameters:{}"
,
JsonUtils
.
toJson
(
sql
),
JsonUtils
.
toJson
(
values
),
ex
);
return
false
;
}
}
/**
* xs 新增一条记录且返回主键Id
*
* @param sql 新增待执行sql
* @param param 参数
* @return 主键ID
*/
public
int
insertSqlAndReturnKeyId
(
final
String
sql
,
final
Object
[]
param
)
{
final
String
innersql
=
sql
;
final
Object
[]
innerO
=
param
;
KeyHolder
keyHolder
=
new
GeneratedKeyHolder
();
try
{
jdbcTemplate
.
update
(
new
PreparedStatementCreator
()
{
@Override
public
PreparedStatement
createPreparedStatement
(
final
Connection
con
)
throws
SQLException
{
PreparedStatement
ps
=
con
.
prepareStatement
(
innersql
,
Statement
.
RETURN_GENERATED_KEYS
);
for
(
int
i
=
0
;
i
<
innerO
.
length
;
i
++)
{
ps
.
setObject
(
i
+
1
,
innerO
[
i
]);
}
return
ps
;
}
},
keyHolder
);
}
catch
(
Exception
e
)
{
log
.
error
(
"###SQL.Preparing:{}\nParameters:{}"
,
sql
,
JsonUtils
.
toJson
(
param
),
e
);
}
return
keyHolder
.
getKey
().
intValue
();
}
}
liquidnet-bus-service/liquidnet-service-consumer/src/main/java/com/liquidnet/service/consumer/service/processor/ConsumerProcessor.java
View file @
4440ad17
package
com
.
liquidnet
.
service
.
consumer
.
service
.
processor
;
import
com.liquidnet.common.mq.constant.MQConst
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.SqlMessage
;
import
com.liquidnet.service.consumer.service.IBaseDao
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.annotation.*
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* ConsumerProcessor.class
*
...
...
@@ -14,13 +19,30 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
public
class
ConsumerProcessor
{
@RabbitListener
(
bindings
=
@QueueBinding
(
exchange
=
@Exchange
(
"queue_test"
),
key
=
"queue_key"
,
value
=
@Queue
(
"queue_adam"
)
))
@RabbitHandler
public
void
consumerSql
(
Message
message
)
{
log
.
info
(
"consumer sql:{}"
,
message
);
@Resource
IBaseDao
baseDao
;
// @RabbitListener(bindings = @QueueBinding(
// exchange = @Exchange("queue.sql"),
// key = "rk",
// value = @Queue("queue.sql.main")
// ))
// @RabbitHandler
// public void consumerSql(Message message) {
// log.info("consumer sql:{}", message);
// }
@RabbitListener
(
queues
=
MQConst
.
QUEUES_SQL_MAIN
)
public
void
consumerSql
(
String
msg
)
{
SqlMessage
sqlMessage
=
JsonUtils
.
fromJson
(
msg
,
SqlMessage
.
class
);
log
.
debug
(
"consumer sql ==> Preparing:{}"
,
JsonUtils
.
toJson
(
sqlMessage
.
getSqls
()));
log
.
debug
(
"consumer sql ==> Parameters:{}"
,
JsonUtils
.
toJson
(
sqlMessage
.
getArgs
()));
try
{
Boolean
rstBatchSqls
=
baseDao
.
batchSqls
(
sqlMessage
.
getSqls
(),
sqlMessage
.
getArgs
());
log
.
debug
(
"batchSqls result of execution:{}"
,
rstBatchSqls
);
}
catch
(
Exception
e
)
{
log
.
error
(
"error:sqlMessage:{}"
,
JsonUtils
.
toJson
(
sqlMessage
),
e
);
}
}
}
liquidnet-bus-service/liquidnet-service-consumer/src/main/resources/bootstrap-dev.yml
0 → 100644
View file @
4440ad17
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
dev
security
:
username
:
user
password
:
user123
eureka
:
host
:
127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
service-consumer
liquidnet-bus-service/liquidnet-service-consumer/src/main/resources/bootstrap-prod.yml
0 → 100644
View file @
4440ad17
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
prod
security
:
username
:
user
password
:
user123
eureka
:
host
:
127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
service-consumer
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer/src/main/resources/bootstrap-service-consumer.yml
0 → 100644
View file @
4440ad17
#eurekaServer配置
eureka
:
client
:
register-with-eureka
:
true
fetch-registry
:
true
serviceUrl
:
defaultZone
:
http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
#configServer配置
spring
:
cloud
:
config
:
# uri: http://127.0.0.1:7002/support-config
profile
:
${liquidnet.cloudConfig.profile}
name
:
${spring.application.name}
#默认为spring.application.name
discovery
:
enabled
:
true
service-id
:
liquidnet-support-config
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer/src/main/resources/bootstrap-test.yml
0 → 100644
View file @
4440ad17
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
test
security
:
username
:
user
password
:
user123
eureka
:
host
:
172.18.0.2:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
service-consumer
\ No newline at end of file
liquidnet-bus-service/liquidnet-service-consumer/src/main/resources/bootstrap.yml
0 → 100644
View file @
4440ad17
spring
:
application
:
name
:
liquidnet-service-consumer
profiles
:
active
:
dev
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/pom.xml
View file @
4440ad17
...
...
@@ -28,5 +28,14 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-service-base
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</project>
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/SupportZuulApplication.java
View file @
4440ad17
package
com
.
liquidnet
.
support
.
zuul
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.core.env.Environment
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Arrays
;
@EnableDiscoveryClient
@Slf4j
@EnableFeignClients
@EnableZuulProxy
@SpringBootApplication
public
class
SupportZuulApplication
{
@SpringBootApplication
(
scanBasePackages
=
{
"com.liquidnet"
})
public
class
SupportZuulApplication
implements
CommandLineRunner
{
@Autowired
private
Environment
environment
;
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SupportZuulApplication
.
class
,
args
);
}
@Override
public
void
run
(
String
...
strings
)
throws
Exception
{
try
{
log
.
info
(
"\n----------------------------------------------------------\n\t"
+
"Application '{}' is running! Access URLs:\n\t"
+
"Local: \t\thttp://127.0.0.1:{}\n\t"
+
"External: \thttp://{}:{}{}/doc.html\n\t"
+
"Profile(s): \t{}\n----------------------------------------------------------"
,
environment
.
getProperty
(
"spring.application.name"
),
environment
.
getProperty
(
"server.port"
),
InetAddress
.
getLocalHost
().
getHostAddress
(),
environment
.
getProperty
(
"server.port"
),
environment
.
getProperty
(
"server.servlet.context-path"
),
Arrays
.
toString
(
environment
.
getActiveProfiles
()));
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/config/swagger/ZuulDocumentationConfig.java
0 → 100644
View file @
4440ad17
package
com
.
liquidnet
.
support
.
zuul
.
config
.
swagger
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
import
springfox.documentation.swagger.web.SwaggerResource
;
import
springfox.documentation.swagger.web.SwaggerResourcesProvider
;
import
java.util.ArrayList
;
import
java.util.List
;
@Primary
@Component
public
class
ZuulDocumentationConfig
implements
SwaggerResourcesProvider
{
private
final
RouteLocator
routeLocator
;
public
ZuulDocumentationConfig
(
RouteLocator
routeLocator
)
{
this
.
routeLocator
=
routeLocator
;
}
@Override
public
List
<
SwaggerResource
>
get
()
{
List
<
SwaggerResource
>
resources
=
new
ArrayList
<>();
List
<
Route
>
routes
=
routeLocator
.
getRoutes
();
routes
.
forEach
(
route
->
resources
.
add
(
swaggerResource
(
route
.
getId
(),
route
.
getFullPath
().
replace
(
"**"
,
"v2/api-docs"
))
));
// resources.add(swaggerResource("Adam", "/api/adam/v2/api-docs"));
// resources.add(swaggerResource("Kylin", "/api/kylin/v2/api-docs"));
return
resources
;
}
private
SwaggerResource
swaggerResource
(
String
name
,
String
location
)
{
SwaggerResource
swaggerResource
=
new
SwaggerResource
();
swaggerResource
.
setName
(
name
);
swaggerResource
.
setLocation
(
location
);
swaggerResource
.
setSwaggerVersion
(
"1.0"
);
return
swaggerResource
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/config/swagger/ZuulSwagger2Config.java
0 → 100755
View file @
4440ad17
package
com
.
liquidnet
.
support
.
zuul
.
config
.
swagger
;
import
com.liquidnet.common.swagger.config.Swagger2Config
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
ZuulSwagger2Config
extends
Swagger2Config
{
// @Override
// public ApiInfo apiInfo() {
// return new ApiInfoBuilder()
// .title("LiquidNet Services")
// .description("LiquidNet接口文档说明")
// .contact(new Contact("liquidnet", "", "**@liquidnet.io"))
// .version("1.0")
// .termsOfServiceUrl("http://localhost:8081")
// .build();
// }
//
// @Bean
// UiConfiguration uiConfig() {
// return new UiConfiguration(null, "list", "alpha", "schema",
// UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS, false, true, 60000L);
// }
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/error/ErrorExtFilter.java
deleted
100644 → 0
View file @
ad094a81
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
error
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter
;
import
org.springframework.stereotype.Component
;
/**
* 从POST抛出的异常,使用该过滤器返回错误信息
*/
@Component
public
class
ErrorExtFilter
extends
SendErrorFilter
{
Logger
log
=
LoggerFactory
.
getLogger
(
ErrorExtFilter
.
class
);
@Override
public
String
filterType
()
{
return
"error"
;
}
@Override
public
int
filterOrder
()
{
return
30
;
}
@Override
public
boolean
shouldFilter
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
ZuulFilter
failedFilter
=
(
ZuulFilter
)
ctx
.
get
(
"failed.filter"
);
if
(
failedFilter
!=
null
&&
failedFilter
.
filterType
().
equals
(
"post"
))
{
return
true
;
}
return
false
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/error/ErrorFilter.java
deleted
100644 → 0
View file @
ad094a81
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
error
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 捕获为处理的异常统一做一些处理,让`SendErrorFilter`可以正确的返回异常信息
* 当是`post`过滤器抛出的话,错误信息会让`ErrorExtFilter`返回异常信息
*/
@Component
public
class
ErrorFilter
extends
ZuulFilter
{
Logger
log
=
LoggerFactory
.
getLogger
(
ErrorFilter
.
class
);
@Override
public
String
filterType
()
{
return
"error"
;
}
@Override
public
int
filterOrder
()
{
return
20
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
Throwable
throwable
=
RequestContext
.
getCurrentContext
().
getThrowable
();
log
.
error
(
"this is a ErrorFilter : {}"
,
throwable
.
getCause
().
getMessage
());
ctx
.
set
(
"error.status_code"
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
ctx
.
set
(
"error.exception"
,
throwable
.
getCause
());
return
null
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/post/ThrowExceptionPostFilter.java
deleted
100644 → 0
View file @
ad094a81
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
post
;
import
com.netflix.zuul.ZuulFilter
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ThrowExceptionPostFilter
extends
ZuulFilter
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ThrowExceptionPostFilter
.
class
);
@Override
public
String
filterType
()
{
return
"post"
;
}
@Override
public
int
filterOrder
()
{
return
10
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
log
.
info
(
"This is a post filter, it will throw a RuntimeException"
);
doSomething
();
return
null
;
}
private
void
doSomething
()
{
// throw new RuntimeException("Exist some errors...");
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/pre/ThrowExceptionFilter.java
deleted
100644 → 0
View file @
ad094a81
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
pre
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletResponse
;
@Component
public
class
ThrowExceptionFilter
extends
ZuulFilter
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ThrowExceptionFilter
.
class
);
@Override
public
String
filterType
()
{
return
"pre"
;
}
@Override
public
int
filterOrder
()
{
return
0
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
log
.
info
(
"This is a pre filter, it will throw a RuntimeException"
);
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
try
{
doSomething
();
}
catch
(
Exception
e
)
{
ctx
.
set
(
"error.status_code"
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
ctx
.
set
(
"error.exception"
,
e
);
}
return
null
;
}
private
void
doSomething
()
{
// throw new RuntimeException("Exist some errors...");
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application-test.yml
deleted
100644 → 0
View file @
ad094a81
liquidnet
:
eureka
:
# serviceUrl: 127.0.0.1:7001/eureka-server/eureka
serviceUrl
:
192.168.31.229:7001/eureka-server/eureka
spring
:
profiles
:
include
:
zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application-zuul.yml
deleted
100644 → 0
View file @
ad094a81
spring
:
application
:
name
:
liquidnet-gateway-zuul
security
:
basic
:
enabled
:
true
user
:
name
:
user
password
:
user123
server
:
port
:
7003
server
:
tomcat
:
accept-count
:
500
max-threads
:
500
min-spare-threads
:
100
max-connections
:
1000
connection-timeout
:
5000
eureka
:
client
:
healthcheck
:
enabled
:
true
register-with-eureka
:
true
fetch-registry
:
true
serviceUrl
:
# defaultZone: ${liquidnet.eureka.serviceUrl}
defaultZone
:
http://${spring.security.user.name}:${spring.security.user.password}@${liquidnet.eureka.serviceUrl}
instance
:
hostname
:
${spring.cloud.client.ip-address}
lease-expiration-duration-in-seconds
:
15
#服务过期时间配置,超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除
lease-renewal-interval-in-seconds
:
5
#服务刷新时间配置,每隔这个时间会主动心跳一次
prefer-ip-address
:
true
instance-id
:
${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
zuul
:
prefix
:
/liquidnet-api
host
:
max-per-route-connections
:
1000
max-total-connections
:
2000
routes
:
liquidnet-service-adam
:
/adam/**
liquidnet-service-sequence
:
/sequence/**
liquidnet-service-example
:
/example/**
liquidnet-service-account
:
/account/**
liquidnet-service-task
:
/task/**
ThrowExceptionPostFilter
:
post
:
disable
:
true
#解决错误 com.netflix.client.ClientException: Load balancer does not have available server for client:panfeng-item-service
#这样就可以即指定path与URL,又不破坏Zuul的Hystrix与Ribbon特性了。
#开启eureka负载均衡策略
ribbon
:
eureka
:
enabled
:
false
# 为Ribbon禁用Eureka
liquidnet-service-sequence
:
ribbon
:
listOfServers
:
192.168.137.1:9001
logging
:
level
:
com.netflix
:
debug
#zuul:
# prefix: /api
# strip-prefix: false
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application.yml
deleted
100644 → 0
View file @
ad094a81
spring
:
profiles
:
active
:
test
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/banner.txt
deleted
100644 → 0
View file @
ad094a81
/$$ /$$ /$$ /$$ /$$ /$$ /$$
| $$ |__/ |__/ | $$| $$$ | $$ | $$
| $$ /$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$$| $$$$| $$ /$$$$$$ /$$$$$$
| $$ | $$ /$$__ $$| $$ | $$| $$ /$$__ $$| $$ $$ $$ /$$__ $$|_ $$_/
| $$ | $$| $$ \ $$| $$ | $$| $$| $$ | $$| $$ $$$$| $$$$$$$$ | $$
| $$ | $$| $$ | $$| $$ | $$| $$| $$ | $$| $$\ $$$| $$_____/ | $$ /$$
| $$$$$$$$| $$| $$$$$$$| $$$$$$/| $$| $$$$$$$| $$ \ $$| $$$$$$$ | $$$$/
|________/|__/ \____ $$ \______/ |__/ \_______/|__/ \__/ \_______/ \___/
| $$
| $$
|__/
Application Version: ${application.version}${application.formatted-version}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-dev.yml
0 → 100755
View file @
4440ad17
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
dev
security
:
username
:
user
password
:
user123
eureka
:
host
:
127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
support-zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-prod.yml
View file @
4440ad17
## ===================================================================
## Spring Cloud Config bootstrap configuration for the "dev" profile
## In prod profile, properties will be overwriten by the ones defined in bootstrap-prod.yml
## ===================================================================
#
#spring:
# application:
# name: liquidnet-gateway-zuul
# profiles:
# active: prod
# cloud:
# config:
# # name of the config server's property source (file.yml) that we want to use
# profile: prod # profile(s) of the property source
# label: master # toggle to switch to a different version of the configuration as stored in git
# uri: http://172.24.132.45:20001/
# # it can be set to any label, branch or commit of the config source git repository
#
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
prod
security
:
username
:
user
password
:
user123
eureka
:
host
:
127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
service-zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-support-zuul.yml
0 → 100755
View file @
4440ad17
#eurekaServer配置
eureka
:
client
:
register-with-eureka
:
true
fetch-registry
:
true
serviceUrl
:
defaultZone
:
http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
#configServer配置
spring
:
cloud
:
config
:
# uri: http://127.0.0.1:7002/support-config
profile
:
${liquidnet.cloudConfig.profile}
name
:
${spring.application.name}
#默认为spring.application.name
discovery
:
enabled
:
true
service-id
:
liquidnet-support-config
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-test.yml
View file @
4440ad17
## ===================================================================
## Spring Cloud Config bootstrap configuration for the "dev" profile
## In prod profile, properties will be overwriten by the ones defined in bootstrap-prod.yml
## ===================================================================
#
#spring:
# application:
# name: liquidnet-gateway-zuul
# profiles:
# active: test
# cloud:
# config:
# label: ${spring.profiles.active1:dev} #当配置文件在git上时为分支名
## profile: ${spring.profiles.active1:dev} #对应业务名称的profile
# uri: http://172.24.133.63:20001/
## discovery: # 需要考虑 eureka 地址的初始化 先不使用
## enabled: true # 默认false,设为true表示使用注册中心中的configserver配置而不自己配置configserver的uri
## serviceId: liquidnet-config-service # 指定config server在服务发现中的serviceId,默认为:configserver
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
test
security
:
username
:
user
password
:
user123
eureka
:
host
:
172.18.0.2:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
service-zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap.yml
View file @
4440ad17
#
#spring:
# application:
# name: liquidnet-gateway-zuul
# profiles:
# active: dev
# cloud:
# config:
# label: ${spring.profiles.active1:dev} #当配置文件在git上时为分支名
## profile: ${spring.profiles.active1:dev} #对应业务名称的profile
# uri: http://172.24.132.45:20001/
## discovery: # 需要考虑 eureka 地址的初始化 先不使用
## enabled: true # 默认false,设为true表示使用注册中心中的configserver配置而不自己配置configserver的uri
## serviceId: liquidnet-config-service # 指定config server在服务发现中的serviceId,默认为:configserver
spring
:
application
:
name
:
liquidnet-support-zuul
profiles
:
active
:
dev
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/logback.xml
deleted
100644 → 0
View file @
ad094a81
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration
scan=
"true"
scanPeriod=
"10 seconds"
>
<!-- Simple file output -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
[ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!-- rollover daily 配置日志所生成的目录以及生成文件名的规则 -->
<fileNamePattern>
/data/logs/YGZX/dubbo/liquidnet-gateway-zuul/liquidnet-gateway-zuul-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>
64 MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
</filter>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
true
</prudent>
</appender>
<!-- Console output -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
[ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<!-- Only log level WARN and above -->
<!--<filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
<!--<level>WARN</level>-->
<!--</filter>-->
</appender>
<!-- Enable FILE and STDOUT appenders for all log messages.
By default, only log at level INFO and above. -->
<root
level=
"INFO"
>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
<!-- For loggers in the these namespaces, log at all levels. -->
<!--<logger name="pedestal" level="ALL"/>-->
<!--<logger name="hammock-cafe" level="ALL"/>-->
<!--<logger name="user" level="ALL"/>-->
</configuration>
liquidnet-bus-support/pom.xml
View file @
4440ad17
...
...
@@ -44,6 +44,11 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
29.0-jre
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment