Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
8c4fd97e
Commit
8c4fd97e
authored
Jan 20, 2019
by
郑杰
Browse files
v1.5 beta版发布,详细查看发行版说明
parent
b066bb99
Changes
198
Expand all
Hide whitespace changes
Inline
Side-by-side
eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.service.impl
;
import
me.zhengjie.domain.GenConfig
;
import
me.zhengjie.domain.vo.ColumnInfo
;
import
me.zhengjie.domain.vo.TableInfo
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.service.GeneratorService
;
import
me.zhengjie.utils.GenUtil
;
import
me.zhengjie.utils.PageUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author jie
* @date 2019-01-02
*/
@Service
public
class
GeneratorServiceImpl
implements
GeneratorService
{
@PersistenceContext
private
EntityManager
em
;
@Override
public
Object
getTables
(
String
name
,
int
[]
startEnd
)
{
StringBuilder
sql
=
new
StringBuilder
(
"select table_name tableName,create_time createTime from information_schema.tables where table_schema = (select database()) "
);
if
(!
ObjectUtils
.
isEmpty
(
name
)){
sql
.
append
(
"and table_name like '%"
+
name
+
"%' "
);
}
sql
.
append
(
"order by table_name"
);
Query
query
=
em
.
createNativeQuery
(
sql
.
toString
());
query
.
setFirstResult
(
startEnd
[
0
]);
query
.
setMaxResults
(
startEnd
[
1
]);
System
.
out
.
println
(
sql
.
toString
());
List
<
Object
[]>
result
=
query
.
getResultList
();
List
<
TableInfo
>
tableInfos
=
new
ArrayList
<>();
for
(
Object
[]
obj
:
result
)
{
tableInfos
.
add
(
new
TableInfo
(
obj
[
0
],
obj
[
1
]));
}
Query
query1
=
em
.
createNativeQuery
(
"SELECT COUNT(*) from information_schema.tables where table_schema = (select database())"
);
Object
totalElements
=
query1
.
getSingleResult
();
return
PageUtil
.
toPage
(
tableInfos
,
totalElements
);
}
@Override
public
Object
getColumns
(
String
name
)
{
StringBuilder
sql
=
new
StringBuilder
(
"select column_name, is_nullable, data_type, column_comment, column_key from information_schema.columns where "
);
if
(!
ObjectUtils
.
isEmpty
(
name
)){
sql
.
append
(
"table_name = '"
+
name
+
"' "
);
}
sql
.
append
(
"and table_schema = (select database()) order by ordinal_position"
);
Query
query
=
em
.
createNativeQuery
(
sql
.
toString
());
List
<
Object
[]>
result
=
query
.
getResultList
();
List
<
ColumnInfo
>
columnInfos
=
new
ArrayList
<>();
for
(
Object
[]
obj
:
result
)
{
columnInfos
.
add
(
new
ColumnInfo
(
obj
[
0
],
obj
[
1
],
obj
[
2
],
obj
[
3
],
obj
[
4
],
null
,
"true"
));
}
return
PageUtil
.
toPage
(
columnInfos
,
columnInfos
.
size
());
}
@Override
public
void
generator
(
List
<
ColumnInfo
>
columnInfos
,
GenConfig
genConfig
,
String
tableName
)
{
if
(
genConfig
.
getId
()
==
null
){
throw
new
BadRequestException
(
"请先配置生成器"
);
}
try
{
GenUtil
.
generatorCode
(
columnInfos
,
genConfig
,
tableName
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.utils
;
import
org.apache.commons.configuration.*
;
/**
* sql字段转java
*
* @author jie
* @date 2019-01-03
*/
public
class
ColUtil
{
/**
* 转换mysql数据类型为java数据类型
* @param type
* @return
*/
public
static
String
cloToJava
(
String
type
){
Configuration
config
=
getConfig
();
return
config
.
getString
(
type
,
"unknowType"
);
}
/**
* 获取配置信息
*/
public
static
PropertiesConfiguration
getConfig
()
{
try
{
return
new
PropertiesConfiguration
(
"generator.properties"
);
}
catch
(
ConfigurationException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.utils
;
import
cn.hutool.extra.template.*
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.domain.GenConfig
;
import
me.zhengjie.domain.vo.ColumnInfo
;
import
org.springframework.util.ObjectUtils
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.Writer
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 代码生成
* @author jie
* @date 2019-01-02
*/
@Slf4j
public
class
GenUtil
{
private
static
final
String
TIMESTAMP
=
"Timestamp"
;
private
static
final
String
BIGDECIMAL
=
"BigDecimal"
;
private
static
final
String
PK
=
"PRI"
;
/**
* 获取后端代码模板名称
* @return
*/
public
static
List
<
String
>
getAdminTemplateNames
()
{
List
<
String
>
templateNames
=
new
ArrayList
<>();
templateNames
.
add
(
"Entity"
);
templateNames
.
add
(
"Dto"
);
templateNames
.
add
(
"Mapper"
);
templateNames
.
add
(
"Repository"
);
templateNames
.
add
(
"Service"
);
templateNames
.
add
(
"ServiceImpl"
);
templateNames
.
add
(
"QueryService"
);
templateNames
.
add
(
"Controller"
);
return
templateNames
;
}
/**
* 获取前端代码模板名称
* @return
*/
public
static
List
<
String
>
getFrontTemplateNames
()
{
List
<
String
>
templateNames
=
new
ArrayList
<>();
templateNames
.
add
(
"api"
);
templateNames
.
add
(
"index"
);
templateNames
.
add
(
"header"
);
templateNames
.
add
(
"edit"
);
templateNames
.
add
(
"eForm"
);
return
templateNames
;
}
/**
* 生成代码
* @param columnInfos 表元数据
* @param genConfig 生成代码的参数配置,如包路径,作者
*/
public
static
void
generatorCode
(
List
<
ColumnInfo
>
columnInfos
,
GenConfig
genConfig
,
String
tableName
)
throws
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
();
map
.
put
(
"package"
,
genConfig
.
getPack
());
map
.
put
(
"moduleName"
,
genConfig
.
getModuleName
());
map
.
put
(
"author"
,
genConfig
.
getAuthor
());
map
.
put
(
"date"
,
LocalDate
.
now
().
toString
());
map
.
put
(
"tableName"
,
tableName
);
String
className
=
StringUtils
.
toCapitalizeCamelCase
(
tableName
);
map
.
put
(
"className"
,
className
);
map
.
put
(
"changeClassName"
,
StringUtils
.
toCamelCase
(
tableName
));
map
.
put
(
"hasTimestamp"
,
false
);
map
.
put
(
"hasBigDecimal"
,
false
);
map
.
put
(
"hasQuery"
,
false
);
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
ColumnInfo
column
:
columnInfos
)
{
Map
<
String
,
Object
>
listMap
=
new
HashMap
();
listMap
.
put
(
"columnComment"
,
column
.
getColumnComment
());
listMap
.
put
(
"columnKey"
,
column
.
getColumnKey
());
String
colType
=
ColUtil
.
cloToJava
(
column
.
getColumnType
().
toString
());
if
(
PK
.
equals
(
column
.
getColumnKey
())){
map
.
put
(
"pkColumnType"
,
colType
);
}
if
(
TIMESTAMP
.
equals
(
colType
)){
map
.
put
(
"hasTimestamp"
,
true
);
}
if
(
BIGDECIMAL
.
equals
(
colType
)){
map
.
put
(
"hasBigDecimal"
,
true
);
}
listMap
.
put
(
"columnType"
,
colType
);
listMap
.
put
(
"columnName"
,
column
.
getColumnName
());
listMap
.
put
(
"isNullable"
,
column
.
getIsNullable
());
listMap
.
put
(
"columnQuery"
,
column
.
getColumnQuery
());
if
(!
ObjectUtils
.
isEmpty
(
column
.
getColumnQuery
())){
map
.
put
(
"hasQuery"
,
true
);
}
listMap
.
put
(
"columnShow"
,
column
.
getColumnShow
());
listMap
.
put
(
"changeColumnName"
,
StringUtils
.
toCamelCase
(
column
.
getColumnName
().
toString
()));
listMap
.
put
(
"capitalColumnName"
,
StringUtils
.
toCapitalizeCamelCase
(
column
.
getColumnName
().
toString
()));
list
.
add
(
listMap
);
}
map
.
put
(
"columns"
,
list
);
TemplateEngine
engine
=
TemplateUtil
.
createEngine
(
new
TemplateConfig
(
"template"
,
TemplateConfig
.
ResourceMode
.
CLASSPATH
));
// 生成后端代码
List
<
String
>
templates
=
getAdminTemplateNames
();
for
(
String
templateName
:
templates
)
{
Template
template
=
engine
.
getTemplate
(
"generator/admin/"
+
templateName
+
".ftl"
);
String
filePath
=
getAdminFilePath
(
templateName
,
genConfig
,
className
);
File
file
=
new
File
(
filePath
);
// 如果非覆盖生成
if
(!
genConfig
.
getCover
()){
if
(
FileUtil
.
exist
(
file
)){
continue
;
}
}
// 生成代码
genFile
(
file
,
template
,
map
);
}
// 生成前端代码
templates
=
getFrontTemplateNames
();
for
(
String
templateName
:
templates
)
{
Template
template
=
engine
.
getTemplate
(
"generator/front/"
+
templateName
+
".ftl"
);
String
filePath
=
getFrontFilePath
(
templateName
,
genConfig
,
map
.
get
(
"changeClassName"
).
toString
());
File
file
=
new
File
(
filePath
);
// 如果非覆盖生成
if
(!
genConfig
.
getCover
()){
if
(
FileUtil
.
exist
(
file
)){
continue
;
}
}
// 生成代码
genFile
(
file
,
template
,
map
);
}
}
/**
* 定义后端文件路径以及名称
*/
public
static
String
getAdminFilePath
(
String
templateName
,
GenConfig
genConfig
,
String
className
)
{
String
ProjectPath
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
genConfig
.
getModuleName
();
String
packagePath
=
ProjectPath
+
File
.
separator
+
"src"
+
File
.
separator
+
"main"
+
File
.
separator
+
"java"
+
File
.
separator
;
if
(!
ObjectUtils
.
isEmpty
(
genConfig
.
getPack
()))
{
packagePath
+=
genConfig
.
getPack
().
replace
(
"."
,
File
.
separator
)
+
File
.
separator
;
}
if
(
"Entity"
.
equals
(
templateName
))
{
return
packagePath
+
"domain"
+
File
.
separator
+
className
+
".java"
;
}
if
(
"Controller"
.
equals
(
templateName
))
{
return
packagePath
+
"rest"
+
File
.
separator
+
className
+
"Controller.java"
;
}
if
(
"Service"
.
equals
(
templateName
))
{
return
packagePath
+
"service"
+
File
.
separator
+
className
+
"Service.java"
;
}
if
(
"ServiceImpl"
.
equals
(
templateName
))
{
return
packagePath
+
"service"
+
File
.
separator
+
"impl"
+
File
.
separator
+
className
+
"ServiceImpl.java"
;
}
if
(
"Dto"
.
equals
(
templateName
))
{
return
packagePath
+
"service"
+
File
.
separator
+
"dto"
+
File
.
separator
+
className
+
"DTO.java"
;
}
if
(
"Mapper"
.
equals
(
templateName
))
{
return
packagePath
+
"service"
+
File
.
separator
+
"mapper"
+
File
.
separator
+
className
+
"Mapper.java"
;
}
if
(
"QueryService"
.
equals
(
templateName
))
{
return
packagePath
+
"service"
+
File
.
separator
+
"query"
+
File
.
separator
+
className
+
"QueryService.java"
;
}
if
(
"Repository"
.
equals
(
templateName
))
{
return
packagePath
+
"repository"
+
File
.
separator
+
className
+
"Repository.java"
;
}
return
null
;
}
/**
* 定义前端文件路径以及名称
*/
public
static
String
getFrontFilePath
(
String
templateName
,
GenConfig
genConfig
,
String
apiName
)
{
String
path
=
genConfig
.
getPath
();
if
(
"api"
.
equals
(
templateName
))
{
return
genConfig
.
getApiPath
()
+
File
.
separator
+
apiName
+
".js"
;
}
if
(
"index"
.
equals
(
templateName
))
{
return
path
+
File
.
separator
+
"index.vue"
;
}
if
(
"header"
.
equals
(
templateName
))
{
return
path
+
File
.
separator
+
"module"
+
File
.
separator
+
"header.vue"
;
}
if
(
"edit"
.
equals
(
templateName
))
{
return
path
+
File
.
separator
+
"module"
+
File
.
separator
+
"edit.vue"
;
}
if
(
"eForm"
.
equals
(
templateName
))
{
return
path
+
File
.
separator
+
"module"
+
File
.
separator
+
"form.vue"
;
}
return
null
;
}
public
static
void
genFile
(
File
file
,
Template
template
,
Map
<
String
,
Object
>
map
)
throws
IOException
{
// 生成目标文件
Writer
writer
=
null
;
try
{
FileUtil
.
touch
(
file
);
writer
=
new
FileWriter
(
file
);
template
.
render
(
map
,
writer
);
}
catch
(
TemplateException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
writer
.
close
();
}
}
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
FileUtil
.
exist
(
"E:\\1.5.txt"
));
}
}
eladmin-logging/eladmin-logging.iml
0 → 100644
View file @
8c4fd97e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
</facet>
<facet
type=
"web"
name=
"Web"
>
<configuration>
<webroots
/>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"module"
module-name=
"eladmin-common"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-aop:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.aspectj:aspectjweaver:1.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.zaxxer:HikariCP:3.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jdbc:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.transaction:javax.transaction-api:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.xml.bind:jaxb-api:2.3.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:javax.activation-api:1.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate:hibernate-core:5.3.7.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss.logging:jboss-logging:3.3.2.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.persistence:javax.persistence-api:2.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.javassist:javassist:3.23.1-GA"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: net.bytebuddy:byte-buddy:1.9.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: antlr:antlr:2.7.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss:jandex:2.0.5.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.dom4j:dom4j:2.1.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.common:hibernate-commons-annotations:5.0.4.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-jpa:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-commons:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-orm:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-tx:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-beans:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aspects:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-web:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-logging:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-classic:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-core:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-api:2.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:jul-to-slf4j:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.annotation:javax.annotation-api:1.3.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"RUNTIME"
name=
"Maven: org.yaml:snakeyaml:1.23"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-json:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-core:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.validator:hibernate-validator:6.0.13.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.validation:validation-api:2.0.1.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-web:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-webmvc:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-expression:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-starter-test:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.jayway.jsonpath:json-path:2.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:json-smart:2.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:accessors-smart:1.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.ow2.asm:asm:5.0.4"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.assertj:assertj-core:3.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.mockito:mockito-core:2.23.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy-agent:1.9.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.objenesis:objenesis:2.6"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-library:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.skyscreamer:jsonassert:1.5.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-core:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework:spring-test:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.xmlunit:xmlunit-core:2.6.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-security:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aop:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-config:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-core:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-web:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-cache:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context-support:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-redis:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-keyvalue:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-oxm:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: redis.clients:jedis:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-pool2:2.5.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-lang3:3.8.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger2:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-annotations:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-models:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spi:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-core:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-schema:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-common:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spring-web:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.guava:guava:20.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml:classmate:1.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-ui:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"RUNTIME"
name=
"Maven: mysql:mysql-connector-java:8.0.13"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:druid-spring-boot-starter:1.1.10"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:druid:1.1.10"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.projectlombok:lombok:1.18.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: cn.hutool:hutool-all:4.4.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:fastjson:1.2.54"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct-jdk8:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"PROVIDED"
name=
"Maven: org.mapstruct:mapstruct-processor:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.inject:javax.inject:1"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
eladmin-logging/pom.xml
0 → 100644
View file @
8c4fd97e
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
eladmin
</artifactId>
<groupId>
me.zhengjie
</groupId>
<version>
1.5
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
eladmin-logging
</artifactId>
<dependencies>
<dependency>
<groupId>
me.zhengjie
</groupId>
<artifactId>
eladmin-common
</artifactId>
<version>
1.5
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/me/zhengjie/
common/
aop/log/Log.java
→
eladmin-logging/
src/main/java/me/zhengjie/aop/log/Log.java
View file @
8c4fd97e
package
me.zhengjie.
common.
aop.log
;
package
me.zhengjie.aop.log
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
...
...
@@ -12,5 +12,5 @@ import java.lang.annotation.Target;
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
Log
{
String
description
()
default
""
;
String
value
()
default
""
;
}
src/main/java/me/zhengjie/
common/aop/log
/LogAspect.java
→
eladmin-logging/
src/main/java/me/zhengjie/
aspect
/LogAspect.java
View file @
8c4fd97e
package
me.zhengjie.
common.aop.log
;
package
me.zhengjie.
aspect
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.
c
om
mon.exception.BadRequestException
;
import
me.zhengjie.
common.utils.ThrowableUtil
;
import
me.zhengjie.
monitor.domain.Logging
;
import
me.zhengjie.
monitor.service.LoggingService
;
import
me.zhengjie.
d
om
ain.Log
;
import
me.zhengjie.
exception.BadRequestException
;
import
me.zhengjie.
service.LogService
;
import
me.zhengjie.
utils.ThrowableUtil
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.AfterThrowing
;
...
...
@@ -14,9 +14,6 @@ import org.aspectj.lang.annotation.Pointcut;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
/**
* @author jie
* @date 2018-11-24
...
...
@@ -27,14 +24,14 @@ import java.io.StringWriter;
public
class
LogAspect
{
@Autowired
private
Log
ging
Service
log
ging
Service
;
private
LogService
logService
;
private
long
currentTime
=
0L
;
/**
* 配置切入点
*/
@Pointcut
(
"@annotation(me.zhengjie.
common.
aop.log.Log)"
)
@Pointcut
(
"@annotation(me.zhengjie.aop.log.Log)"
)
public
void
logPointcut
()
{
// 该方法无方法体,主要为了让同类中其他方法使用此切入点
}
...
...
@@ -53,8 +50,8 @@ public class LogAspect {
}
catch
(
Throwable
e
)
{
throw
new
BadRequestException
(
e
.
getMessage
());
}
Log
ging
loggin
g
=
new
Log
ging
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
log
ging
Service
.
save
(
joinPoint
,
log
ging
);
Log
lo
g
=
new
Log
(
"INFO"
,
System
.
currentTimeMillis
()
-
currentTime
);
logService
.
save
(
joinPoint
,
log
);
return
result
;
}
...
...
@@ -66,8 +63,8 @@ public class LogAspect {
*/
@AfterThrowing
(
pointcut
=
"logPointcut()"
,
throwing
=
"e"
)
public
void
logAfterThrowing
(
JoinPoint
joinPoint
,
Throwable
e
)
{
Log
ging
loggin
g
=
new
Log
ging
(
"ERROR"
,
System
.
currentTimeMillis
()
-
currentTime
);
log
ging
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
));
log
ging
Service
.
save
((
ProceedingJoinPoint
)
joinPoint
,
log
ging
);
Log
lo
g
=
new
Log
(
"ERROR"
,
System
.
currentTimeMillis
()
-
currentTime
);
log
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
));
logService
.
save
((
ProceedingJoinPoint
)
joinPoint
,
log
);
}
}
src/main/java/me/zhengjie/
monitor/
domain/Log
ging
.java
→
eladmin-logging/
src/main/java/me/zhengjie/domain/Log.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
domain
;
package
me.zhengjie.domain
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -14,7 +14,7 @@ import java.sql.Timestamp;
@Data
@Table
(
name
=
"log"
)
@NoArgsConstructor
public
class
Log
ging
{
public
class
Log
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
@@ -44,11 +44,13 @@ public class Logging {
/**
* 日志类型
*/
@Column
(
name
=
"log_type"
)
private
String
logType
;
/**
* 请求ip
*/
@Column
(
name
=
"request_ip"
)
private
String
requestIp
;
/**
...
...
@@ -59,16 +61,17 @@ public class Logging {
/**
* 异常详细
*/
@Column
(
columnDefinition
=
"text"
)
@Column
(
name
=
"exception_detail"
,
columnDefinition
=
"text"
)
private
String
exceptionDetail
;
/**
* 创建日期
*/
@CreationTimestamp
@Column
(
name
=
"create_time"
)
private
Timestamp
createTime
;
public
Log
ging
(
String
logType
,
Long
time
)
{
public
Log
(
String
logType
,
Long
time
)
{
this
.
logType
=
logType
;
this
.
time
=
time
;
}
...
...
src/main/java/me/zhengjie/
monitor/
repository/Log
ging
Repository.java
→
eladmin-logging/
src/main/java/me/zhengjie/repository/LogRepository.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
repository
;
package
me.zhengjie.repository
;
import
me.zhengjie.
monitor.
domain.Log
ging
;
import
me.zhengjie.domain.Log
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
...
...
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Repository;
* @date 2018-11-24
*/
@Repository
public
interface
Log
ging
Repository
extends
JpaRepository
<
Log
ging
,
Long
>,
JpaSpecificationExecutor
{
public
interface
LogRepository
extends
JpaRepository
<
Log
,
Long
>,
JpaSpecificationExecutor
{
/**
* 获取一个时间段的IP记录
...
...
@@ -19,6 +19,6 @@ public interface LoggingRepository extends JpaRepository<Logging,Long>, JpaSpeci
* @param date2
* @return
*/
@Query
(
value
=
"select count(*) FROM (select request
I
p FROM log where create
T
ime between ?1 and ?2 GROUP BY request
I
p) as s"
,
nativeQuery
=
true
)
@Query
(
value
=
"select count(*) FROM (select request
_i
p FROM log where create
_t
ime between ?1 and ?2 GROUP BY request
_i
p) as s"
,
nativeQuery
=
true
)
Long
findIp
(
String
date1
,
String
date2
);
}
src/main/java/me/zhengjie/
monitor/
rest/Log
ging
Controller.java
→
eladmin-logging/
src/main/java/me/zhengjie/rest/LogController.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
rest
;
package
me.zhengjie.rest
;
import
me.zhengjie.
monitor.
domain.Log
ging
;
import
me.zhengjie.
monitor.
service.query.Log
ging
QueryService
;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.service.query.LogQueryService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -17,14 +17,22 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping
(
"api"
)
public
class
Log
ging
Controller
{
public
class
LogController
{
@Autowired
private
Log
ging
QueryService
log
ging
QueryService
;
private
LogQueryService
logQueryService
;
@GetMapping
(
value
=
"logs"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER')"
)
public
ResponseEntity
getLogs
(
Logging
logging
,
Pageable
pageable
){
return
new
ResponseEntity
(
loggingQueryService
.
queryAll
(
logging
,
pageable
),
HttpStatus
.
OK
);
@GetMapping
(
value
=
"/logs"
)
@PreAuthorize
(
"hasAnyRole('ADMIN')"
)
public
ResponseEntity
getLogs
(
Log
log
,
Pageable
pageable
){
log
.
setLogType
(
"INFO"
);
return
new
ResponseEntity
(
logQueryService
.
queryAll
(
log
,
pageable
),
HttpStatus
.
OK
);
}
@GetMapping
(
value
=
"/logs/error"
)
@PreAuthorize
(
"hasAnyRole('ADMIN')"
)
public
ResponseEntity
getErrorLogs
(
Log
log
,
Pageable
pageable
){
log
.
setLogType
(
"ERROR"
);
return
new
ResponseEntity
(
logQueryService
.
queryAll
(
log
,
pageable
),
HttpStatus
.
OK
);
}
}
src/main/java/me/zhengjie/
monitor/
service/Log
ging
Service.java
→
eladmin-logging/
src/main/java/me/zhengjie/service/LogService.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
service
;
package
me.zhengjie.service
;
import
me.zhengjie.
monitor.
domain.Log
ging
;
import
me.zhengjie.domain.Log
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.springframework.scheduling.annotation.Async
;
...
...
@@ -8,13 +8,13 @@ import org.springframework.scheduling.annotation.Async;
* @author jie
* @date 2018-11-24
*/
public
interface
Log
ging
Service
{
public
interface
LogService
{
/**
* 新增日志
* @param joinPoint
* @param log
ging
* @param log
*/
@Async
void
save
(
ProceedingJoinPoint
joinPoint
,
Log
ging
loggin
g
);
void
save
(
ProceedingJoinPoint
joinPoint
,
Log
lo
g
);
}
src/main/java/me/zhengjie/
monitor/
service/impl/Log
ging
ServiceImpl.java
→
eladmin-logging/
src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
service.impl
;
package
me.zhengjie.service.impl
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
me.zhengjie.common.utils.IpUtil
;
import
me.zhengjie.common.utils.RequestHolder
;
import
me.zhengjie.core.security.AuthorizationUser
;
import
me.zhengjie.core.utils.JwtTokenUtil
;
import
me.zhengjie.monitor.domain.Logging
;
import
me.zhengjie.monitor.repository.LoggingRepository
;
import
me.zhengjie.monitor.service.LoggingService
;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.repository.LogRepository
;
import
me.zhengjie.service.LogService
;
import
me.zhengjie.utils.RequestHolder
;
import
me.zhengjie.utils.SecurityContextHolder
;
import
me.zhengjie.utils.StringUtils
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
...
...
@@ -27,32 +24,29 @@ import java.lang.reflect.Method;
*/
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
Log
ging
ServiceImpl
implements
Log
ging
Service
{
public
class
LogServiceImpl
implements
LogService
{
@Autowired
private
Log
ging
Repository
log
ging
Repository
;
private
LogRepository
logRepository
;
@Value
(
"${jwt.header}"
)
private
String
tokenHeader
;
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
private
final
String
LOGINPATH
=
"authenticationLogin"
;
private
final
String
LOGINPATH
=
"login"
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
save
(
ProceedingJoinPoint
joinPoint
,
Log
ging
loggin
g
){
public
void
save
(
ProceedingJoinPoint
joinPoint
,
Log
lo
g
){
// 获取request
HttpServletRequest
request
=
RequestHolder
.
getHttpServletRequest
();
MethodSignature
signature
=
(
MethodSignature
)
joinPoint
.
getSignature
();
Method
method
=
signature
.
getMethod
();
me
.
zhengjie
.
common
.
aop
.
log
.
Log
l
og
=
method
.
getAnnotation
(
me
.
zhengjie
.
common
.
aop
.
log
.
Log
.
class
);
me
.
zhengjie
.
aop
.
log
.
Log
aopL
og
=
method
.
getAnnotation
(
me
.
zhengjie
.
aop
.
log
.
Log
.
class
);
// 描述
if
(
log
!=
null
)
{
log
ging
.
setDescription
(
log
.
description
());
log
.
setDescription
(
aopLog
.
value
());
}
// 方法路径
...
...
@@ -73,19 +67,22 @@ public class LoggingServiceImpl implements LoggingService {
}
// 获取IP地址
log
ging
.
setRequestIp
(
Ip
Util
.
getIP
(
request
));
log
.
setRequestIp
(
String
Util
s
.
getIP
(
request
));
if
(!
LOGINPATH
.
equals
(
signature
.
getName
())){
UserDetails
userDetails
=
(
UserDetails
)
SecurityContextHolder
.
get
Context
().
getAuthentication
().
getPrincipal
();
UserDetails
userDetails
=
SecurityContextHolder
.
get
UserDetails
();
username
=
userDetails
.
getUsername
();
}
else
{
AuthorizationUser
user
=
JSONUtil
.
toBean
(
new
JSONObject
(
argValues
[
0
]),
AuthorizationUser
.
class
);
username
=
user
.
getUsername
();
try
{
JSONObject
jsonObject
=
new
JSONObject
(
argValues
[
0
]);
username
=
jsonObject
.
get
(
"username"
).
toString
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
log
ging
.
setMethod
(
methodName
);
log
ging
.
setUsername
(
username
);
log
ging
.
setParams
(
params
+
" }"
);
log
ging
Repository
.
save
(
log
ging
);
log
.
setMethod
(
methodName
);
log
.
setUsername
(
username
);
log
.
setParams
(
params
+
" }"
);
logRepository
.
save
(
log
);
}
}
src/main/java/me/zhengjie/
monitor/
service/query/Log
ging
QueryService.java
→
eladmin-logging/
src/main/java/me/zhengjie/service/query/LogQueryService.java
View file @
8c4fd97e
package
me.zhengjie.
monitor.
service.query
;
package
me.zhengjie.service.query
;
import
me.zhengjie.
monitor.
domain.Log
ging
;
import
me.zhengjie.
monitor.
repository.Log
ging
Repository
;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.repository.LogRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
...
...
@@ -23,41 +23,35 @@ import java.util.List;
*/
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
readOnly
=
true
,
rollbackFor
=
Exception
.
class
)
public
class
Log
ging
QueryService
{
public
class
LogQueryService
{
@Autowired
private
Log
ging
Repository
log
ging
Repository
;
private
LogRepository
logRepository
;
public
Page
queryAll
(
Logging
logging
,
Pageable
pageable
){
return
loggingRepository
.
findAll
(
new
Spec
(
logging
),
pageable
);
}
public
List
queryAll
(
Logging
logging
){
return
loggingRepository
.
findAll
(
new
Spec
(
logging
));
public
Page
queryAll
(
Log
log
,
Pageable
pageable
){
return
logRepository
.
findAll
(
new
Spec
(
log
),
pageable
);
}
class
Spec
implements
Specification
<
Log
ging
>
{
class
Spec
implements
Specification
<
Log
>
{
private
Log
ging
loggin
g
;
private
Log
lo
g
;
public
Spec
(
Log
ging
loggin
g
){
this
.
log
ging
=
log
ging
;
public
Spec
(
Log
lo
g
){
this
.
log
=
log
;
}
@Override
public
Predicate
toPredicate
(
Root
<
Log
ging
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
cb
)
{
public
Predicate
toPredicate
(
Root
<
Log
>
root
,
CriteriaQuery
<?>
criteriaQuery
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
list
=
new
ArrayList
<
Predicate
>();
if
(!
ObjectUtils
.
isEmpty
(
log
ging
.
getUsername
())){
list
.
add
(
cb
.
like
(
root
.
get
(
"username"
).
as
(
String
.
class
),
"%"
+
log
ging
.
getUsername
()+
"%"
));
if
(!
ObjectUtils
.
isEmpty
(
log
.
getUsername
())){
list
.
add
(
cb
.
like
(
root
.
get
(
"username"
).
as
(
String
.
class
),
"%"
+
log
.
getUsername
()+
"%"
));
}
if
(!
ObjectUtils
.
isEmpty
(
log
ging
.
getLogType
()))
{
list
.
add
(
cb
.
equal
(
root
.
get
(
"logType"
).
as
(
String
.
class
),
log
ging
.
getLogType
()));
if
(!
ObjectUtils
.
isEmpty
(
log
.
getLogType
()))
{
list
.
add
(
cb
.
equal
(
root
.
get
(
"logType"
).
as
(
String
.
class
),
log
.
getLogType
()));
}
Predicate
[]
p
=
new
Predicate
[
list
.
size
()];
...
...
eladmin-system/eladmin-system.iml
0 → 100644
View file @
8c4fd97e
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration
/>
</facet>
<facet
type=
"web"
name=
"Web"
>
<configuration>
<webroots
/>
<sourceRoots>
<root
url=
"file://$MODULE_DIR$/src/main/java"
/>
<root
url=
"file://$MODULE_DIR$/src/main/resources"
/>
<root
url=
"file://$MODULE_DIR$/target/generated-sources/annotations"
/>
</sourceRoots>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/resources"
type=
"java-resource"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/target/generated-sources/annotations"
isTestSource=
"false"
generated=
"true"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"module"
module-name=
"eladmin-generator"
/>
<orderEntry
type=
"module"
module-name=
"eladmin-common"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-freemarker:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.freemarker:freemarker:2.3.28"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-configuration:commons-configuration:1.9"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-lang:commons-lang:2.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-logging:commons-logging:1.1.1"
level=
"project"
/>
<orderEntry
type=
"module"
module-name=
"eladmin-tools"
/>
<orderEntry
type=
"module"
module-name=
"eladmin-logging"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.mail:mail:1.4.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:activation:1.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.qiniu:qiniu-java-sdk:7.2.18"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.squareup.okhttp3:okhttp:3.11.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.squareup.okio:okio:1.14.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.code.gson:gson:2.8.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alipay.sdk:alipay-sdk-java:3.1.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.jsonwebtoken:jjwt:0.9.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.core:jackson-core:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-websocket:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-messaging:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-beans:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-websocket:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.quartz-scheduler:quartz:2.3.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.mchange:mchange-commons-java:0.2.11"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-aop:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.aspectj:aspectjweaver:1.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.zaxxer:HikariCP:3.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jdbc:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.transaction:javax.transaction-api:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.xml.bind:jaxb-api:2.3.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:javax.activation-api:1.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate:hibernate-core:5.3.7.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss.logging:jboss-logging:3.3.2.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.persistence:javax.persistence-api:2.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.javassist:javassist:3.23.1-GA"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: net.bytebuddy:byte-buddy:1.9.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: antlr:antlr:2.7.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.jboss:jandex:2.0.5.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.dom4j:dom4j:2.1.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.common:hibernate-commons-annotations:5.0.4.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-jpa:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-commons:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-orm:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-tx:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aspects:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-web:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-logging:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-classic:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: ch.qos.logback:logback-core:1.2.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.logging.log4j:log4j-api:2.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:jul-to-slf4j:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.annotation:javax.annotation-api:1.3.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"RUNTIME"
name=
"Maven: org.yaml:snakeyaml:1.23"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-json:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hibernate.validator:hibernate-validator:6.0.13.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.validation:validation-api:2.0.1.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-web:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-webmvc:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-expression:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-starter-test:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.jayway.jsonpath:json-path:2.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:json-smart:2.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.minidev:accessors-smart:1.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.ow2.asm:asm:5.0.4"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.assertj:assertj-core:3.11.1"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.mockito:mockito-core:2.23.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy-agent:1.9.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.objenesis:objenesis:2.6"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-library:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.skyscreamer:jsonassert:1.5.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-core:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.springframework:spring-test:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.xmlunit:xmlunit-core:2.6.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-security:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aop:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-config:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-core:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.security:spring-security-web:5.1.1.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-cache:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context-support:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-redis:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.data:spring-data-keyvalue:2.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-oxm:5.1.2.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: redis.clients:jedis:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-pool2:2.5.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-lang3:3.8.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger2:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-annotations:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.swagger:swagger-models:1.5.20"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spi:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-core:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-schema:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-common:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-spring-web:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.guava:guava:20.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.fasterxml:classmate:1.4.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: io.springfox:springfox-swagger-ui:2.9.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"RUNTIME"
name=
"Maven: mysql:mysql-connector-java:8.0.13"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:druid-spring-boot-starter:1.1.10"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:druid:1.1.10"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.0.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.projectlombok:lombok:1.18.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: cn.hutool:hutool-all:4.4.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:fastjson:1.2.54"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mapstruct:mapstruct-jdk8:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"PROVIDED"
name=
"Maven: org.mapstruct:mapstruct-processor:1.2.0.Final"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.inject:javax.inject:1"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
eladmin-system/pom.xml
0 → 100644
View file @
8c4fd97e
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
eladmin
</artifactId>
<groupId>
me.zhengjie
</groupId>
<version>
1.5
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
eladmin-system
</artifactId>
<properties>
<jjwt.version>
0.9.1
</jjwt.version>
</properties>
<dependencies>
<dependency>
<groupId>
me.zhengjie
</groupId>
<artifactId>
eladmin-generator
</artifactId>
<version>
1.5
</version>
</dependency>
<dependency>
<groupId>
me.zhengjie
</groupId>
<artifactId>
eladmin-tools
</artifactId>
<version>
1.5
</version>
</dependency>
<!--jwt-->
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
${jjwt.version}
</version>
</dependency>
<!--websocket-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-websocket
</artifactId>
</dependency>
<!-- quartz -->
<dependency>
<groupId>
org.quartz-scheduler
</groupId>
<artifactId>
quartz
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<configuration>
<skipTests>
true
</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
sql/eladmin.sql
→
eladmin-system/
sql/eladmin.sql
View file @
8c4fd97e
This diff is collapsed.
Click to expand it.
src/main/java/me/zhengjie/AppRun.java
→
eladmin-system/
src/main/java/me/zhengjie/AppRun.java
View file @
8c4fd97e
package
me.zhengjie
;
import
me.zhengjie.
common.
utils.SpringContextHolder
;
import
me.zhengjie.utils.SpringContextHolder
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.Bean
;
...
...
src/main/java/me/zhengjie/
core/
config/Co
rsCo
nfig.java
→
eladmin-system/
src/main/java/me/zhengjie/config/Config
urerAdapter
.java
View file @
8c4fd97e
package
me.zhengjie.
core.
config
;
package
me.zhengjie.config
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.config.annotation.CorsRegistry
;
...
...
@@ -7,27 +7,23 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
/**
*
跨域请求
*
WebMvcConfigurer
*
* @author jie
* @date 2018-11-30
*/
@Configuration
@EnableWebMvc
public
class
Co
rsCo
nfig
implements
WebMvcConfigurer
{
public
class
Config
urerAdapter
implements
WebMvcConfigurer
{
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
//设置允许跨域的路径
registry
.
addMapping
(
"/**"
)
//设置允许跨域请求的域名
.
allowedOrigins
(
"*"
)
//是否允许证书 不再默认开启
.
allowCredentials
(
true
)
//设置允许的方法
.
allowed
Method
s
(
"*"
)
//跨域允许时间
.
maxAge
(
3600
);
.
allowedHeaders
(
"*"
)
.
allowed
Origin
s
(
"*"
)
.
allowedMethods
(
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
);
}
@Override
...
...
src/main/java/me/zhengjie/monitor/config/LogFilter.java
→
eladmin-system/
src/main/java/me/zhengjie/
modules/
monitor/config/LogFilter.java
View file @
8c4fd97e
package
me.zhengjie.monitor.config
;
package
me.zhengjie.
modules.
monitor.config
;
import
ch.qos.logback.classic.spi.ILoggingEvent
;
import
ch.qos.logback.classic.spi.IThrowableProxy
;
import
ch.qos.logback.core.filter.Filter
;
import
ch.qos.logback.core.spi.FilterReply
;
import
me.zhengjie.monitor.domain.LogMessage
;
import
me.zhengjie.modules.monitor.domain.LogMessage
;
import
java.text.DateFormat
;
import
java.util.Date
;
...
...
src/main/java/me/zhengjie/monitor/config/LoggerQueue.java
→
eladmin-system/
src/main/java/me/zhengjie/
modules/
monitor/config/LoggerQueue.java
View file @
8c4fd97e
package
me.zhengjie.monitor.config
;
package
me.zhengjie.
modules.
monitor.config
;
import
me.zhengjie.monitor.domain.LogMessage
;
import
me.zhengjie.
modules.
monitor.domain.LogMessage
;
import
java.util.concurrent.BlockingQueue
;
import
java.util.concurrent.LinkedBlockingQueue
;
...
...
@@ -11,11 +11,15 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public
class
LoggerQueue
{
//队列大小
/**
* 队列大小
*/
public
static
final
int
QUEUE_MAX_SIZE
=
10000
;
private
static
LoggerQueue
alarmMessageQueue
=
new
LoggerQueue
();
//阻塞队列
/**
* 阻塞队列
*/
private
BlockingQueue
blockingQueue
=
new
LinkedBlockingQueue
<>(
QUEUE_MAX_SIZE
);
private
LoggerQueue
()
{
...
...
@@ -31,7 +35,7 @@ public class LoggerQueue {
* @return
*/
public
boolean
push
(
LogMessage
log
)
{
return
this
.
blockingQueue
.
add
(
log
);
//队列满了就抛出异常,不阻塞
return
this
.
blockingQueue
.
add
(
log
);
}
/**
...
...
Prev
1
2
3
4
5
6
7
…
10
Next
Write
Preview
Supports
Markdown
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