优化user列表中的岗位DTO,修改@author信息,新增验证码登录

pull/127/head
zhengjie 2019-06-10 16:49:51 +08:00
parent c01435a059
commit 83dc7f8a18
172 changed files with 378 additions and 200 deletions

View File

@ -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>

View File

@ -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 {

View File

@ -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) {

View File

@ -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
* *
*/ */

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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> {

View File

@ -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

View File

@ -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
*/ */

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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()));

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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{

View File

@ -5,7 +5,7 @@ import javax.persistence.*;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-01-03 * @date 2019-01-03
*/ */
@Data @Data

View File

@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-01-02 * @date 2019-01-02
*/ */
@Data @Data

View File

@ -6,7 +6,7 @@ import lombok.NoArgsConstructor;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-01-02 * @date 2019-01-02
*/ */
@Data @Data

View File

@ -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> {

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -5,7 +5,7 @@ import org.apache.commons.configuration.*;
/** /**
* sqljava * sqljava
* *
* @author jie * @author Zheng Jie
* @date 2019-01-03 * @date 2019-01-03
*/ */
public class ColUtil { public class ColUtil {

View File

@ -18,7 +18,7 @@ import java.util.Map;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-01-02 * @date 2019-01-02
*/ */
@Slf4j @Slf4j

View File

@ -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)

View File

@ -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);
} }

View File

@ -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;
/** /**
* *

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -17,7 +17,7 @@ import java.util.Set;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-4-1 * @date 2019-4-1
*/ */
@Component @Component

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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();
} }

View File

@ -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 {

View File

@ -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);
} }
} }

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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 {

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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")

View File

@ -5,7 +5,7 @@ import org.springframework.stereotype.Component;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2019-01-08 * @date 2019-01-08
*/ */
@Slf4j @Slf4j

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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();
}
}
} }

View File

@ -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
*/ */

View File

@ -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= ******}";

View File

@ -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;
}

View File

@ -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

View File

@ -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(),

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -15,7 +15,7 @@ import java.util.Set;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2018-11-22 * @date 2018-11-22
*/ */
@Entity @Entity

View File

@ -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

View File

@ -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

View File

@ -8,7 +8,7 @@ import java.util.List;
/** /**
* *
* @author jie * @author Zheng Jie
* @date 2018-12-20 * @date 2018-12-20
*/ */
@Data @Data

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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