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
e4ca7afc
"eladmin-common/src/main/vscode:/vscode.git/clone" did not exist on "7a2fbae8b6c0f9eb6dab7dc91b435c967b2faa8e"
Commit
e4ca7afc
authored
Nov 25, 2019
by
dqjdda
Browse files
阿里巴巴代码规范
parent
6d941c09
Changes
160
Show whitespace changes
Inline
Side-by-side
eladmin-common/pom.xml
View file @
e4ca7afc
...
@@ -8,7 +8,19 @@
...
@@ -8,7 +8,19 @@
<version>
2.3
</version>
<version>
2.3
</version>
</parent>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<properties>
<hutool.version>
[4.1.12,)
</hutool.version>
</properties>
<artifactId>
eladmin-common
</artifactId>
<artifactId>
eladmin-common
</artifactId>
<name>
公共模块
</name>
<name>
公共模块
</name>
<dependencies>
<!--工具包-->
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
${hutool.version}
</version>
</dependency>
</dependencies>
</project>
</project>
\ No newline at end of file
eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java
View file @
e4ca7afc
...
@@ -19,6 +19,9 @@ import org.springframework.stereotype.Component;
...
@@ -19,6 +19,9 @@ import org.springframework.stereotype.Component;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
/**
* @author /
*/
@Aspect
@Aspect
@Component
@Component
public
class
LimitAspect
{
public
class
LimitAspect
{
...
...
eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java
View file @
e4ca7afc
...
@@ -18,4 +18,13 @@ public class BaseDTO implements Serializable {
...
@@ -18,4 +18,13 @@ public class BaseDTO implements Serializable {
private
Timestamp
createTime
;
private
Timestamp
createTime
;
private
Timestamp
updateTime
;
private
Timestamp
updateTime
;
@Override
public
String
toString
()
{
return
"BaseDTO{"
+
"isDelete="
+
isDelete
+
", createTime="
+
createTime
+
", updateTime="
+
updateTime
+
'}'
;
}
}
}
eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java
View file @
e4ca7afc
...
@@ -19,7 +19,7 @@ import java.lang.reflect.Field;
...
@@ -19,7 +19,7 @@ import java.lang.reflect.Field;
@MappedSuperclass
@MappedSuperclass
public
class
BaseEntity
implements
Serializable
{
public
class
BaseEntity
implements
Serializable
{
/
/
删除标识
/
**
删除标识
**/
@Column
(
name
=
"is_delete"
,
columnDefinition
=
"bit default 0"
)
@Column
(
name
=
"is_delete"
,
columnDefinition
=
"bit default 0"
)
private
Boolean
isDelete
=
false
;
private
Boolean
isDelete
=
false
;
...
...
eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java
View file @
e4ca7afc
...
@@ -10,21 +10,29 @@ public interface BaseMapper<D, E> {
...
@@ -10,21 +10,29 @@ public interface BaseMapper<D, E> {
/**
/**
* DTO转Entity
* DTO转Entity
* @param dto /
* @return /
*/
*/
E
toEntity
(
D
dto
);
E
toEntity
(
D
dto
);
/**
/**
* Entity转DTO
* Entity转DTO
* @param entity /
* @return /
*/
*/
D
toDto
(
E
entity
);
D
toDto
(
E
entity
);
/**
/**
* DTO集合转Entity集合
* DTO集合转Entity集合
* @param dtoList /
* @return /
*/
*/
List
<
E
>
toEntity
(
List
<
D
>
dtoList
);
List
<
E
>
toEntity
(
List
<
D
>
dtoList
);
/**
/**
* Entity集合转DTO集合
* Entity集合转DTO集合
* @param entityList /
* @return /
*/
*/
List
<
D
>
toDto
(
List
<
E
>
entityList
);
List
<
D
>
toDto
(
List
<
E
>
entityList
);
}
}
eladmin-common/src/main/java/me/zhengjie/config/ElPermissionConfig.java
View file @
e4ca7afc
...
@@ -7,6 +7,9 @@ import java.util.Arrays;
...
@@ -7,6 +7,9 @@ import java.util.Arrays;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
* @author Zheng Jie
*/
@Service
(
value
=
"el"
)
@Service
(
value
=
"el"
)
public
class
ElPermissionConfig
{
public
class
ElPermissionConfig
{
...
...
eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java
View file @
e4ca7afc
...
@@ -53,6 +53,7 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -53,6 +53,7 @@ public class RedisConfig extends CachingConfigurerSupport {
return
configuration
;
return
configuration
;
}
}
@SuppressWarnings
(
"all"
)
@Bean
(
name
=
"redisTemplate"
)
@Bean
(
name
=
"redisTemplate"
)
@ConditionalOnMissingBean
(
name
=
"redisTemplate"
)
@ConditionalOnMissingBean
(
name
=
"redisTemplate"
)
public
RedisTemplate
<
Object
,
Object
>
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
public
RedisTemplate
<
Object
,
Object
>
redisTemplate
(
RedisConnectionFactory
redisConnectionFactory
)
{
...
@@ -65,13 +66,7 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -65,13 +66,7 @@ public class RedisConfig extends CachingConfigurerSupport {
// 全局开启AutoType,这里方便开发,使用全局的方式
// 全局开启AutoType,这里方便开发,使用全局的方式
ParserConfig
.
getGlobalInstance
().
setAutoTypeSupport
(
true
);
ParserConfig
.
getGlobalInstance
().
setAutoTypeSupport
(
true
);
// 建议使用这种方式,小范围指定白名单
// 建议使用这种方式,小范围指定白名单
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.domain");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.service.dto");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.service.dto");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.system.domain");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.quartz.domain");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.monitor.domain");
// ParserConfig.getGlobalInstance().addAccept("me.zhengjie.modules.security.security");
// key的序列化采用StringRedisSerializer
// key的序列化采用StringRedisSerializer
template
.
setKeySerializer
(
new
StringRedisSerializer
());
template
.
setKeySerializer
(
new
StringRedisSerializer
());
template
.
setHashKeySerializer
(
new
StringRedisSerializer
());
template
.
setHashKeySerializer
(
new
StringRedisSerializer
());
...
@@ -86,7 +81,7 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -86,7 +81,7 @@ public class RedisConfig extends CachingConfigurerSupport {
@Override
@Override
public
KeyGenerator
keyGenerator
()
{
public
KeyGenerator
keyGenerator
()
{
return
(
target
,
method
,
params
)
->
{
return
(
target
,
method
,
params
)
->
{
Map
<
String
,
Object
>
container
=
new
HashMap
<>();
Map
<
String
,
Object
>
container
=
new
HashMap
<>(
3
);
Class
<?>
targetClassClass
=
target
.
getClass
();
Class
<?>
targetClassClass
=
target
.
getClass
();
// 类地址
// 类地址
container
.
put
(
"class"
,
targetClassClass
.
toGenericString
());
container
.
put
(
"class"
,
targetClassClass
.
toGenericString
());
...
...
eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java
View file @
e4ca7afc
...
@@ -81,7 +81,8 @@ public class GlobalExceptionHandler {
...
@@ -81,7 +81,8 @@ public class GlobalExceptionHandler {
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
log
.
error
(
ThrowableUtil
.
getStackTrace
(
e
));
String
[]
str
=
Objects
.
requireNonNull
(
e
.
getBindingResult
().
getAllErrors
().
get
(
0
).
getCodes
())[
1
].
split
(
"\\."
);
String
[]
str
=
Objects
.
requireNonNull
(
e
.
getBindingResult
().
getAllErrors
().
get
(
0
).
getCodes
())[
1
].
split
(
"\\."
);
String
message
=
e
.
getBindingResult
().
getAllErrors
().
get
(
0
).
getDefaultMessage
();
String
message
=
e
.
getBindingResult
().
getAllErrors
().
get
(
0
).
getDefaultMessage
();
if
(
"不能为空"
.
equals
(
message
)){
String
msg
=
"不能为空"
;
if
(
msg
.
equals
(
message
)){
message
=
str
[
1
]
+
":"
+
message
;
message
=
str
[
1
]
+
":"
+
message
;
}
}
return
buildResponseEntity
(
ApiError
.
error
(
message
));
return
buildResponseEntity
(
ApiError
.
error
(
message
));
...
...
eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java
View file @
e4ca7afc
...
@@ -15,25 +15,46 @@ import java.nio.charset.StandardCharsets;
...
@@ -15,25 +15,46 @@ import java.nio.charset.StandardCharsets;
*/
*/
public
class
EncryptUtils
{
public
class
EncryptUtils
{
private
static
String
strKey
=
"Passw0rd"
,
strParam
=
"Passw0rd"
;
private
static
String
strParam
=
"Passw0rd"
;
private
static
Cipher
cipher
;
private
static
IvParameterSpec
iv
=
new
IvParameterSpec
(
strParam
.
getBytes
(
StandardCharsets
.
UTF_8
));
private
static
DESKeySpec
getDesKeySpec
(
String
source
)
throws
Exception
{
if
(
source
==
null
||
source
.
length
()
==
0
){
return
null
;
}
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
String
strKey
=
"Passw0rd"
;
return
new
DESKeySpec
(
strKey
.
getBytes
(
StandardCharsets
.
UTF_8
));
}
/**
/**
* 对称加密
* 对称加密
*/
*/
public
static
String
desEncrypt
(
String
source
)
throws
Exception
{
public
static
String
desEncrypt
(
String
source
)
throws
Exception
{
if
(
source
==
null
||
source
.
length
()
==
0
){
DESKeySpec
desKeySpec
=
getDesKeySpec
(
source
);
return
null
;
}
Cipher
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
DESKeySpec
desKeySpec
=
new
DESKeySpec
(
strKey
.
getBytes
(
StandardCharsets
.
UTF_8
));
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
secretKey
=
keyFactory
.
generateSecret
(
desKeySpec
);
SecretKey
secretKey
=
keyFactory
.
generateSecret
(
desKeySpec
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
strParam
.
getBytes
(
StandardCharsets
.
UTF_8
));
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
,
iv
);
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
secretKey
,
iv
);
return
byte2hex
(
return
byte2hex
(
cipher
.
doFinal
(
source
.
getBytes
(
StandardCharsets
.
UTF_8
))).
toUpperCase
();
cipher
.
doFinal
(
source
.
getBytes
(
StandardCharsets
.
UTF_8
))).
toUpperCase
();
}
}
/**
* 对称解密
*/
public
static
String
desDecrypt
(
String
source
)
throws
Exception
{
byte
[]
src
=
hex2byte
(
source
.
getBytes
());
DESKeySpec
desKeySpec
=
getDesKeySpec
(
source
);
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
secretKey
=
keyFactory
.
generateSecret
(
desKeySpec
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
iv
);
byte
[]
retByte
=
cipher
.
doFinal
(
src
);
return
new
String
(
retByte
);
}
private
static
String
byte2hex
(
byte
[]
inStr
)
{
private
static
String
byte2hex
(
byte
[]
inStr
)
{
String
stmp
;
String
stmp
;
StringBuilder
out
=
new
StringBuilder
(
inStr
.
length
*
2
);
StringBuilder
out
=
new
StringBuilder
(
inStr
.
length
*
2
);
...
@@ -50,35 +71,18 @@ public class EncryptUtils {
...
@@ -50,35 +71,18 @@ public class EncryptUtils {
}
}
private
static
byte
[]
hex2byte
(
byte
[]
b
)
{
private
static
byte
[]
hex2byte
(
byte
[]
b
)
{
if
((
b
.
length
%
2
)
!=
0
){
int
size
=
2
;
if
((
b
.
length
%
size
)
!=
0
){
throw
new
IllegalArgumentException
(
"长度不是偶数"
);
throw
new
IllegalArgumentException
(
"长度不是偶数"
);
}
}
byte
[]
b2
=
new
byte
[
b
.
length
/
2
];
byte
[]
b2
=
new
byte
[
b
.
length
/
2
];
for
(
int
n
=
0
;
n
<
b
.
length
;
n
+=
2
)
{
for
(
int
n
=
0
;
n
<
b
.
length
;
n
+=
size
)
{
String
item
=
new
String
(
b
,
n
,
2
);
String
item
=
new
String
(
b
,
n
,
2
);
b2
[
n
/
2
]
=
(
byte
)
Integer
.
parseInt
(
item
,
16
);
b2
[
n
/
2
]
=
(
byte
)
Integer
.
parseInt
(
item
,
16
);
}
}
return
b2
;
return
b2
;
}
}
/**
* 对称解密
*/
public
static
String
desDecrypt
(
String
source
)
throws
Exception
{
if
(
source
==
null
||
source
.
length
()
==
0
){
return
null
;
}
byte
[]
src
=
hex2byte
(
source
.
getBytes
());
Cipher
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
DESKeySpec
desKeySpec
=
new
DESKeySpec
(
strKey
.
getBytes
(
StandardCharsets
.
UTF_8
));
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
secretKey
=
keyFactory
.
generateSecret
(
desKeySpec
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
strParam
.
getBytes
(
StandardCharsets
.
UTF_8
));
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
secretKey
,
iv
);
byte
[]
retByte
=
cipher
.
doFinal
(
src
);
return
new
String
(
retByte
);
}
/**
/**
* 密码加密
* 密码加密
*/
*/
...
...
eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
View file @
e4ca7afc
...
@@ -119,8 +119,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -119,8 +119,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
}
OutputStream
os
=
new
FileOutputStream
(
file
);
OutputStream
os
=
new
FileOutputStream
(
file
);
int
bytesRead
;
int
bytesRead
;
byte
[]
buffer
=
new
byte
[
8192
];
int
len
=
8192
;
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
8192
))
!=
-
1
)
{
byte
[]
buffer
=
new
byte
[
len
];
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
len
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
os
.
write
(
buffer
,
0
,
bytesRead
);
}
}
os
.
close
();
os
.
close
();
...
@@ -210,7 +211,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -210,7 +211,9 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
}
}
public
static
void
checkSize
(
long
maxSize
,
long
size
)
{
public
static
void
checkSize
(
long
maxSize
,
long
size
)
{
if
(
size
>
(
maxSize
*
1024
*
1024
)){
// 1M
int
len
=
1024
*
1024
;
if
(
size
>
(
maxSize
*
len
)){
throw
new
BadRequestException
(
"文件超出规定大小"
);
throw
new
BadRequestException
(
"文件超出规定大小"
);
}
}
}
}
...
...
eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java
View file @
e4ca7afc
...
@@ -15,7 +15,7 @@ import java.util.*;
...
@@ -15,7 +15,7 @@ import java.util.*;
@Slf4j
@Slf4j
public
class
QueryHelp
{
public
class
QueryHelp
{
@SuppressWarnings
(
"
unchecked
"
)
@SuppressWarnings
(
"
all
"
)
public
static
<
R
,
Q
>
Predicate
getPredicate
(
Root
<
R
>
root
,
Q
query
,
CriteriaBuilder
cb
)
{
public
static
<
R
,
Q
>
Predicate
getPredicate
(
Root
<
R
>
root
,
Q
query
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
list
=
new
ArrayList
<>();
List
<
Predicate
>
list
=
new
ArrayList
<>();
...
...
eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java
View file @
e4ca7afc
...
@@ -15,12 +15,15 @@ import java.util.Calendar;
...
@@ -15,12 +15,15 @@ import java.util.Calendar;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
* @author Zheng Jie
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
*/
*/
public
class
StringUtils
extends
org
.
apache
.
commons
.
lang3
.
StringUtils
{
public
class
StringUtils
extends
org
.
apache
.
commons
.
lang3
.
StringUtils
{
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
char
SEPARATOR
=
'_'
;
private
static
final
String
UNKNOWN
=
"unknown"
;
/**
/**
* 驼峰命名法工具
* 驼峰命名法工具
*
*
...
@@ -111,19 +114,21 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -111,19 +114,21 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
*/
*/
public
static
String
getIp
(
HttpServletRequest
request
)
{
public
static
String
getIp
(
HttpServletRequest
request
)
{
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
String
ip
=
request
.
getHeader
(
"x-forwarded-for"
);
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
ip
=
request
.
getHeader
(
"Proxy-Client-IP"
);
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
ip
=
request
.
getHeader
(
"WL-Proxy-Client-IP"
);
}
}
if
(
ip
==
null
||
ip
.
length
()
==
0
||
"unknown"
.
equalsIgnoreCase
(
ip
))
{
if
(
ip
==
null
||
ip
.
length
()
==
0
||
UNKNOWN
.
equalsIgnoreCase
(
ip
))
{
ip
=
request
.
getRemoteAddr
();
ip
=
request
.
getRemoteAddr
();
}
}
if
(
ip
.
contains
(
","
))
{
String
comma
=
","
;
String
localhost
=
"127.0.0.1"
;
if
(
ip
.
contains
(
comma
))
{
ip
=
ip
.
split
(
","
)[
0
];
ip
=
ip
.
split
(
","
)[
0
];
}
}
if
(
"127.0.0.1"
.
equals
(
ip
))
{
if
(
localhost
.
equals
(
ip
))
{
// 获取本机真正的ip地址
// 获取本机真正的ip地址
try
{
try
{
ip
=
InetAddress
.
getLocalHost
().
getHostAddress
();
ip
=
InetAddress
.
getLocalHost
().
getHostAddress
();
...
@@ -149,7 +154,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
...
@@ -149,7 +154,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
DataBlock
dataBlock
;
DataBlock
dataBlock
;
dataBlock
=
(
DataBlock
)
method
.
invoke
(
searcher
,
ip
);
dataBlock
=
(
DataBlock
)
method
.
invoke
(
searcher
,
ip
);
String
address
=
dataBlock
.
getRegion
().
replace
(
"0|"
,
""
);
String
address
=
dataBlock
.
getRegion
().
replace
(
"0|"
,
""
);
if
(
address
.
charAt
(
address
.
length
()-
1
)
==
'|'
){
char
symbol
=
'|'
;
if
(
address
.
charAt
(
address
.
length
()-
1
)
==
symbol
){
address
=
address
.
substring
(
0
,
address
.
length
()
-
1
);
address
=
address
.
substring
(
0
,
address
.
length
()
-
1
);
}
}
return
address
.
equals
(
ElAdminConstant
.
REGION
)?
"内网IP"
:
address
;
return
address
.
equals
(
ElAdminConstant
.
REGION
)?
"内网IP"
:
address
;
...
...
eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java
View file @
e4ca7afc
...
@@ -7,6 +7,10 @@ import java.net.HttpURLConnection;
...
@@ -7,6 +7,10 @@ import java.net.HttpURLConnection;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
/**
* @author Zheng Jie
* 翻译工具类
*/
public
class
TranslatorUtil
{
public
class
TranslatorUtil
{
public
static
String
translate
(
String
word
){
public
static
String
translate
(
String
word
){
...
...
eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java
View file @
e4ca7afc
...
@@ -23,40 +23,40 @@ public class ColumnInfo {
...
@@ -23,40 +23,40 @@ public class ColumnInfo {
private
String
tableName
;
private
String
tableName
;
/
/
数据库字段名称
/
**
数据库字段名称
*/
private
String
columnName
;
private
String
columnName
;
/
/
数据库字段类型
/
**
数据库字段类型
*/
private
String
columnType
;
private
String
columnType
;
/
/
数据库字段键类型
/
**
数据库字段键类型
*/
private
String
keyType
;
private
String
keyType
;
/
/
字段额外的参数
/
**
字段额外的参数
*/
private
String
extra
;
private
String
extra
;
/
/
数据库字段描述
/
**
数据库字段描述
*/
private
String
remark
;
private
String
remark
;
/
/
必填
/
**
必填
*/
private
Boolean
notNull
;
private
Boolean
notNull
;
/
/
是否在列表显示
/
**
是否在列表显示
*/
private
Boolean
listShow
;
private
Boolean
listShow
;
/
/
是否表单显示
/
**
是否表单显示
*/
private
Boolean
formShow
;
private
Boolean
formShow
;
/
/
表单类型
/
**
表单类型
*/
private
String
formType
;
private
String
formType
;
/
/
查询 1:模糊 2:精确
/
**
查询 1:模糊 2:精确
*/
private
String
queryType
;
private
String
queryType
;
/
/
字典名称
/
**
字典名称
*/
private
String
dictName
;
private
String
dictName
;
/
/
日期注解
/
**
日期注解
*/
private
String
dateAnnotation
;
private
String
dateAnnotation
;
public
ColumnInfo
(
String
tableName
,
String
columnName
,
Boolean
notNull
,
String
columnType
,
String
remark
,
String
keyType
,
String
extra
)
{
public
ColumnInfo
(
String
tableName
,
String
columnName
,
Boolean
notNull
,
String
columnType
,
String
remark
,
String
keyType
,
String
extra
)
{
...
...
eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java
View file @
e4ca7afc
...
@@ -30,29 +30,29 @@ public class GenConfig {
...
@@ -30,29 +30,29 @@ public class GenConfig {
@NotBlank
@NotBlank
private
String
tableName
;
private
String
tableName
;
/
/
包路径
/
**
包路径
*/
@NotBlank
@NotBlank
private
String
pack
;
private
String
pack
;
/
/
模块名
/
**
模块名
*/
@Column
(
name
=
"module_name"
)
@Column
(
name
=
"module_name"
)
@NotBlank
@NotBlank
private
String
moduleName
;
private
String
moduleName
;
/
/
前端文件路径
/
**
前端文件路径
*/
@NotBlank
@NotBlank
private
String
path
;
private
String
path
;
/
/
前端文件路径
/
**
前端文件路径
*/
@Column
(
name
=
"api_path"
)
@Column
(
name
=
"api_path"
)
private
String
apiPath
;
private
String
apiPath
;
/
/
作者
/
**
作者
*/
private
String
author
;
private
String
author
;
/
/
表前缀
/
**
表前缀
*/
private
String
prefix
;
private
String
prefix
;
/
/
是否覆盖
/
**
是否覆盖
*/
private
Boolean
cover
;
private
Boolean
cover
;
}
}
eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java
View file @
e4ca7afc
...
@@ -14,19 +14,19 @@ import lombok.NoArgsConstructor;
...
@@ -14,19 +14,19 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@NoArgsConstructor
public
class
TableInfo
{
public
class
TableInfo
{
/
/
表名称
/
**
表名称
*/
private
Object
tableName
;
private
Object
tableName
;
/
/
创建日期
/
**
创建日期
*/
private
Object
createTime
;
private
Object
createTime
;
/
/
数据库引擎
/
**
数据库引擎
*/
private
Object
engine
;
private
Object
engine
;
/
/
编码集
/
**
编码集
*/
private
Object
coding
;
private
Object
coding
;
/
/
备注
/
**
备注
*/
private
Object
remark
;
private
Object
remark
;
...
...
eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java
View file @
e4ca7afc
...
@@ -10,5 +10,10 @@ import java.util.List;
...
@@ -10,5 +10,10 @@ import java.util.List;
*/
*/
public
interface
ColumnInfoRepository
extends
JpaRepository
<
ColumnInfo
,
Long
>
{
public
interface
ColumnInfoRepository
extends
JpaRepository
<
ColumnInfo
,
Long
>
{
/**
* 查询表信息
* @param tableName 表格名
* @return 表信息
*/
List
<
ColumnInfo
>
findByTableNameOrderByIdAsc
(
String
tableName
);
List
<
ColumnInfo
>
findByTableNameOrderByIdAsc
(
String
tableName
);
}
}
eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java
View file @
e4ca7afc
...
@@ -9,5 +9,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
...
@@ -9,5 +9,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
*/
*/
public
interface
GenConfigRepository
extends
JpaRepository
<
GenConfig
,
Long
>
{
public
interface
GenConfigRepository
extends
JpaRepository
<
GenConfig
,
Long
>
{
/**
* 查询表配置
* @param tableName 表名
* @return /
*/
GenConfig
findByTableName
(
String
tableName
);
GenConfig
findByTableName
(
String
tableName
);
}
}
eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java
View file @
e4ca7afc
...
@@ -8,7 +8,18 @@ import me.zhengjie.domain.GenConfig;
...
@@ -8,7 +8,18 @@ import me.zhengjie.domain.GenConfig;
*/
*/
public
interface
GenConfigService
{
public
interface
GenConfigService
{
/**
* 查询表配置
* @param tableName 表名
* @return 表配置
*/
GenConfig
find
(
String
tableName
);
GenConfig
find
(
String
tableName
);
/**
* 更新表配置
* @param tableName 表名
* @param genConfig 表配置
* @return 表配置
*/
GenConfig
update
(
String
tableName
,
GenConfig
genConfig
);
GenConfig
update
(
String
tableName
,
GenConfig
genConfig
);
}
}
eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java
View file @
e4ca7afc
...
@@ -39,14 +39,17 @@ public class GenConfigServiceImpl implements GenConfigService {
...
@@ -39,14 +39,17 @@ public class GenConfigServiceImpl implements GenConfigService {
// 自动设置Api路径,注释掉前需要同步取消前端的注释
// 自动设置Api路径,注释掉前需要同步取消前端的注释
String
separator
=
File
.
separator
;
String
separator
=
File
.
separator
;
String
[]
paths
;
String
[]
paths
;
if
(
separator
.
equals
(
"\\"
))
{
String
symbol
=
"\\"
;
if
(
symbol
.
equals
(
separator
))
{
paths
=
genConfig
.
getPath
().
split
(
"\\\\"
);
paths
=
genConfig
.
getPath
().
split
(
"\\\\"
);
}
else
paths
=
genConfig
.
getPath
().
split
(
File
.
separator
);
}
else
{
paths
=
genConfig
.
getPath
().
split
(
File
.
separator
);
}
StringBuilder
api
=
new
StringBuilder
();
StringBuilder
api
=
new
StringBuilder
();
for
(
String
path
:
paths
)
{
for
(
String
path
:
paths
)
{
api
.
append
(
path
);
api
.
append
(
path
);
api
.
append
(
separator
);
api
.
append
(
separator
);
if
(
path
.
equals
(
"src"
))
{
if
(
"src"
.
equals
(
path
))
{
api
.
append
(
"api"
);
api
.
append
(
"api"
);
break
;
break
;
}
}
...
...
Prev
1
2
3
4
5
…
8
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