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
"src/git@ustchcs.com:gujinli1118/MCMS.git" did not exist on "fd764fdb4ec77668db4b71e1bc5da570f8794a2d"
Commit
8c4fd97e
authored
Jan 20, 2019
by
郑杰
Browse files
v1.5 beta版发布,详细查看发行版说明
parent
b066bb99
Changes
198
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/ListSortUtil.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.utils
;
import
java.lang.reflect.Method
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* List按照指定字段排序工具类
* @author jie
* @date 2018/08/23 20:03:12
* @param <T>
*/
public
class
ListSortUtil
<
T
>
{
/**
* @param targetList 目标排序List
* @param sortField 排序字段(实体类属性名)
* @param sortMode 排序方式(asc or desc)
*/
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
void
sort
(
List
<
T
>
targetList
,
final
String
sortField
,
final
String
sortMode
)
{
Collections
.
sort
(
targetList
,
new
Comparator
()
{
@Override
public
int
compare
(
Object
obj1
,
Object
obj2
)
{
int
retVal
=
0
;
try
{
//首字母转大写
String
newStr
=
sortField
.
substring
(
0
,
1
).
toUpperCase
()+
sortField
.
replaceFirst
(
"\\w"
,
""
);
String
methodStr
=
"get"
+
newStr
;
Method
method1
=
((
T
)
obj1
).
getClass
().
getMethod
(
methodStr
,
new
Class
[
0
]);
Method
method2
=
((
T
)
obj2
).
getClass
().
getMethod
(
methodStr
,
new
Class
[
0
]);
if
(
sortMode
!=
null
&&
"desc"
.
equals
(
sortMode
))
{
// 倒序
retVal
=
method2
.
invoke
(((
T
)
obj2
),
new
Object
[
0
]).
toString
().
compareTo
(
method1
.
invoke
(((
T
)
obj1
),
new
Object
[
0
]).
toString
());
}
else
{
// 正序
retVal
=
method1
.
invoke
(((
T
)
obj1
),
new
Object
[
0
]).
toString
().
compareTo
(
method2
.
invoke
(((
T
)
obj2
),
new
Object
[
0
]).
toString
());
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
();
}
return
retVal
;
}
});
}
}
\ No newline at end of file
src/main/java/me/zhengjie/
common/
utils/PageUtil.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/PageUtil.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -8,11 +8,10 @@ import java.util.Map;
...
@@ -8,11 +8,10 @@ import java.util.Map;
/**
/**
* 分页工具
* 分页工具
*
* @author jie
* @author jie
* @date 2018-12-10
* @date 2018-12-10
*/
*/
public
class
PageUtil
{
public
class
PageUtil
extends
cn
.
hutool
.
core
.
util
.
PageUtil
{
/**
/**
* List 分页
* List 分页
...
@@ -48,4 +47,18 @@ public class PageUtil {
...
@@ -48,4 +47,18 @@ public class PageUtil {
return
map
;
return
map
;
}
}
/**
* @param object
* @param totalElements
* @return
*/
public
static
Map
toPage
(
Object
object
,
Object
totalElements
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"content"
,
object
);
map
.
put
(
"totalElements"
,
totalElements
);
return
map
;
}
}
}
src/main/java/me/zhengjie/
common/
utils/RequestHolder.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/RequestHolder.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
...
...
eladmin-common/src/main/java/me/zhengjie/utils/SecurityContextHolder.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.utils
;
import
me.zhengjie.exception.BadRequestException
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.security.core.userdetails.UserDetails
;
/**
* 获取当前登录的用户名
*
* @author jie
* @date 2019-01-17
*/
public
class
SecurityContextHolder
{
public
static
UserDetails
getUserDetails
()
{
UserDetails
userDetails
=
null
;
try
{
userDetails
=
(
UserDetails
)
org
.
springframework
.
security
.
core
.
context
.
SecurityContextHolder
.
getContext
().
getAuthentication
().
getPrincipal
();
}
catch
(
Exception
e
)
{
throw
new
BadRequestException
(
HttpStatus
.
UNAUTHORIZED
,
"登录状态过期"
);
}
return
userDetails
;
}
}
src/main/java/me/zhengjie/
common/
utils/SpringContextHolder.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/SpringContextHolder.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.BeansException
;
...
...
src/main/java/me/zhengjie/
common/
utils/StringUtils.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/StringUtils.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
java.io.File
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
/**
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
...
@@ -13,38 +13,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -13,38 +13,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
String
CHARSET_NAME
=
"UTF-8"
;
private
static
final
String
CHARSET_NAME
=
"UTF-8"
;
/**
* 转换为字节数组
*
* @param str
* @return
*/
public
static
byte
[]
getBytes
(
String
str
)
{
if
(
str
!=
null
)
{
try
{
return
str
.
getBytes
(
CHARSET_NAME
);
}
catch
(
UnsupportedEncodingException
e
)
{
return
null
;
}
}
else
{
return
null
;
}
}
/**
* 转换为字节数组
*
* @param bytes
* @return
*/
public
static
String
toString
(
byte
[]
bytes
)
{
try
{
return
new
String
(
bytes
,
CHARSET_NAME
);
}
catch
(
UnsupportedEncodingException
e
)
{
return
EMPTY
;
}
}
/**
/**
* 是否包含字符串
* 是否包含字符串
*
*
...
@@ -63,41 +31,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -63,41 +31,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return
false
;
return
false
;
}
}
/**
* 转换为Double类型
*/
public
static
Double
toDouble
(
Object
val
)
{
if
(
val
==
null
)
{
return
0
D
;
}
try
{
return
Double
.
valueOf
(
trim
(
val
.
toString
()));
}
catch
(
Exception
e
)
{
return
0
D
;
}
}
/**
* 转换为Float类型
*/
public
static
Float
toFloat
(
Object
val
)
{
return
toDouble
(
val
).
floatValue
();
}
/**
* 转换为Long类型
*/
public
static
Long
toLong
(
Object
val
)
{
return
toDouble
(
val
).
longValue
();
}
/**
* 转换为Integer类型
*/
public
static
Integer
toInteger
(
Object
val
)
{
return
toLong
(
val
).
intValue
();
}
/**
/**
* 驼峰命名法工具
* 驼峰命名法工具
*
*
...
@@ -184,31 +117,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -184,31 +117,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
}
}
/**
/**
* 获取
工程路径
* 获取
ip地址
*
*
@param request
* @return
* @return
*/
*/
public
static
String
getProjectPath
()
{
public
static
String
getIP
(
HttpServletRequest
request
)
{
String
projectPath
=
""
;
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
try
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
File
file
=
new
DefaultResourceLoader
().
getResource
(
""
).
getFile
();
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
if
(
file
!=
null
)
{
}
while
(
true
)
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
File
f
=
new
File
(
file
.
getPath
()
+
File
.
separator
+
"src"
+
File
.
separator
+
"main"
);
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
if
(
f
==
null
||
f
.
exists
())
{
}
break
;
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
}
ip
=
request
.
getRemoteAddr
();
if
(
file
.
getParentFile
()
!=
null
)
{
}
file
=
file
.
getParentFile
();
return
"0:0:0:0:0:0:0:1"
.
equals
(
ip
)?
"127.0.0.1"
:
ip
;
}
else
{
}
break
;
}
/**
}
* 获得当天是周几
projectPath
=
file
.
toString
();
*/
}
public
static
String
getWeekDay
(){
}
catch
(
IOException
e
)
{
String
[]
weekDays
=
{
"Sun"
,
"Mon"
,
"Tue"
,
"Wed"
,
"Thu"
,
"Fri"
,
"Sat"
};
e
.
printStackTrace
();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
new
Date
());
int
w
=
cal
.
get
(
Calendar
.
DAY_OF_WEEK
)
-
1
;
if
(
w
<
0
){
w
=
0
;
}
}
return
projectPath
;
return
weekDays
[
w
]
;
}
}
}
}
\ No newline at end of file
src/main/java/me/zhengjie/
common/config
/ThreadPool
Config
.java
→
eladmin-common/
src/main/java/me/zhengjie/
utils
/ThreadPool
Util
.java
View file @
8c4fd97e
package
me.zhengjie.
common.config
;
package
me.zhengjie.
utils
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
...
@@ -10,7 +10,7 @@ import java.util.concurrent.*;
...
@@ -10,7 +10,7 @@ import java.util.concurrent.*;
* @date 2019-01-08
* @date 2019-01-08
*/
*/
@Configuration
@Configuration
public
class
ThreadPool
Config
{
public
class
ThreadPool
Util
{
@Bean
@Bean
public
ExecutorService
getThreadPool
(){
public
ExecutorService
getThreadPool
(){
...
...
src/main/java/me/zhengjie/
common/
utils/ThrowableUtil.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/ThrowableUtil.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
...
@@ -20,7 +20,7 @@ public class ThrowableUtil {
...
@@ -20,7 +20,7 @@ public class ThrowableUtil {
PrintWriter
pw
=
new
PrintWriter
(
sw
);
PrintWriter
pw
=
new
PrintWriter
(
sw
);
try
{
try
{
throwable
.
printStackTrace
(
pw
);
throwable
.
printStackTrace
(
pw
);
return
"\n"
+
sw
.
toString
();
return
sw
.
toString
();
}
finally
{
}
finally
{
pw
.
close
();
pw
.
close
();
}
}
...
...
src/main/java/me/zhengjie/
common/
utils/ValidationUtil.java
→
eladmin-common/
src/main/java/me/zhengjie/utils/ValidationUtil.java
View file @
8c4fd97e
package
me.zhengjie.
common.
utils
;
package
me.zhengjie.utils
;
import
me.zhengjie.
common.
exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
java.util.Optional
;
import
java.util.Optional
;
/**
/**
...
@@ -8,7 +8,7 @@ import java.util.Optional;
...
@@ -8,7 +8,7 @@ import java.util.Optional;
* @author jie
* @author jie
* @date 2018-11-23
* @date 2018-11-23
*/
*/
public
class
ValidationUtil
{
public
class
ValidationUtil
{
/**
/**
* 验证空
* 验证空
...
...
eladmin-generator/eladmin-generator.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-freemarker: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.freemarker:freemarker:2.3.28"
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:spring-beans:5.1.2.RELEASE"
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=
"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-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.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-generator/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-generator
</artifactId>
<properties>
<configuration.version>
1.9
</configuration.version>
</properties>
<dependencies>
<dependency>
<groupId>
me.zhengjie
</groupId>
<artifactId>
eladmin-common
</artifactId>
<version>
1.5
</version>
</dependency>
<!--模板引擎-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-freemarker
</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-configuration/commons-configuration -->
<dependency>
<groupId>
commons-configuration
</groupId>
<artifactId>
commons-configuration
</artifactId>
<version>
${configuration.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.domain
;
import
lombok.Data
;
import
javax.persistence.*
;
/**
* 代码生成配置
* @author jie
* @date 2019-01-03
*/
@Data
@Entity
@Table
(
name
=
"gen_config"
)
public
class
GenConfig
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/** 包路径 **/
private
String
pack
;
/** 模块名 **/
@Column
(
name
=
"module_name"
)
private
String
moduleName
;
/** 前端文件路径 **/
private
String
path
;
/** 前端文件路径 **/
@Column
(
name
=
"api_path"
)
private
String
apiPath
;
/** 作者 **/
private
String
author
;
/** 是否覆盖 **/
private
Boolean
cover
;
}
eladmin-generator/src/main/java/me/zhengjie/domain/vo/ColumnInfo.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.domain.vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* 列的数据信息
* @author jie
* @date 2019-01-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ColumnInfo
{
/** 数据库字段名称 **/
private
Object
columnName
;
/** 允许空值 **/
private
Object
isNullable
;
/** 数据库字段类型 **/
private
Object
columnType
;
/** 数据库字段注释 **/
private
Object
columnComment
;
/** 数据库字段键类型 **/
private
Object
columnKey
;
/** 查询 1:模糊 2:精确 **/
private
String
columnQuery
;
/** 是否在列表显示 **/
private
String
columnShow
;
}
eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.domain.vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* 表的数据信息
* @author jie
* @date 2019-01-02
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
TableInfo
{
/** 表名称 **/
private
Object
tableName
;
/** 创建日期 **/
private
Object
createTime
;
}
eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.repository
;
import
me.zhengjie.domain.GenConfig
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
* @author jie
* @date 2019-01-14
*/
public
interface
GenConfigRepository
extends
JpaRepository
<
GenConfig
,
Long
>
{
}
eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.rest
;
import
me.zhengjie.domain.GenConfig
;
import
me.zhengjie.service.GenConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* @author jie
* @date 2019-01-14
*/
@RestController
@RequestMapping
(
"api"
)
public
class
GenConfigController
{
@Autowired
private
GenConfigService
genConfigService
;
/**
* 查询生成器配置
* @return
*/
@GetMapping
(
value
=
"/genConfig"
)
public
ResponseEntity
get
(){
return
new
ResponseEntity
(
genConfigService
.
find
(),
HttpStatus
.
OK
);
}
@PutMapping
(
value
=
"/genConfig"
)
public
ResponseEntity
emailConfig
(
@Validated
@RequestBody
GenConfig
genConfig
){
return
new
ResponseEntity
(
genConfigService
.
update
(
genConfig
),
HttpStatus
.
OK
);
}
}
eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.rest
;
import
cn.hutool.core.util.PageUtil
;
import
me.zhengjie.domain.vo.ColumnInfo
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.service.GenConfigService
;
import
me.zhengjie.service.GeneratorService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* @author jie
* @date 2019-01-02
*/
@RestController
@RequestMapping
(
"api"
)
public
class
GeneratorController
{
@Autowired
private
GeneratorService
generatorService
;
@Autowired
private
GenConfigService
genConfigService
;
@Value
(
"${generator.enabled}"
)
private
Boolean
generatorEnabled
;
/**
* 查询数据库元数据
* @param name
* @param page
* @param size
* @return
*/
@GetMapping
(
value
=
"/generator/tables"
)
public
ResponseEntity
getTables
(
@RequestParam
(
defaultValue
=
""
)
String
name
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
size
){
int
[]
startEnd
=
PageUtil
.
transToStartEnd
(
page
+
1
,
size
);
return
new
ResponseEntity
(
generatorService
.
getTables
(
name
,
startEnd
),
HttpStatus
.
OK
);
}
/**
* 查询表内元数据
* @param tableName
* @return
*/
@GetMapping
(
value
=
"/generator/columns"
)
public
ResponseEntity
getTables
(
@RequestParam
String
tableName
){
return
new
ResponseEntity
(
generatorService
.
getColumns
(
tableName
),
HttpStatus
.
OK
);
}
/**
* 生成代码
* @param columnInfos
* @return
*/
@PostMapping
(
value
=
"/generator"
)
public
ResponseEntity
generator
(
@RequestBody
List
<
ColumnInfo
>
columnInfos
,
@RequestParam
String
tableName
){
if
(!
generatorEnabled
){
throw
new
BadRequestException
(
"此环境不允许生成代码!"
);
}
generatorService
.
generator
(
columnInfos
,
genConfigService
.
find
(),
tableName
);
return
new
ResponseEntity
(
HttpStatus
.
OK
);
}
}
eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.service
;
import
me.zhengjie.domain.GenConfig
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CachePut
;
import
org.springframework.cache.annotation.Cacheable
;
/**
* @author jie
* @date 2019-01-14
*/
@CacheConfig
(
cacheNames
=
"genConfig"
)
public
interface
GenConfigService
{
/**
* find
* @return
*/
@Cacheable
(
key
=
"'1'"
)
GenConfig
find
();
/**
* update
* @param genConfig
*/
@CachePut
(
key
=
"'1'"
)
GenConfig
update
(
GenConfig
genConfig
);
}
eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.service
;
import
me.zhengjie.domain.GenConfig
;
import
me.zhengjie.domain.vo.ColumnInfo
;
import
java.util.List
;
/**
* @author jie
* @date 2019-01-02
*/
public
interface
GeneratorService
{
/**
* 查询数据库元数据
* @param name
* @param startEnd
* @return
*/
Object
getTables
(
String
name
,
int
[]
startEnd
);
/**
* 得到数据表的元数据
* @param name
* @return
*/
Object
getColumns
(
String
name
);
/**
* 生成代码
* @param columnInfos
* @param genConfig
* @param tableName
*/
void
generator
(
List
<
ColumnInfo
>
columnInfos
,
GenConfig
genConfig
,
String
tableName
);
}
eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java
0 → 100644
View file @
8c4fd97e
package
me.zhengjie.service.impl
;
import
me.zhengjie.domain.GenConfig
;
import
me.zhengjie.repository.GenConfigRepository
;
import
me.zhengjie.service.GenConfigService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Optional
;
/**
* @author jie
* @date 2019-01-14
*/
@Service
public
class
GenConfigServiceImpl
implements
GenConfigService
{
@Autowired
private
GenConfigRepository
genConfigRepository
;
@Override
public
GenConfig
find
()
{
Optional
<
GenConfig
>
genConfig
=
genConfigRepository
.
findById
(
1L
);
if
(
genConfig
.
isPresent
()){
return
genConfig
.
get
();
}
else
{
return
new
GenConfig
();
}
}
@Override
public
GenConfig
update
(
GenConfig
genConfig
)
{
genConfig
.
setId
(
1L
);
return
genConfigRepository
.
save
(
genConfig
);
}
}
Prev
1
2
3
4
5
6
…
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