Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
admin
Project
Project
Details
Activity
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
曲欣亮
admin
Commits
54fc136a
Commit
54fc136a
authored
Aug 06, 2018
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除多余目录
Change-Id: Iaeb88d88a3c6965b44512991d8a3008edaa57f23
parent
c9a5aceb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
0 additions
and
263 deletions
+0
-263
ExceptionHandler.java
src/main/java/cn/ossip/admin/config/ExceptionHandler.java
+0
-38
SwaggerConfig.java
src/main/java/cn/ossip/admin/config/SwaggerConfig.java
+0
-35
WebMvcConfig.java
src/main/java/cn/ossip/admin/config/WebMvcConfig.java
+0
-57
XException.java
src/main/java/cn/ossip/admin/config/XException.java
+0
-43
ConfigDataSourceConfig.java
...ossip/admin/config/datasource/ConfigDataSourceConfig.java
+0
-47
ShopDataSourceConfig.java
...n/ossip/admin/config/datasource/ShopDataSourceConfig.java
+0
-43
No files found.
src/main/java/cn/ossip/admin/config/ExceptionHandler.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.view.json.MappingJackson2JsonView
;
import
com.egolm.common.bean.Rjx
;
@Component
public
class
ExceptionHandler
implements
HandlerExceptionResolver
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandler
.
class
);
@Override
public
ModelAndView
resolveException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
{
ModelAndView
mav
=
new
ModelAndView
(
new
MappingJackson2JsonView
());
try
{
response
.
setContentType
(
"application/json"
);
if
(
ex
instanceof
XException
)
{
mav
.
addAllObjects
(((
XException
)
ex
).
getRjx
());
}
else
{
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
"未处理异常["
+
ex
.
getClass
().
getName
()
+
":"
+
ex
.
getMessage
()
+
"]"
));
}
}
catch
(
Exception
e
)
{
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
"异常处理失败"
));
}
finally
{
logger
.
error
(
""
,
ex
);
}
return
mav
;
}
}
src/main/java/cn/ossip/admin/config/SwaggerConfig.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
@Configuration
public
class
SwaggerConfig
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.egolm.admin"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"在线文档"
)
.
description
(
"在线文档"
)
.
termsOfServiceUrl
(
"NO terms of service"
)
.
version
(
"1.0"
)
.
build
();
}
}
src/main/java/cn/ossip/admin/config/WebMvcConfig.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
;
import
java.util.EventListener
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextListener
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.servlet.config.annotation.PathMatchConfigurer
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@Configuration
public
class
WebMvcConfig
extends
WebMvcConfigurerAdapter
{
@Override
public
void
configurePathMatch
(
PathMatchConfigurer
configurer
)
{
configurer
.
setUseSuffixPatternMatch
(
false
).
setUseTrailingSlashMatch
(
false
);
}
@Bean
public
ServletListenerRegistrationBean
<
EventListener
>
getDemoListener
(){
ServletListenerRegistrationBean
<
EventListener
>
registrationBean
=
new
ServletListenerRegistrationBean
<>();
registrationBean
.
setListener
(
new
RequestContextListener
());
return
registrationBean
;
}
public
static
HttpServletRequest
getRequest
()
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
servletRequestAttributes
!=
null
)
{
return
servletRequestAttributes
.
getRequest
();
}
return
null
;
}
public
static
HttpServletResponse
getResponse
()
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
servletRequestAttributes
!=
null
)
{
return
servletRequestAttributes
.
getResponse
();
}
return
null
;
}
public
static
HttpSession
getSession
()
{
HttpServletRequest
request
=
WebMvcConfig
.
getRequest
();
if
(
request
!=
null
)
{
return
request
.
getSession
();
}
return
null
;
}
}
src/main/java/cn/ossip/admin/config/XException.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
;
import
com.egolm.common.bean.Rjx
;
public
class
XException
extends
RuntimeException
{
private
static
final
long
serialVersionUID
=
1L
;
private
Rjx
rjx
=
Rjx
.
jsonErr
().
setStatus
(
500
).
setMessage
(
"ERROR"
);
public
XException
(
String
msg
)
{
super
(
msg
);
rjx
.
setMessage
(
msg
);
}
public
XException
(
String
msg
,
Throwable
e
)
{
super
(
msg
,
e
);
rjx
.
setMessage
(
msg
);
}
public
XException
(
String
msg
,
int
code
)
{
super
(
msg
);
rjx
.
setMessage
(
msg
);
rjx
.
setStatus
(
code
);
}
public
XException
(
String
msg
,
int
code
,
Throwable
e
)
{
super
(
msg
,
e
);
rjx
.
setMessage
(
msg
);
rjx
.
setStatus
(
code
);
}
public
Rjx
getRjx
()
{
return
rjx
;
}
public
static
void
assertNotBlank
(
Object
obj
,
String
message
)
{
if
(
obj
==
null
||
obj
.
toString
().
trim
().
equals
(
""
))
{
throw
new
XException
((
message
==
null
||
message
.
trim
().
equals
(
""
))
?
"对象不能为空"
:
message
);
}
}
}
src/main/java/cn/ossip/admin/config/datasource/ConfigDataSourceConfig.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
.
datasource
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.dialect.MySqlDialect
;
@Configuration
public
class
ConfigDataSourceConfig
{
@Bean
@Primary
@Qualifier
(
"configDataSource"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource.config"
)
public
DataSource
getDataSource
()
{
return
DataSourceBuilder
.
create
().
type
(
DruidDataSource
.
class
).
build
();
}
@Bean
@Primary
@Qualifier
(
"configTxManager"
)
public
PlatformTransactionManager
getTransactionManager
(
@Qualifier
(
"configDataSource"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
@Primary
@Qualifier
(
"configJdbcTemplate"
)
public
JdbcTemplate
getJdbcTemplate
(
@Qualifier
(
"configDataSource"
)
DataSource
dataSource
)
{
JdbcTemplate
jdbcTemplate
=
new
JdbcTemplate
();
jdbcTemplate
.
setDataSource
(
dataSource
);
jdbcTemplate
.
setDialect
(
new
MySqlDialect
());
jdbcTemplate
.
setSql_level
(
3
);
return
jdbcTemplate
;
}
}
\ No newline at end of file
src/main/java/cn/ossip/admin/config/datasource/ShopDataSourceConfig.java
deleted
100644 → 0
View file @
c9a5aceb
package
cn
.
ossip
.
admin
.
config
.
datasource
;
import
javax.sql.DataSource
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.dialect.MySqlDialect
;
@Configuration
public
class
ShopDataSourceConfig
{
@Bean
@Qualifier
(
"shopDataSource"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource.shop"
)
public
DataSource
getDataSource
()
{
return
DataSourceBuilder
.
create
().
type
(
DruidDataSource
.
class
).
build
();
}
@Bean
@Qualifier
(
"shopTxManager"
)
public
PlatformTransactionManager
getTransactionManager
(
@Qualifier
(
"shopDataSource"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
@Qualifier
(
"shopJdbcTemplate"
)
public
JdbcTemplate
getJdbcTemplate
(
@Qualifier
(
"shopDataSource"
)
DataSource
dataSource
)
{
JdbcTemplate
jdbcTemplate
=
new
JdbcTemplate
();
jdbcTemplate
.
setDataSource
(
dataSource
);
jdbcTemplate
.
setDialect
(
new
MySqlDialect
());
jdbcTemplate
.
setSql_level
(
3
);
return
jdbcTemplate
;
}
}
\ No newline at end of file
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