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
83dc7f8a
Commit
83dc7f8a
authored
Jun 10, 2019
by
zhengjie
Browse files
优化user列表中的岗位DTO,修改@author信息,新增验证码登录
parent
c01435a0
Changes
172
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzLog.java
View file @
83dc7f8a
...
...
@@ -8,7 +8,7 @@ import java.io.Serializable;
import
java.sql.Timestamp
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
@Entity
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzJobRepository.java
View file @
83dc7f8a
...
...
@@ -3,28 +3,16 @@ package me.zhengjie.modules.quartz.repository;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
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
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
public
interface
QuartzJobRepository
extends
JpaRepository
<
QuartzJob
,
Long
>,
JpaSpecificationExecutor
{
/**
* 更新状态
* @param id
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update quartz_job set is_pause = 1 where id = ?1"
,
nativeQuery
=
true
)
void
updateIsPause
(
Long
id
);
/**
* 查询不是启用的任务
* 查询启用的任务
* @return
*/
List
<
QuartzJob
>
findByIsPauseIsFalse
();
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzLogRepository.java
View file @
83dc7f8a
...
...
@@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
public
interface
QuartzLogRepository
extends
JpaRepository
<
QuartzLog
,
Long
>,
JpaSpecificationExecutor
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java
View file @
83dc7f8a
...
...
@@ -15,7 +15,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
@Slf4j
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java
View file @
83dc7f8a
...
...
@@ -9,7 +9,7 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Pageable
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
@CacheConfig
(
cacheNames
=
"quartzJob"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java
View file @
83dc7f8a
...
...
@@ -4,7 +4,7 @@ import lombok.Data;
import
me.zhengjie.annotation.Query
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-6-4 10:33:02
*/
@Data
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
View file @
83dc7f8a
...
...
@@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.Optional
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
@Service
(
value
=
"quartzJobService"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java
View file @
83dc7f8a
...
...
@@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
/**
* 测试用
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-08
*/
@Slf4j
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/VisitsTask.java
View file @
83dc7f8a
...
...
@@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-12-25
*/
@Component
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java
View file @
83dc7f8a
...
...
@@ -11,7 +11,7 @@ import java.util.Date;
import
static
org
.
quartz
.
TriggerBuilder
.
newTrigger
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-01-07
*/
@Slf4j
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java
View file @
83dc7f8a
...
...
@@ -92,14 +92,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
).
anonymous
()
.
antMatchers
(
HttpMethod
.
POST
,
"/auth/"
+
loginPath
).
anonymous
()
.
antMatchers
(
"/
websocket/**
"
).
anonymous
()
.
antMatchers
(
"/
auth/vCode
"
).
anonymous
()
// 支付宝回调
.
antMatchers
(
"/api/aliPay/return"
).
anonymous
()
.
antMatchers
(
"/api/aliPay/notify"
).
anonymous
()
// 系统监控
.
antMatchers
(
"/actuator/**"
).
anonymous
()
// swagger start
.
antMatchers
(
"/swagger-ui.html"
).
anonymous
()
.
antMatchers
(
"/swagger-resources/**"
).
anonymous
()
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthenticationController.java
View file @
83dc7f8a
package
me.zhengjie.modules.security.rest
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.util.IdUtil
;
import
com.wf.captcha.Captcha
;
import
com.wf.captcha.SpecCaptcha
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.monitor.service.RedisService
;
import
me.zhengjie.modules.security.security.AuthenticationInfo
;
import
me.zhengjie.modules.security.security.AuthorizationUser
;
import
me.zhengjie.modules.security.security.ImgResult
;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.utils.EncryptUtils
;
import
me.zhengjie.modules.security.utils.JwtTokenUtil
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -16,9 +24,12 @@ import org.springframework.security.authentication.AccountExpiredException;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-11-23
* 授权、根据token获取用户详细信息
*/
...
...
@@ -33,6 +44,9 @@ public class AuthenticationController {
@Autowired
private
JwtTokenUtil
jwtTokenUtil
;
@Autowired
private
RedisService
redisService
;
@Autowired
@Qualifier
(
"jwtUserDetailsService"
)
private
UserDetailsService
userDetailsService
;
...
...
@@ -46,6 +60,16 @@ public class AuthenticationController {
@PostMapping
(
value
=
"${jwt.auth.path}"
)
public
ResponseEntity
login
(
@Validated
@RequestBody
AuthorizationUser
authorizationUser
){
// 查询验证码
String
code
=
redisService
.
getCodeVal
(
authorizationUser
.
getUuid
());
// 清除验证码
redisService
.
delete
(
authorizationUser
.
getUuid
());
if
(
StringUtils
.
isBlank
(
code
))
{
throw
new
BadRequestException
(
"验证码已过期"
);
}
if
(
StringUtils
.
isBlank
(
authorizationUser
.
getCode
())
||
!
authorizationUser
.
getCode
().
equalsIgnoreCase
(
code
))
{
throw
new
BadRequestException
(
"验证码错误"
);
}
final
JwtUser
jwtUser
=
(
JwtUser
)
userDetailsService
.
loadUserByUsername
(
authorizationUser
.
getUsername
());
if
(!
jwtUser
.
getPassword
().
equals
(
EncryptUtils
.
encryptPassword
(
authorizationUser
.
getPassword
()))){
...
...
@@ -72,4 +96,33 @@ public class AuthenticationController {
JwtUser
jwtUser
=
(
JwtUser
)
userDetailsService
.
loadUserByUsername
(
SecurityUtils
.
getUsername
());
return
ResponseEntity
.
ok
(
jwtUser
);
}
/**
* 获取验证码
*/
@GetMapping
(
value
=
"vCode"
)
public
ImgResult
getCode
(
HttpServletResponse
response
)
throws
IOException
{
// 三个参数分别为宽、高、位数
SpecCaptcha
specCaptcha
=
new
SpecCaptcha
(
105
,
33
,
4
);
// 设置类型,纯数字、纯字母、字母数字混合
specCaptcha
.
setCharType
(
Captcha
.
TYPE_DEFAULT
);
// 生成的验证码
String
code
=
specCaptcha
.
text
();
String
uuid
=
IdUtil
.
simpleUUID
();
redisService
.
saveCode
(
uuid
,
code
);
response
.
addHeader
(
"codeUuid"
,
uuid
);
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
try
{
specCaptcha
.
out
(
stream
);
return
new
ImgResult
(
Base64
.
encode
(
stream
.
toByteArray
()),
uuid
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
finally
{
stream
.
close
();
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthenticationInfo.java
View file @
83dc7f8a
...
...
@@ -5,7 +5,7 @@ import lombok.Getter;
import
java.io.Serializable
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-11-23
* 返回token
*/
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/security/AuthorizationUser.java
View file @
83dc7f8a
...
...
@@ -6,7 +6,7 @@ import lombok.Setter;
import
javax.validation.constraints.NotBlank
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-11-30
*/
@Getter
...
...
@@ -19,6 +19,10 @@ public class AuthorizationUser {
@NotBlank
private
String
password
;
private
String
code
;
private
String
uuid
=
""
;
@Override
public
String
toString
()
{
return
"{username="
+
username
+
", password= ******}"
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/security/ImgResult.java
0 → 100644
View file @
83dc7f8a
package
me.zhengjie.modules.security.security
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
/**
* @author Zheng Jie
* @date 2019-6-5 17:29:57
*/
@Data
@AllArgsConstructor
public
class
ImgResult
{
private
String
img
;
private
String
uuid
;
}
eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtUser.java
View file @
83dc7f8a
...
...
@@ -11,7 +11,7 @@ import java.util.Date;
import
java.util.stream.Collectors
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-11-23
*/
@Getter
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/service/JwtUserDetailsService.java
View file @
83dc7f8a
package
me.zhengjie.modules.security.service
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.system.domain.*
;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.modules.system.service.UserService
;
import
me.zhengjie.modules.system.service.dto.DeptDTO
;
import
me.zhengjie.modules.system.service.dto.JobDTO
;
import
me.zhengjie.modules.system.service.dto.UserDTO
;
import
me.zhengjie.modules.system.service.dto.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
...
...
@@ -16,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.Optional
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2018-11-22
*/
@Service
...
...
@@ -48,8 +45,8 @@ public class JwtUserDetailsService implements UserDetailsService {
user
.
getAvatar
(),
user
.
getEmail
(),
user
.
getPhone
(),
Optional
.
ofNullable
(
user
.
getDept
()).
map
(
DeptDTO:
:
getName
).
orElse
(
null
),
Optional
.
ofNullable
(
user
.
getJob
()).
map
(
JobDTO:
:
getName
).
orElse
(
null
),
Optional
.
ofNullable
(
user
.
getDept
()).
map
(
Dept
Small
DTO:
:
getName
).
orElse
(
null
),
Optional
.
ofNullable
(
user
.
getJob
()).
map
(
Job
Small
DTO:
:
getName
).
orElse
(
null
),
permissionService
.
mapToGrantedAuthorities
(
user
),
user
.
getEnabled
(),
user
.
getCreateTime
(),
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java
View file @
83dc7f8a
...
...
@@ -11,7 +11,7 @@ import java.io.Serializable;
import
java.util.Set
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-03-25
*/
@Entity
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java
View file @
83dc7f8a
...
...
@@ -10,7 +10,7 @@ import java.util.List;
import
java.util.Set
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-04-10
*/
@Entity
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java
View file @
83dc7f8a
...
...
@@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull;
import
java.io.Serializable
;
/**
* @author
j
ie
* @author
Zheng J
ie
* @date 2019-04-10
*/
@Entity
...
...
Prev
1
2
3
4
5
6
7
8
9
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