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
fd9fb2a6
"jetbrains:/idea/checkout/git" did not exist on "dd7c88010de33fa2793e7312a4be01e97d6dcc31"
Commit
fd9fb2a6
authored
Nov 01, 2019
by
dqjdda
Browse files
Merge branch '2.3dev'
parents
7895e547
1839ef8d
Changes
227
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/utils/VerifyCodeUtils.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.security.utils
;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Graphics
;
import
java.awt.Graphics2D
;
import
java.awt.RenderingHints
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Arrays
;
import
java.util.Random
;
import
javax.imageio.ImageIO
;
/**
* @author https://blog.csdn.net/ruixue0117/article/details/22829557
* @date 2019-6-20 17:28:53
*/
public
class
VerifyCodeUtils
{
//使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符
public
static
final
String
VERIFY_CODES
=
"23456789ABCDEFGHJKLMNPQRSTUVWXYZ"
;
private
static
Random
random
=
new
Random
();
/**
* 使用系统默认字符源生成验证码
* @param verifySize 验证码长度
* @return
*/
public
static
String
generateVerifyCode
(
int
verifySize
){
return
generateVerifyCode
(
verifySize
,
VERIFY_CODES
);
}
/**
* 使用指定源生成验证码
* @param verifySize 验证码长度
* @param sources 验证码字符源
* @return
*/
public
static
String
generateVerifyCode
(
int
verifySize
,
String
sources
){
if
(
sources
==
null
||
sources
.
length
()
==
0
){
sources
=
VERIFY_CODES
;
}
int
codesLen
=
sources
.
length
();
Random
rand
=
new
Random
(
System
.
currentTimeMillis
());
StringBuilder
verifyCode
=
new
StringBuilder
(
verifySize
);
for
(
int
i
=
0
;
i
<
verifySize
;
i
++){
verifyCode
.
append
(
sources
.
charAt
(
rand
.
nextInt
(
codesLen
-
1
)));
}
return
verifyCode
.
toString
();
}
/**
* 输出指定验证码图片流
* @param w
* @param h
* @param os
* @param code
* @throws IOException
*/
public
static
void
outputImage
(
int
w
,
int
h
,
OutputStream
os
,
String
code
)
throws
IOException
{
int
verifySize
=
code
.
length
();
BufferedImage
image
=
new
BufferedImage
(
w
,
h
,
BufferedImage
.
TYPE_INT_RGB
);
Random
rand
=
new
Random
();
Graphics2D
g2
=
image
.
createGraphics
();
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
Color
[]
colors
=
new
Color
[
5
];
Color
[]
colorSpaces
=
new
Color
[]
{
Color
.
WHITE
,
Color
.
CYAN
,
Color
.
GRAY
,
Color
.
LIGHT_GRAY
,
Color
.
MAGENTA
,
Color
.
ORANGE
,
Color
.
PINK
,
Color
.
YELLOW
};
float
[]
fractions
=
new
float
[
colors
.
length
];
for
(
int
i
=
0
;
i
<
colors
.
length
;
i
++){
colors
[
i
]
=
colorSpaces
[
rand
.
nextInt
(
colorSpaces
.
length
)];
fractions
[
i
]
=
rand
.
nextFloat
();
}
Arrays
.
sort
(
fractions
);
g2
.
setColor
(
Color
.
GRAY
);
// 设置边框色
g2
.
fillRect
(
0
,
0
,
w
,
h
);
Color
c
=
getRandColor
(
200
,
250
);
g2
.
setColor
(
c
);
// 设置背景色
g2
.
fillRect
(
0
,
2
,
w
,
h
-
4
);
//绘制干扰线
Random
random
=
new
Random
();
g2
.
setColor
(
getRandColor
(
160
,
200
));
// 设置线条的颜色
for
(
int
i
=
0
;
i
<
20
;
i
++)
{
int
x
=
random
.
nextInt
(
w
-
1
);
int
y
=
random
.
nextInt
(
h
-
1
);
int
xl
=
random
.
nextInt
(
6
)
+
1
;
int
yl
=
random
.
nextInt
(
12
)
+
1
;
g2
.
drawLine
(
x
,
y
,
x
+
xl
+
40
,
y
+
yl
+
20
);
}
// 添加噪点
float
yawpRate
=
0.05f
;
// 噪声率
int
area
=
(
int
)
(
yawpRate
*
w
*
h
);
for
(
int
i
=
0
;
i
<
area
;
i
++)
{
int
x
=
random
.
nextInt
(
w
);
int
y
=
random
.
nextInt
(
h
);
int
rgb
=
getRandomIntColor
();
image
.
setRGB
(
x
,
y
,
rgb
);
}
shear
(
g2
,
w
,
h
,
c
);
// 使图片扭曲
g2
.
setColor
(
getRandColor
(
100
,
160
));
int
fontSize
=
h
-
4
;
Font
font
=
new
Font
(
"Algerian"
,
Font
.
ITALIC
,
fontSize
);
g2
.
setFont
(
font
);
char
[]
chars
=
code
.
toCharArray
();
for
(
int
i
=
0
;
i
<
verifySize
;
i
++){
AffineTransform
affine
=
new
AffineTransform
();
affine
.
setToRotation
(
Math
.
PI
/
4
*
rand
.
nextDouble
()
*
(
rand
.
nextBoolean
()
?
1
:
-
1
),
(
w
/
verifySize
)
*
i
+
fontSize
/
2
,
h
/
2
);
g2
.
setTransform
(
affine
);
g2
.
drawChars
(
chars
,
i
,
1
,
((
w
-
10
)
/
verifySize
)
*
i
+
5
,
h
/
2
+
fontSize
/
2
-
10
);
}
g2
.
dispose
();
ImageIO
.
write
(
image
,
"jpg"
,
os
);
}
private
static
Color
getRandColor
(
int
fc
,
int
bc
)
{
if
(
fc
>
255
)
fc
=
255
;
if
(
bc
>
255
)
bc
=
255
;
int
r
=
fc
+
random
.
nextInt
(
bc
-
fc
);
int
g
=
fc
+
random
.
nextInt
(
bc
-
fc
);
int
b
=
fc
+
random
.
nextInt
(
bc
-
fc
);
return
new
Color
(
r
,
g
,
b
);
}
private
static
int
getRandomIntColor
()
{
int
[]
rgb
=
getRandomRgb
();
int
color
=
0
;
for
(
int
c
:
rgb
)
{
color
=
color
<<
8
;
color
=
color
|
c
;
}
return
color
;
}
private
static
int
[]
getRandomRgb
()
{
int
[]
rgb
=
new
int
[
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
rgb
[
i
]
=
random
.
nextInt
(
255
);
}
return
rgb
;
}
private
static
void
shear
(
Graphics
g
,
int
w1
,
int
h1
,
Color
color
)
{
shearX
(
g
,
w1
,
h1
,
color
);
shearY
(
g
,
w1
,
h1
,
color
);
}
private
static
void
shearX
(
Graphics
g
,
int
w1
,
int
h1
,
Color
color
)
{
int
period
=
random
.
nextInt
(
2
);
boolean
borderGap
=
true
;
int
frames
=
1
;
int
phase
=
random
.
nextInt
(
2
);
for
(
int
i
=
0
;
i
<
h1
;
i
++)
{
double
d
=
(
double
)
(
period
>>
1
)
*
Math
.
sin
((
double
)
i
/
(
double
)
period
+
(
6.2831853071795862
D
*
(
double
)
phase
)
/
(
double
)
frames
);
g
.
copyArea
(
0
,
i
,
w1
,
1
,
(
int
)
d
,
0
);
if
(
borderGap
)
{
g
.
setColor
(
color
);
g
.
drawLine
((
int
)
d
,
i
,
0
,
i
);
g
.
drawLine
((
int
)
d
+
w1
,
i
,
w1
,
i
);
}
}
}
private
static
void
shearY
(
Graphics
g
,
int
w1
,
int
h1
,
Color
color
)
{
int
period
=
random
.
nextInt
(
40
)
+
10
;
// 50;
boolean
borderGap
=
true
;
int
frames
=
20
;
int
phase
=
7
;
for
(
int
i
=
0
;
i
<
w1
;
i
++)
{
double
d
=
(
double
)
(
period
>>
1
)
*
Math
.
sin
((
double
)
i
/
(
double
)
period
+
(
6.2831853071795862
D
*
(
double
)
phase
)
/
(
double
)
frames
);
g
.
copyArea
(
i
,
0
,
1
,
h1
,
0
,
(
int
)
d
);
if
(
borderGap
)
{
g
.
setColor
(
color
);
g
.
drawLine
(
i
,
(
int
)
d
,
i
,
0
);
g
.
drawLine
(
i
,
(
int
)
d
+
h1
,
i
,
h1
);
}
}
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.domain
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.sql.Timestamp
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Set
;
/**
...
...
@@ -15,22 +16,17 @@ import java.util.Set;
* @date 2019-03-25
*/
@Entity
@Data
@Getter
@Setter
@Table
(
name
=
"dept"
)
public
class
Dept
implements
Serializable
{
/**
* ID
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
)
@NotNull
(
groups
=
Update
.
class
)
private
Long
id
;
/**
* 名称
*/
@Column
(
name
=
"name"
,
nullable
=
false
)
@NotBlank
private
String
name
;
...
...
@@ -38,9 +34,6 @@ public class Dept implements Serializable {
@NotNull
private
Boolean
enabled
;
/**
* 上级部门
*/
@Column
(
name
=
"pid"
,
nullable
=
false
)
@NotNull
private
Long
pid
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.domain
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
me.zhengjie.base.BaseEntity
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.List
;
/**
...
...
@@ -12,7 +16,8 @@ import java.util.List;
* @date 2019-04-10
*/
@Entity
@Data
@Getter
@Setter
@Table
(
name
=
"dict"
)
public
class
Dict
implements
Serializable
{
...
...
@@ -22,19 +27,17 @@ public class Dict implements Serializable {
@NotNull
(
groups
=
Update
.
class
)
private
Long
id
;
/**
* 字典名称
*/
@Column
(
name
=
"name"
,
nullable
=
false
,
unique
=
true
)
@NotBlank
private
String
name
;
/**
* 描述
*/
@Column
(
name
=
"remark"
)
private
String
remark
;
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
@OneToMany
(
mappedBy
=
"dict"
,
cascade
={
CascadeType
.
PERSIST
,
CascadeType
.
REMOVE
})
private
List
<
DictDetail
>
dictDetails
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.domain
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Entity
@Data
@Getter
@Setter
@Table
(
name
=
"dict_detail"
)
public
class
DictDetail
implements
Serializable
{
...
...
@@ -20,30 +24,26 @@ public class DictDetail implements Serializable {
@NotNull
(
groups
=
Update
.
class
)
private
Long
id
;
/**
* 字典标签
*/
// 字典标签
@Column
(
name
=
"label"
,
nullable
=
false
)
private
String
label
;
/**
* 字典值
*/
// 字典值
@Column
(
name
=
"value"
,
nullable
=
false
)
private
String
value
;
/**
* 排序
*/
// 排序
@Column
(
name
=
"sort"
)
private
String
sort
=
"999"
;
/**
* 字典id
*/
// 字典id
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@JoinColumn
(
name
=
"dict_id"
)
private
Dict
dict
;
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
public
@interface
Update
{}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.domain
;
import
lombok.Data
;
import
org.hibernate.annotations.*
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.sql.Timestamp
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
* @author Zheng Jie
* @date 2019-03-29
*/
@Entity
@Data
@Getter
@Setter
@Table
(
name
=
"job"
)
public
class
Job
implements
Serializable
{
/**
* ID
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@Column
(
name
=
"id"
)
@NotNull
(
groups
=
Update
.
class
)
private
Long
id
;
/**
* 名称
*/
@Column
(
name
=
"name"
,
nullable
=
false
)
@NotBlank
private
String
name
;
...
...
@@ -39,9 +35,6 @@ public class Job implements Serializable {
@NotNull
private
Long
sort
;
/**
* 状态
*/
@Column
(
name
=
"enabled"
,
nullable
=
false
)
@NotNull
private
Boolean
enabled
;
...
...
@@ -50,9 +43,6 @@ public class Job implements Serializable {
@JoinColumn
(
name
=
"dept_id"
)
private
Dept
dept
;
/**
* 创建日期
*/
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java
View file @
fd9fb2a6
...
...
@@ -31,15 +31,21 @@ public class Menu implements Serializable {
private
String
name
;
@Column
(
unique
=
true
)
@NotNull
private
Long
sort
;
private
Long
sort
=
999L
;
@NotBlank
@Column
(
name
=
"path"
)
private
String
path
;
private
String
component
;
// 类型
@Column
(
name
=
"type"
)
private
Integer
type
;
// 权限
@Column
(
name
=
"permission"
)
private
String
permission
;
@Column
(
unique
=
true
,
name
=
"component_name"
)
private
String
componentName
;
...
...
@@ -51,15 +57,11 @@ public class Menu implements Serializable {
@Column
(
columnDefinition
=
"bit(1) default 0"
)
private
Boolean
hidden
;
/**
* 上级菜单ID
*/
// 上级菜单ID
@Column
(
name
=
"pid"
,
nullable
=
false
)
private
Long
pid
;
/**
* 是否为外链 true/false
*/
// 是否为外链 true/false
@Column
(
name
=
"i_frame"
)
private
Boolean
iFrame
;
...
...
@@ -67,11 +69,11 @@ public class Menu implements Serializable {
@JsonIgnore
private
Set
<
Role
>
roles
;
@CreationTimestamp
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
public
interface
Update
{}
public
@
interface
Update
{}
@Override
public
boolean
equals
(
Object
o
)
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Permission.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.system.domain
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.util.Set
;
/**
* @author Zheng Jie
* @date 2018-12-03
*/
@Entity
@Getter
@Setter
@Table
(
name
=
"permission"
)
public
class
Permission
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@NotNull
(
groups
=
{
Update
.
class
})
private
Long
id
;
@NotBlank
private
String
name
;
/**
* 上级类目
*/
@NotNull
@Column
(
name
=
"pid"
,
nullable
=
false
)
private
Long
pid
;
@NotBlank
private
String
alias
;
@JsonIgnore
@ManyToMany
(
mappedBy
=
"permissions"
)
private
Set
<
Role
>
roles
;
@CreationTimestamp
@Column
(
name
=
"create_time"
)
private
Timestamp
createTime
;
@Override
public
String
toString
()
{
return
"Permission{"
+
"id="
+
id
+
", name='"
+
name
+
'\''
+
", pid="
+
pid
+
", alias='"
+
alias
+
'\''
+
", createTime="
+
createTime
+
'}'
;
}
public
interface
Update
{}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java
View file @
fd9fb2a6
...
...
@@ -43,14 +43,14 @@ public class Role implements Serializable {
@Column
private
String
remark
;
// 权限
@Column
(
name
=
"permission"
)
private
String
permission
;
@JsonIgnore
@ManyToMany
(
mappedBy
=
"roles"
)
private
Set
<
User
>
users
;
@ManyToMany
@JoinTable
(
name
=
"roles_permissions"
,
joinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
"id"
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"permission_id"
,
referencedColumnName
=
"id"
)})
private
Set
<
Permission
>
permissions
;
@ManyToMany
@JoinTable
(
name
=
"roles_menus"
,
joinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
"id"
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"menu_id"
,
referencedColumnName
=
"id"
)})
private
Set
<
Menu
>
menus
;
...
...
@@ -59,19 +59,11 @@ public class Role implements Serializable {
@JoinTable
(
name
=
"roles_depts"
,
joinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
"id"
)},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"dept_id"
,
referencedColumnName
=
"id"
)})
private
Set
<
Dept
>
depts
;
@CreationTimestamp
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
@Override
public
String
toString
()
{
return
"Role{"
+
"id="
+
id
+
", name='"
+
name
+
'\''
+
", remark='"
+
remark
+
'\''
+
", createDateTime="
+
createTime
+
'}'
;
}
public
@interface
Update
{}
@Override
public
boolean
equals
(
Object
o
)
{
...
...
@@ -85,6 +77,4 @@ public class Role implements Serializable {
public
int
hashCode
()
{
return
Objects
.
hash
(
id
);
}
public
interface
Update
{}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java
View file @
fd9fb2a6
...
...
@@ -36,7 +36,7 @@ public class User implements Serializable {
private
UserAvatar
userAvatar
;
@NotBlank
@Pattern
(
regexp
=
"([a-z0-9A-Z]+[-|
\\
.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}"
,
message
=
"格式错误"
)
@Pattern
(
regexp
=
"([a-z0-9A-Z]+[-|.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}"
,
message
=
"格式错误"
)
private
String
email
;
@NotBlank
...
...
@@ -47,8 +47,8 @@ public class User implements Serializable {
private
String
password
;
@CreationTimestamp
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
@Column
(
name
=
"last_password_reset_time"
)
...
...
@@ -66,18 +66,5 @@ public class User implements Serializable {
@JoinColumn
(
name
=
"dept_id"
)
private
Dept
dept
;
@Override
public
String
toString
()
{
return
"User{"
+
"id="
+
id
+
", username='"
+
username
+
'\''
+
", email='"
+
email
+
'\''
+
", enabled="
+
enabled
+
", password='"
+
password
+
'\''
+
", createTime="
+
createTime
+
", lastPasswordResetTime="
+
lastPasswordResetTime
+
'}'
;
}
public
@interface
Update
{}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/UserAvatar.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.domain
;
import
cn.hutool.core.util.ObjectUtil
;
import
lombok.
Data
;
import
lombok.
Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
me.zhengjie.base.BaseEntity
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
...
...
@@ -12,10 +16,11 @@ import java.sql.Timestamp;
* @date 2019年9月7日 16:16:59
*/
@Entity
@
Table
(
name
=
"user_avatar"
)
@
Data
@
Getter
@
Setter
@NoArgsConstructor
public
class
UserAvatar
{
@Table
(
name
=
"user_avatar"
)
public
class
UserAvatar
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
@@ -27,6 +32,10 @@ public class UserAvatar {
private
String
size
;
@Column
(
name
=
"create_time"
)
@CreationTimestamp
private
Timestamp
createTime
;
public
UserAvatar
(
UserAvatar
userAvatar
,
String
realName
,
String
path
,
String
size
)
{
this
.
id
=
ObjectUtil
.
isNotEmpty
(
userAvatar
)
?
userAvatar
.
getId
()
:
null
;
this
.
realName
=
realName
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DeptRepository.java
View file @
fd9fb2a6
...
...
@@ -4,7 +4,6 @@ import me.zhengjie.modules.system.domain.Dept;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -12,13 +11,8 @@ import java.util.Set;
* @author Zheng Jie
* @date 2019-03-25
*/
public
interface
DeptRepository
extends
JpaRepository
<
Dept
,
Long
>,
JpaSpecificationExecutor
{
public
interface
DeptRepository
extends
JpaRepository
<
Dept
,
Long
>,
JpaSpecificationExecutor
<
Dept
>
{
/**
* findByPid
* @param id
* @return
*/
List
<
Dept
>
findByPid
(
Long
id
);
@Query
(
value
=
"select name from dept where id = ?1"
,
nativeQuery
=
true
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java
View file @
fd9fb2a6
...
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @date 2019-04-10
*/
public
interface
DictDetailRepository
extends
JpaRepository
<
DictDetail
,
Long
>,
JpaSpecificationExecutor
{
public
interface
DictDetailRepository
extends
JpaRepository
<
DictDetail
,
Long
>,
JpaSpecificationExecutor
<
DictDetail
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java
View file @
fd9fb2a6
...
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @date 2019-04-10
*/
public
interface
DictRepository
extends
JpaRepository
<
Dict
,
Long
>,
JpaSpecificationExecutor
{
public
interface
DictRepository
extends
JpaRepository
<
Dict
,
Long
>,
JpaSpecificationExecutor
<
Dict
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobRepository.java
View file @
fd9fb2a6
...
...
@@ -8,5 +8,5 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
* @author Zheng Jie
* @date 2019-03-29
*/
public
interface
JobRepository
extends
JpaRepository
<
Job
,
Long
>,
JpaSpecificationExecutor
{
public
interface
JobRepository
extends
JpaRepository
<
Job
,
Long
>,
JpaSpecificationExecutor
<
Job
>
{
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.repository
;
import
me.zhengjie.modules.system.domain.Menu
;
import
me.zhengjie.modules.system.domain.Role
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @author Zheng Jie
* @date 2018-12-17
*/
public
interface
MenuRepository
extends
JpaRepository
<
Menu
,
Long
>,
JpaSpecificationExecutor
{
public
interface
MenuRepository
extends
JpaRepository
<
Menu
,
Long
>,
JpaSpecificationExecutor
<
Menu
>
{
/**
* findByName
* @param name
* @return
*/
Menu
findByName
(
String
name
);
/**
* findByName
* @param name
* @return
*/
Menu
findByComponentName
(
String
name
);
/**
* findByPid
* @param pid
* @return
*/
List
<
Menu
>
findByPid
(
long
pid
);
LinkedHashSet
<
Menu
>
findByRoles_IdOrderBySortAsc
(
Long
id
);
LinkedHashSet
<
Menu
>
findByRoles_Id
AndTypeIsNotIn
OrderBySortAsc
(
Long
id
,
Integer
type
);
}
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/PermissionRepository.java
deleted
100644 → 0
View file @
7895e547
package
me.zhengjie.modules.system.repository
;
import
me.zhengjie.modules.system.domain.Permission
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
/**
* @author Zheng Jie
* @date 2018-12-03
*/
public
interface
PermissionRepository
extends
JpaRepository
<
Permission
,
Long
>,
JpaSpecificationExecutor
{
/**
* findByName
* @param name
* @return
*/
Permission
findByName
(
String
name
);
/**
* findByPid
* @param pid
* @return
*/
List
<
Permission
>
findByPid
(
long
pid
);
}
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java
View file @
fd9fb2a6
...
...
@@ -5,28 +5,18 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.Set
;
/**
* @author Zheng Jie
* @date 2018-12-03
*/
public
interface
RoleRepository
extends
JpaRepository
<
Role
,
Long
>,
JpaSpecificationExecutor
{
public
interface
RoleRepository
extends
JpaRepository
<
Role
,
Long
>,
JpaSpecificationExecutor
<
Role
>
{
/**
* findByName
* @param name
* @return
*/
Role
findByName
(
String
name
);
Set
<
Role
>
findByUsers_Id
(
Long
id
);
@Modifying
@Query
(
value
=
"delete from roles_permissions where permission_id = ?1"
,
nativeQuery
=
true
)
void
untiedPermission
(
Long
id
);
@Modifying
@Query
(
value
=
"delete from roles_menus where menu_id = ?1"
,
nativeQuery
=
true
)
void
untiedMenu
(
Long
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserAvatarRepository.java
View file @
fd9fb2a6
...
...
@@ -4,12 +4,10 @@ import me.zhengjie.modules.system.domain.UserAvatar;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.Date
;
/**
* @author Zheng Jie
* @date 2018-11-22
*/
public
interface
UserAvatarRepository
extends
JpaRepository
<
UserAvatar
,
Long
>,
JpaSpecificationExecutor
{
public
interface
UserAvatarRepository
extends
JpaRepository
<
UserAvatar
,
Long
>,
JpaSpecificationExecutor
<
UserAvatar
>
{
}
eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.repository
;
import
me.zhengjie.modules.system.domain.User
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author Zheng Jie
* @date 2018-11-22
*/
public
interface
UserRepository
extends
JpaRepository
<
User
,
Long
>,
JpaSpecificationExecutor
{
public
interface
UserRepository
extends
JpaRepository
<
User
,
Long
>,
JpaSpecificationExecutor
<
User
>
{
/**
* findByUsername
* @param username
* @return
*/
User
findByUsername
(
String
username
);
/**
* findByEmail
* @param email
* @return
*/
User
findByEmail
(
String
email
);
/**
* 修改密码
* @param username
* @param pass
*/
@Modifying
@Query
(
value
=
"update user set password = ?2 , last_password_reset_time = ?3 where username = ?1"
,
nativeQuery
=
true
)
void
updatePass
(
String
username
,
String
pass
,
Date
lastPasswordResetTime
);
/**
* 修改头像
* @param username
* @param url
*/
@Modifying
@Query
(
value
=
"update user set avatar = ?2 where username = ?1"
,
nativeQuery
=
true
)
void
updateAvatar
(
String
username
,
String
url
);
/**
* 修改邮箱
* @param username
* @param email
*/
@Modifying
@Query
(
value
=
"update user set email = ?2 where username = ?1"
,
nativeQuery
=
true
)
void
updateEmail
(
String
username
,
String
email
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java
View file @
fd9fb2a6
package
me.zhengjie.modules.system.rest
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.config.DataScope
;
import
me.zhengjie.exception.BadRequestException
;
...
...
@@ -8,12 +10,14 @@ import me.zhengjie.modules.system.service.DeptService;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
me.zhengjie.modules.system.service.dto.DeptQueryCriteria
;
import
me.zhengjie.utils.ThrowableUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
/**
...
...
@@ -21,48 +25,64 @@ import java.util.List;
* @date 2019-03-25
*/
@RestController
@RequestMapping
(
"api"
)
@Api
(
tags
=
"系统:部门管理"
)
@RequestMapping
(
"/api/dept"
)
public
class
DeptController
{
@Autowired
private
DeptService
deptService
;
private
final
DeptService
deptService
;
@Autowired
private
DataScope
dataScope
;
private
final
DataScope
dataScope
;
private
static
final
String
ENTITY_NAME
=
"dept"
;
public
DeptController
(
DeptService
deptService
,
DataScope
dataScope
)
{
this
.
deptService
=
deptService
;
this
.
dataScope
=
dataScope
;
}
@Log
(
"导出部门数据"
)
@ApiOperation
(
"导出部门数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('dept:list')"
)
public
void
download
(
HttpServletResponse
response
,
DeptQueryCriteria
criteria
)
throws
IOException
{
deptService
.
download
(
deptService
.
queryAll
(
criteria
),
response
);
}
@Log
(
"查询部门"
)
@GetMapping
(
value
=
"/dept"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT','DEPT_ALL','DEPT_SELECT')"
)
@ApiOperation
(
"查询部门"
)
@GetMapping
@PreAuthorize
(
"@el.check('user:list','dept:list')"
)
public
ResponseEntity
getDepts
(
DeptQueryCriteria
criteria
){
// 数据权限
criteria
.
setIds
(
dataScope
.
getDeptIds
());
List
<
DeptDTO
>
deptDTOS
=
deptService
.
queryAll
(
criteria
);
return
new
ResponseEntity
(
deptService
.
buildTree
(
deptDTOS
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>
(
deptService
.
buildTree
(
deptDTOS
),
HttpStatus
.
OK
);
}
@Log
(
"新增部门"
)
@PostMapping
(
value
=
"/dept"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DEPT_ALL','DEPT_CREATE')"
)
@ApiOperation
(
"新增部门"
)
@PostMapping
@PreAuthorize
(
"@el.check('dept:add')"
)
public
ResponseEntity
create
(
@Validated
@RequestBody
Dept
resources
){
if
(
resources
.
getId
()
!=
null
)
{
throw
new
BadRequestException
(
"A new "
+
ENTITY_NAME
+
" cannot already have an ID"
);
}
return
new
ResponseEntity
(
deptService
.
create
(
resources
),
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>
(
deptService
.
create
(
resources
),
HttpStatus
.
CREATED
);
}
@Log
(
"修改部门"
)
@PutMapping
(
value
=
"/dept"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DEPT_ALL','DEPT_EDIT')"
)
@ApiOperation
(
"修改部门"
)
@PutMapping
@PreAuthorize
(
"@el.check('dept:edit')"
)
public
ResponseEntity
update
(
@Validated
(
Dept
.
Update
.
class
)
@RequestBody
Dept
resources
){
deptService
.
update
(
resources
);
return
new
ResponseEntity
(
HttpStatus
.
NO_CONTENT
);
}
@Log
(
"删除部门"
)
@DeleteMapping
(
value
=
"/dept/{id}"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','DEPT_ALL','DEPT_DELETE')"
)
@ApiOperation
(
"删除部门"
)
@DeleteMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('dept:del')"
)
public
ResponseEntity
delete
(
@PathVariable
Long
id
){
try
{
deptService
.
delete
(
id
);
...
...
Prev
1
2
3
4
5
6
7
8
9
10
…
12
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