mirror of https://github.com/elunez/eladmin
优化user列表中的岗位DTO,修改@author信息,新增验证码登录
parent
c01435a059
commit
83dc7f8a18
|
@ -35,7 +35,6 @@ eladmin基于 Spring Boot 2.1.0 、 Jpa、 Spring Security、redis、Vue的前
|
||||||
- 操作日志:记录用户操作的日志
|
- 操作日志:记录用户操作的日志
|
||||||
- 异常日志:记录异常日志,方便开发人员定位错误
|
- 异常日志:记录异常日志,方便开发人员定位错误
|
||||||
- 系统缓存:使用jedis将缓存操作可视化,并提供对redis的基本操作,可根据需求自行扩展
|
- 系统缓存:使用jedis将缓存操作可视化,并提供对redis的基本操作,可根据需求自行扩展
|
||||||
- 实时控制台:实时打印logback日志
|
|
||||||
- SQL监控:采用druid 监控数据库访问性能,默认用户名admin,密码123456
|
- SQL监控:采用druid 监控数据库访问性能,默认用户名admin,密码123456
|
||||||
- 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然
|
- 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然
|
||||||
- 代码生成:高灵活度一键生成前后端代码,减少百分之80左右的工作任务
|
- 代码生成:高灵活度一键生成前后端代码,减少百分之80左右的工作任务
|
||||||
|
@ -71,10 +70,9 @@ eladmin基于 Spring Boot 2.1.0 、 Jpa、 Spring Security、redis、Vue的前
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://i.loli.net/2019/05/18/5cdf77632b4b090165.png"/></td>
|
<td><img src="https://i.loli.net/2019/05/18/5cdf77632b4b090165.png"/></td>
|
||||||
<td><img src="https://i.loli.net/2019/05/18/5cdf77639b1be47210.png"/></td>
|
<td><img src="https://i.loli.net/2019/05/18/5cdf77639929277783.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><img src="https://i.loli.net/2019/05/18/5cdf77639929277783.png"/></td>
|
|
||||||
<td><img src="https://i.loli.net/2019/05/18/5cdf78969adc389599.png"/></td>
|
<td><img src="https://i.loli.net/2019/05/18/5cdf78969adc389599.png"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-6-4 13:52:30
|
* @date 2019-6-4 13:52:30
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
|
@ -49,7 +49,7 @@ public @interface Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询
|
* 适用于简单连接查询,复杂的请自定义该注解,或者使用sql查询
|
||||||
*/
|
*/
|
||||||
enum Join {
|
enum Join {
|
||||||
|
|
|
@ -39,7 +39,6 @@ public class LimitAspect {
|
||||||
Method signatureMethod = signature.getMethod();
|
Method signatureMethod = signature.getMethod();
|
||||||
Limit limit = signatureMethod.getAnnotation(Limit.class);
|
Limit limit = signatureMethod.getAnnotation(Limit.class);
|
||||||
LimitType limitType = limit.limitType();
|
LimitType limitType = limit.limitType();
|
||||||
String name = limit.name();
|
|
||||||
String key = limit.key();
|
String key = limit.key();
|
||||||
if (StringUtils.isEmpty(key)) {
|
if (StringUtils.isEmpty(key)) {
|
||||||
switch (limitType) {
|
switch (limitType) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.http.HttpStatus;
|
||||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
* 统一异常处理
|
* 统一异常处理
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
public class EntityExistException extends RuntimeException {
|
public class EntityExistException extends RuntimeException {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
public class EntityNotFoundException extends RuntimeException {
|
public class EntityNotFoundException extends RuntimeException {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
import static org.springframework.http.HttpStatus.*;
|
import static org.springframework.http.HttpStatus.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -3,7 +3,7 @@ package me.zhengjie.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
public interface EntityMapper<D, E> {
|
public interface EntityMapper<D, E> {
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api页面 /swagger-ui.html
|
* api页面 /swagger-ui.html
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package me.zhengjie.utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常用静态常量
|
* 常用静态常量
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-26
|
* @date 2018-12-26
|
||||||
*/
|
*/
|
||||||
public class ElAdminConstant {
|
public class ElAdminConstant {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import javax.crypto.spec.IvParameterSpec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
public class EncryptUtils {
|
public class EncryptUtils {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.text.DecimalFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File工具类,扩展 hutool 工具包
|
* File工具类,扩展 hutool 工具包
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-27
|
* @date 2018-12-27
|
||||||
*/
|
*/
|
||||||
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
public class FileUtil extends cn.hutool.core.io.FileUtil {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页工具
|
* 分页工具
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-10
|
* @date 2018-12-10
|
||||||
*/
|
*/
|
||||||
public class PageUtil extends cn.hutool.core.util.PageUtil {
|
public class PageUtil extends cn.hutool.core.util.PageUtil {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-6-4 14:59:48
|
* @date 2019-6-4 14:59:48
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -97,12 +97,14 @@ public class QueryHelp {
|
||||||
return cb.and(list.toArray(new Predicate[list.size()]));
|
return cb.and(list.toArray(new Predicate[list.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
|
private static <T, R> Expression<T> getExpression(String attributeName, Join join, Root<R> root) {
|
||||||
if (ObjectUtil.isNotEmpty(join)) {
|
if (ObjectUtil.isNotEmpty(join)) {
|
||||||
return join.get(attributeName);
|
return join.get(attributeName);
|
||||||
} else return root.get(attributeName);
|
} else return root.get(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static boolean isBlank(final CharSequence cs) {
|
public static boolean isBlank(final CharSequence cs) {
|
||||||
int strLen;
|
int strLen;
|
||||||
if (cs == null || (strLen = cs.length()) == 0) {
|
if (cs == null || (strLen = cs.length()) == 0) {
|
||||||
|
@ -116,6 +118,7 @@ public class QueryHelp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static List<Field> getAllFields(Class clazz, List<Field> fields) {
|
private static List<Field> getAllFields(Class clazz, List<Field> fields) {
|
||||||
if (clazz != null) {
|
if (clazz != null) {
|
||||||
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
|
||||||
|
|
|
@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 HttpServletRequest
|
* 获取 HttpServletRequest
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
public class RequestHolder {
|
public class RequestHolder {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前登录的用户
|
* 获取当前登录的用户
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-17
|
* @date 2019-01-17
|
||||||
*/
|
*/
|
||||||
public class SecurityUtils {
|
public class SecurityUtils {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.io.StringWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 异常工具
|
* 异常工具
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-06
|
* @date 2019-01-06
|
||||||
*/
|
*/
|
||||||
public class ThrowableUtil {
|
public class ThrowableUtil {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证工具
|
* 验证工具
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
public class ValidationUtil{
|
public class ValidationUtil{
|
||||||
|
|
|
@ -5,7 +5,7 @@ import javax.persistence.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成配置
|
* 代码生成配置
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-03
|
* @date 2019-01-03
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列的数据信息
|
* 列的数据信息
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表的数据信息
|
* 表的数据信息
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -4,7 +4,7 @@ import me.zhengjie.domain.GenConfig;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-14
|
* @date 2019-01-14
|
||||||
*/
|
*/
|
||||||
public interface GenConfigRepository extends JpaRepository<GenConfig,Long> {
|
public interface GenConfigRepository extends JpaRepository<GenConfig,Long> {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-14
|
* @date 2019-01-14
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.cache.annotation.CachePut;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-14
|
* @date 2019-01-14
|
||||||
*/
|
*/
|
||||||
@CacheConfig(cacheNames = "genConfig")
|
@CacheConfig(cacheNames = "genConfig")
|
||||||
|
|
|
@ -5,7 +5,7 @@ import me.zhengjie.domain.vo.ColumnInfo;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
public interface GeneratorService {
|
public interface GeneratorService {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-14
|
* @date 2019-01-14
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.apache.commons.configuration.*;
|
||||||
/**
|
/**
|
||||||
* sql字段转java
|
* sql字段转java
|
||||||
*
|
*
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-03
|
* @date 2019-01-03
|
||||||
*/
|
*/
|
||||||
public class ColUtil {
|
public class ColUtil {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成
|
* 代码生成
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-02
|
* @date 2019-01-02
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@ -65,7 +65,7 @@ public class LogAspect {
|
||||||
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
|
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
|
||||||
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||||
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime);
|
Log log = new Log("ERROR",System.currentTimeMillis() - currentTime);
|
||||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(e));
|
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
|
||||||
logService.save(getUsername(), StringUtils.getIP(RequestHolder.getHttpServletRequest()), (ProceedingJoinPoint)joinPoint, log);
|
logService.save(getUsername(), StringUtils.getIP(RequestHolder.getHttpServletRequest()), (ProceedingJoinPoint)joinPoint, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -63,7 +63,7 @@ public class Log implements Serializable {
|
||||||
* 异常详细
|
* 异常详细
|
||||||
*/
|
*/
|
||||||
@Column(name = "exception_detail", columnDefinition = "text")
|
@Column(name = "exception_detail", columnDefinition = "text")
|
||||||
private String exceptionDetail;
|
private byte[] exceptionDetail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建日期
|
* 创建日期
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
public interface LogService {
|
public interface LogService {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-5-22
|
* @date 2019-5-22
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -5,7 +5,7 @@ import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志查询类
|
* 日志查询类
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-6-4 09:23:07
|
* @date 2019-6-4 09:23:07
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-5-22
|
* @date 2019-5-22
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-24
|
* @date 2018-11-24
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-5-22
|
* @date 2019-5-22
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.ReportingPolicy;
|
import org.mapstruct.ReportingPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-5-22
|
* @date 2019-5-22
|
||||||
*/
|
*/
|
||||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||||
|
|
|
@ -15,8 +15,22 @@
|
||||||
<jjwt.version>0.9.1</jjwt.version>
|
<jjwt.version>0.9.1</jjwt.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- 验证码 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.whvcse</groupId>
|
||||||
|
<artifactId>EasyCaptcha</artifactId>
|
||||||
|
<version>1.5.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-generator</artifactId>
|
<artifactId>eladmin-generator</artifactId>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018/11/15 9:20:19
|
* @date 2018/11/15 9:20:19
|
||||||
*/
|
*/
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* WebMvcConfigurer
|
* WebMvcConfigurer
|
||||||
*
|
*
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-30
|
* @date 2018-11-30
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限配置
|
* 数据权限配置
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-4-1
|
* @date 2019-4-1
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化站点统计
|
* 初始化站点统计
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class VisitsInitialization implements ApplicationRunner {
|
public class VisitsInitialization implements ApplicationRunner {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.sql.Timestamp;
|
||||||
/**
|
/**
|
||||||
* pv 与 ip 统计
|
* pv 与 ip 统计
|
||||||
*
|
*
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-13
|
* @date 2018-12-13
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-10
|
* @date 2018-12-10
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-13
|
* @date 2018-12-13
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-10
|
* @date 2018-12-10
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-13
|
* @date 2018-12-13
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可自行扩展
|
* 可自行扩展
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-10
|
* @date 2018-12-10
|
||||||
*/
|
*/
|
||||||
public interface RedisService {
|
public interface RedisService {
|
||||||
|
@ -16,16 +16,30 @@ public interface RedisService {
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Page findByKey(String key, Pageable pageable);
|
Page findByKey(String key, Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询验证码的值
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getCodeVal(String key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存验证码
|
||||||
|
* @param key
|
||||||
|
* @param val
|
||||||
|
*/
|
||||||
|
void saveCode(String key, Object val);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* delete
|
* delete
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public void delete(String key);
|
void delete(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清空所有缓存
|
* 清空所有缓存
|
||||||
*/
|
*/
|
||||||
public void flushdb();
|
void flushdb();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-13
|
* @date 2018-12-13
|
||||||
*/
|
*/
|
||||||
public interface VisitsService {
|
public interface VisitsService {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-10
|
* @date 2018-12-10
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@ -23,7 +23,7 @@ public class RedisServiceImpl implements RedisService {
|
||||||
RedisTemplate redisTemplate;
|
RedisTemplate redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page findByKey(String key, Pageable pageable){
|
public Page<RedisVo> findByKey(String key, Pageable pageable){
|
||||||
List<RedisVo> redisVos = new ArrayList<>();
|
List<RedisVo> redisVos = new ArrayList<>();
|
||||||
if(!key.equals("*")){
|
if(!key.equals("*")){
|
||||||
key = "*" + key + "*";
|
key = "*" + key + "*";
|
||||||
|
@ -43,6 +43,8 @@ public class RedisServiceImpl implements RedisService {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(String key) {
|
public void delete(String key) {
|
||||||
redisTemplate.delete(key);
|
redisTemplate.delete(key);
|
||||||
|
@ -51,6 +53,20 @@ public class RedisServiceImpl implements RedisService {
|
||||||
@Override
|
@Override
|
||||||
public void flushdb() {
|
public void flushdb() {
|
||||||
redisTemplate.getConnectionFactory().getConnection().flushDb();
|
redisTemplate.getConnectionFactory().getConnection().flushDb();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCodeVal(String key) {
|
||||||
|
try {
|
||||||
|
String value = redisTemplate.opsForValue().get(key).toString();
|
||||||
|
return value;
|
||||||
|
}catch (Exception e){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveCode(String key, Object val) {
|
||||||
|
redisTemplate.opsForValue().set(key,val,2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-13
|
* @date 2018-12-13
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -3,28 +3,16 @@ package me.zhengjie.modules.quartz.repository;
|
||||||
import me.zhengjie.modules.quartz.domain.QuartzJob;
|
import me.zhengjie.modules.quartz.domain.QuartzJob;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
public interface QuartzJobRepository extends JpaRepository<QuartzJob,Long>, JpaSpecificationExecutor {
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
List<QuartzJob> findByIsPauseIsFalse();
|
List<QuartzJob> findByIsPauseIsFalse();
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
public interface QuartzLogRepository extends JpaRepository<QuartzLog,Long>, JpaSpecificationExecutor {
|
public interface QuartzLogRepository extends JpaRepository<QuartzLog,Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@CacheConfig(cacheNames = "quartzJob")
|
@CacheConfig(cacheNames = "quartzJob")
|
||||||
|
|
|
@ -4,7 +4,7 @@ import lombok.Data;
|
||||||
import me.zhengjie.annotation.Query;
|
import me.zhengjie.annotation.Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-6-4 10:33:02
|
* @date 2019-6-4 10:33:02
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Service(value = "quartzJobService")
|
@Service(value = "quartzJobService")
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 测试用
|
* 测试用
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-08
|
* @date 2019-01-08
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-25
|
* @date 2018-12-25
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Date;
|
||||||
import static org.quartz.TriggerBuilder.newTrigger;
|
import static org.quartz.TriggerBuilder.newTrigger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -92,14 +92,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
).anonymous()
|
).anonymous()
|
||||||
|
|
||||||
.antMatchers( HttpMethod.POST,"/auth/"+loginPath).anonymous()
|
.antMatchers( HttpMethod.POST,"/auth/"+loginPath).anonymous()
|
||||||
.antMatchers("/websocket/**").anonymous()
|
.antMatchers("/auth/vCode").anonymous()
|
||||||
// 支付宝回调
|
// 支付宝回调
|
||||||
.antMatchers("/api/aliPay/return").anonymous()
|
.antMatchers("/api/aliPay/return").anonymous()
|
||||||
.antMatchers("/api/aliPay/notify").anonymous()
|
.antMatchers("/api/aliPay/notify").anonymous()
|
||||||
|
|
||||||
// 系统监控
|
|
||||||
.antMatchers("/actuator/**").anonymous()
|
|
||||||
|
|
||||||
// swagger start
|
// swagger start
|
||||||
.antMatchers("/swagger-ui.html").anonymous()
|
.antMatchers("/swagger-ui.html").anonymous()
|
||||||
.antMatchers("/swagger-resources/**").anonymous()
|
.antMatchers("/swagger-resources/**").anonymous()
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
package me.zhengjie.modules.security.rest;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhengjie.aop.log.Log;
|
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.AuthenticationInfo;
|
||||||
import me.zhengjie.modules.security.security.AuthorizationUser;
|
import me.zhengjie.modules.security.security.AuthorizationUser;
|
||||||
|
import me.zhengjie.modules.security.security.ImgResult;
|
||||||
import me.zhengjie.modules.security.security.JwtUser;
|
import me.zhengjie.modules.security.security.JwtUser;
|
||||||
import me.zhengjie.utils.EncryptUtils;
|
import me.zhengjie.utils.EncryptUtils;
|
||||||
import me.zhengjie.modules.security.utils.JwtTokenUtil;
|
import me.zhengjie.modules.security.utils.JwtTokenUtil;
|
||||||
import me.zhengjie.utils.SecurityUtils;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
|
import me.zhengjie.utils.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
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.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
* 授权、根据token获取用户详细信息
|
* 授权、根据token获取用户详细信息
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +44,9 @@ public class AuthenticationController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private JwtTokenUtil jwtTokenUtil;
|
private JwtTokenUtil jwtTokenUtil;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("jwtUserDetailsService")
|
@Qualifier("jwtUserDetailsService")
|
||||||
private UserDetailsService userDetailsService;
|
private UserDetailsService userDetailsService;
|
||||||
|
@ -46,6 +60,16 @@ public class AuthenticationController {
|
||||||
@PostMapping(value = "${jwt.auth.path}")
|
@PostMapping(value = "${jwt.auth.path}")
|
||||||
public ResponseEntity login(@Validated @RequestBody AuthorizationUser authorizationUser){
|
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());
|
final JwtUser jwtUser = (JwtUser) userDetailsService.loadUserByUsername(authorizationUser.getUsername());
|
||||||
|
|
||||||
if(!jwtUser.getPassword().equals(EncryptUtils.encryptPassword(authorizationUser.getPassword()))){
|
if(!jwtUser.getPassword().equals(EncryptUtils.encryptPassword(authorizationUser.getPassword()))){
|
||||||
|
@ -72,4 +96,33 @@ public class AuthenticationController {
|
||||||
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
|
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
|
||||||
return ResponseEntity.ok(jwtUser);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import lombok.Getter;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
* 返回token
|
* 返回token
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Setter;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-30
|
* @date 2018-11-30
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -19,6 +19,10 @@ public class AuthorizationUser {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String uuid = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "{username=" + username + ", password= ******}";
|
return "{username=" + username + ", password= ******}";
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
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;
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import java.util.Date;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package me.zhengjie.modules.security.service;
|
package me.zhengjie.modules.security.service;
|
||||||
|
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.modules.system.domain.*;
|
|
||||||
import me.zhengjie.modules.security.security.JwtUser;
|
import me.zhengjie.modules.security.security.JwtUser;
|
||||||
import me.zhengjie.modules.system.service.UserService;
|
import me.zhengjie.modules.system.service.UserService;
|
||||||
import me.zhengjie.modules.system.service.dto.DeptDTO;
|
import me.zhengjie.modules.system.service.dto.*;
|
||||||
import me.zhengjie.modules.system.service.dto.JobDTO;
|
|
||||||
import me.zhengjie.modules.system.service.dto.UserDTO;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
@ -16,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-22
|
* @date 2018-11-22
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@ -48,8 +45,8 @@ public class JwtUserDetailsService implements UserDetailsService {
|
||||||
user.getAvatar(),
|
user.getAvatar(),
|
||||||
user.getEmail(),
|
user.getEmail(),
|
||||||
user.getPhone(),
|
user.getPhone(),
|
||||||
Optional.ofNullable(user.getDept()).map(DeptDTO::getName).orElse(null),
|
Optional.ofNullable(user.getDept()).map(DeptSmallDTO::getName).orElse(null),
|
||||||
Optional.ofNullable(user.getJob()).map(JobDTO::getName).orElse(null),
|
Optional.ofNullable(user.getJob()).map(JobSmallDTO::getName).orElse(null),
|
||||||
permissionService.mapToGrantedAuthorities(user),
|
permissionService.mapToGrantedAuthorities(user),
|
||||||
user.getEnabled(),
|
user.getEnabled(),
|
||||||
user.getCreateTime(),
|
user.getCreateTime(),
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.io.Serializable;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-25
|
* @date 2019-03-25
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.sql.Timestamp;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-29
|
* @date 2019-03-29
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-17
|
* @date 2018-12-17
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-03
|
* @date 2018-12-03
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色
|
* 角色
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-22
|
* @date 2018-11-22
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-22
|
* @date 2018-11-22
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-20
|
* @date 2018-12-20
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构建前端路由时用到
|
* 构建前端路由时用到
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-20
|
* @date 2018-12-20
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-25
|
* @date 2019-03-25
|
||||||
*/
|
*/
|
||||||
public interface DeptRepository extends JpaRepository<Dept, Long>, JpaSpecificationExecutor {
|
public interface DeptRepository extends JpaRepository<Dept, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, JpaSpecificationExecutor {
|
public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificationExecutor {
|
public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-29
|
* @date 2019-03-29
|
||||||
*/
|
*/
|
||||||
public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor {
|
public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-17
|
* @date 2018-12-17
|
||||||
*/
|
*/
|
||||||
public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificationExecutor {
|
public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-03
|
* @date 2018-12-03
|
||||||
*/
|
*/
|
||||||
public interface PermissionRepository extends JpaRepository<Permission, Long>, JpaSpecificationExecutor {
|
public interface PermissionRepository extends JpaRepository<Permission, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-03
|
* @date 2018-12-03
|
||||||
*/
|
*/
|
||||||
public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificationExecutor {
|
public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-11-22
|
* @date 2018-11-22
|
||||||
*/
|
*/
|
||||||
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor {
|
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-25
|
* @date 2019-03-25
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-04-10
|
* @date 2019-04-10
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2019-03-29
|
* @date 2019-03-29
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jie
|
* @author Zheng Jie
|
||||||
* @date 2018-12-03
|
* @date 2018-12-03
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue