优化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的基本操作可根据需求自行扩展
- 实时控制台实时打印logback日志
- SQL监控采用druid 监控数据库访问性能默认用户名admin密码123456
- 定时任务整合Quartz做定时任务加入任务日志任务运行情况一目了然
- 代码生成高灵活度一键生成前后端代码减少百分之80左右的工作任务
@ -71,10 +70,9 @@ eladmin基于 Spring Boot 2.1.0 、 Jpa、 Spring Security、redis、Vue的前
</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/5cdf77639b1be47210.png"/></td>
<td><img src="https://i.loli.net/2019/05/18/5cdf77639929277783.png"/></td>
</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>
</tr>
</table>

View File

@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author jie
* @author Zheng Jie
* @date 2019-6-4 13:52:30
*/
@Target(ElementType.FIELD)
@ -49,7 +49,7 @@ public @interface Query {
}
/**
* @author jie
* @author Zheng Jie
* 使sql
*/
enum Join {

View File

@ -39,7 +39,6 @@ public class LimitAspect {
Method signatureMethod = signature.getMethod();
Limit limit = signatureMethod.getAnnotation(Limit.class);
LimitType limitType = limit.limitType();
String name = limit.name();
String key = limit.key();
if (StringUtils.isEmpty(key)) {
switch (limitType) {

View File

@ -6,7 +6,7 @@ import org.springframework.http.HttpStatus;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*
*/

View File

@ -7,7 +7,7 @@ import java.util.Map;
import java.util.stream.IntStream;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
public class EntityExistException extends RuntimeException {

View File

@ -7,7 +7,7 @@ import java.util.Map;
import java.util.stream.IntStream;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
public class EntityNotFoundException extends RuntimeException {

View File

@ -6,7 +6,7 @@ import lombok.Data;
import java.time.LocalDateTime;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
@Data

View File

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import static org.springframework.http.HttpStatus.*;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
@Slf4j

View File

@ -3,7 +3,7 @@ package me.zhengjie.mapper;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
public interface EntityMapper<D, E> {

View File

@ -22,7 +22,7 @@ import org.springframework.data.redis.serializer.RedisSerializationContext;
import java.time.Duration;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Slf4j

View File

@ -18,7 +18,7 @@ import java.util.List;
/**
* api /swagger-ui.html
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/

View File

@ -2,7 +2,7 @@ package me.zhengjie.utils;
/**
*
* @author jie
* @author Zheng Jie
* @date 2018-12-26
*/
public class ElAdminConstant {

View File

@ -9,7 +9,7 @@ import javax.crypto.spec.IvParameterSpec;
/**
*
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
public class EncryptUtils {

View File

@ -8,7 +8,7 @@ import java.text.DecimalFormat;
/**
* File hutool
* @author jie
* @author Zheng Jie
* @date 2018-12-27
*/
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
*/
public class PageUtil extends cn.hutool.core.util.PageUtil {

View File

@ -9,7 +9,7 @@ import java.lang.reflect.Field;
import java.util.*;
/**
* @author jie
* @author Zheng Jie
* @date 2019-6-4 14:59:48
*/
@Slf4j
@ -97,12 +97,14 @@ public class QueryHelp {
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) {
if (ObjectUtil.isNotEmpty(join)) {
return join.get(attributeName);
} else return root.get(attributeName);
}
@SuppressWarnings("unchecked")
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
@ -116,6 +118,7 @@ public class QueryHelp {
return true;
}
@SuppressWarnings("unchecked")
private static List<Field> getAllFields(Class clazz, List<Field> fields) {
if (clazz != null) {
fields.addAll(Arrays.asList(clazz.getDeclaredFields()));

View File

@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletRequest;
/**
* HttpServletRequest
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
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
*/
public class SecurityUtils {

View File

@ -5,7 +5,7 @@ import java.io.StringWriter;
/**
*
* @author jie
* @author Zheng Jie
* @date 2019-01-06
*/
public class ThrowableUtil {

View File

@ -5,7 +5,7 @@ import java.util.Optional;
/**
*
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
public class ValidationUtil{

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import me.zhengjie.domain.GenConfig;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-14
*/
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.*;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-14
*/
@RestController

View File

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-02
*/
@RestController

View File

@ -7,7 +7,7 @@ import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-14
*/
@CacheConfig(cacheNames = "genConfig")

View File

@ -5,7 +5,7 @@ import me.zhengjie.domain.vo.ColumnInfo;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-02
*/
public interface GeneratorService {

View File

@ -8,7 +8,7 @@ import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-14
*/
@Service

View File

@ -17,7 +17,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-02
*/
@Service

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Target(ElementType.METHOD)

View File

@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Component
@ -65,7 +65,7 @@ public class LogAspect {
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
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);
}

View File

@ -8,7 +8,7 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Entity
@ -63,7 +63,7 @@ public class Log implements Serializable {
*
*/
@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;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Repository

View File

@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@RestController

View File

@ -7,7 +7,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.Async;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
public interface LogService {

View File

@ -5,7 +5,7 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @author Zheng Jie
* @date 2019-5-22
*/
@Data

View File

@ -5,7 +5,7 @@ import me.zhengjie.annotation.Query;
/**
*
* @author jie
* @author Zheng Jie
* @date 2019-6-4 09:23:07
*/
@Data

View File

@ -6,7 +6,7 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @author Zheng Jie
* @date 2019-5-22
*/
@Data

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Method;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-24
*/
@Service

View File

@ -7,7 +7,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author jie
* @author Zheng Jie
* @date 2019-5-22
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)

View File

@ -7,7 +7,7 @@ import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author jie
* @author Zheng Jie
* @date 2019-5-22
*/
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)

View File

@ -15,8 +15,22 @@
<jjwt.version>0.9.1</jjwt.version>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- 验证码 -->
<dependency>
<groupId>com.github.whvcse</groupId>
<artifactId>EasyCaptcha</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>me.zhengjie</groupId>
<artifactId>eladmin-generator</artifactId>

View File

@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author jie
* @author Zheng Jie
* @date 2018/11/15 9:20:19
*/
@EnableAsync

View File

@ -18,7 +18,7 @@ import java.util.List;
/**
* WebMvcConfigurer
*
* @author jie
* @author Zheng Jie
* @date 2018-11-30
*/
@Configuration

View File

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

View File

@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
/**
*
* @author jie
* @author Zheng Jie
*/
@Component
public class VisitsInitialization implements ApplicationRunner {

View File

@ -9,7 +9,7 @@ import java.sql.Timestamp;
/**
* pv ip
*
* @author jie
* @author Zheng Jie
* @date 2018-12-13
*/
@Entity

View File

@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-10
*/
@Data

View File

@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-13
*/
@Repository

View File

@ -12,7 +12,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-10
*/
@RestController

View File

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-13
*/
@RestController

View File

@ -6,7 +6,7 @@ import org.springframework.data.domain.Pageable;
/**
*
* @author jie
* @author Zheng Jie
* @date 2018-12-10
*/
public interface RedisService {
@ -16,16 +16,30 @@ public interface RedisService {
* @param key
* @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
* @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;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-13
*/
public interface VisitsService {

View File

@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-10
*/
@Service
@ -23,7 +23,7 @@ public class RedisServiceImpl implements RedisService {
RedisTemplate redisTemplate;
@Override
public Page findByKey(String key, Pageable pageable){
public Page<RedisVo> findByKey(String key, Pageable pageable){
List<RedisVo> redisVos = new ArrayList<>();
if(!key.equals("*")){
key = "*" + key + "*";
@ -43,6 +43,8 @@ public class RedisServiceImpl implements RedisService {
return page;
}
@Override
public void delete(String key) {
redisTemplate.delete(key);
@ -51,6 +53,20 @@ public class RedisServiceImpl implements RedisService {
@Override
public void 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;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-13
*/
@Slf4j

View File

@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Component

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Data

View File

@ -8,7 +8,7 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Entity

View File

@ -3,28 +3,16 @@ package me.zhengjie.modules.quartz.repository;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
public interface QuartzJobRepository extends JpaRepository<QuartzJob,Long>, JpaSpecificationExecutor {
/**
*
* @param id
*/
@Transactional(rollbackFor = Exception.class)
@Modifying
@Query(value = "update quartz_job set is_pause = 1 where id = ?1",nativeQuery = true)
void updateIsPause(Long id);
/**
*
*
* @return
*/
List<QuartzJob> findByIsPauseIsFalse();

View File

@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
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.*;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Slf4j

View File

@ -9,7 +9,7 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@CacheConfig(cacheNames = "quartzJob")

View File

@ -4,7 +4,7 @@ import lombok.Data;
import me.zhengjie.annotation.Query;
/**
* @author jie
* @author Zheng Jie
* @date 2019-6-4 10:33:02
*/
@Data

View File

@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Service(value = "quartzJobService")

View File

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

View File

@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-25
*/
@Component

View File

@ -11,7 +11,7 @@ import java.util.Date;
import static org.quartz.TriggerBuilder.newTrigger;
/**
* @author jie
* @author Zheng Jie
* @date 2019-01-07
*/
@Slf4j

View File

@ -92,14 +92,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
).anonymous()
.antMatchers( HttpMethod.POST,"/auth/"+loginPath).anonymous()
.antMatchers("/websocket/**").anonymous()
.antMatchers("/auth/vCode").anonymous()
// 支付宝回调
.antMatchers("/api/aliPay/return").anonymous()
.antMatchers("/api/aliPay/notify").anonymous()
// 系统监控
.antMatchers("/actuator/**").anonymous()
// swagger start
.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()

View File

@ -1,13 +1,21 @@
package me.zhengjie.modules.security.rest;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.IdUtil;
import com.wf.captcha.Captcha;
import com.wf.captcha.SpecCaptcha;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.monitor.service.RedisService;
import me.zhengjie.modules.security.security.AuthenticationInfo;
import me.zhengjie.modules.security.security.AuthorizationUser;
import me.zhengjie.modules.security.security.ImgResult;
import me.zhengjie.modules.security.security.JwtUser;
import me.zhengjie.utils.EncryptUtils;
import me.zhengjie.modules.security.utils.JwtTokenUtil;
import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
@ -16,9 +24,12 @@ import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
* token
*/
@ -33,6 +44,9 @@ public class AuthenticationController {
@Autowired
private JwtTokenUtil jwtTokenUtil;
@Autowired
private RedisService redisService;
@Autowired
@Qualifier("jwtUserDetailsService")
private UserDetailsService userDetailsService;
@ -46,6 +60,16 @@ public class AuthenticationController {
@PostMapping(value = "${jwt.auth.path}")
public ResponseEntity login(@Validated @RequestBody AuthorizationUser authorizationUser){
// 查询验证码
String code = redisService.getCodeVal(authorizationUser.getUuid());
// 清除验证码
redisService.delete(authorizationUser.getUuid());
if (StringUtils.isBlank(code)) {
throw new BadRequestException("验证码已过期");
}
if (StringUtils.isBlank(authorizationUser.getCode()) || !authorizationUser.getCode().equalsIgnoreCase(code)) {
throw new BadRequestException("验证码错误");
}
final JwtUser jwtUser = (JwtUser) userDetailsService.loadUserByUsername(authorizationUser.getUsername());
if(!jwtUser.getPassword().equals(EncryptUtils.encryptPassword(authorizationUser.getPassword()))){
@ -72,4 +96,33 @@ public class AuthenticationController {
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
return ResponseEntity.ok(jwtUser);
}
/**
*
*/
@GetMapping(value = "vCode")
public ImgResult getCode(HttpServletResponse response) throws IOException {
// 三个参数分别为宽、高、位数
SpecCaptcha specCaptcha = new SpecCaptcha(105, 33, 4);
// 设置类型,纯数字、纯字母、字母数字混合
specCaptcha.setCharType(Captcha.TYPE_DEFAULT);
// 生成的验证码
String code = specCaptcha.text();
String uuid = IdUtil.simpleUUID();
redisService.saveCode(uuid,code);
response.addHeader("codeUuid",uuid);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
specCaptcha.out(stream);
return new ImgResult(Base64.encode(stream.toByteArray()),uuid);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
stream.close();
}
}
}

View File

@ -5,7 +5,7 @@ import lombok.Getter;
import java.io.Serializable;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
* token
*/

View File

@ -6,7 +6,7 @@ import lombok.Setter;
import javax.validation.constraints.NotBlank;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-30
*/
@Getter
@ -19,6 +19,10 @@ public class AuthorizationUser {
@NotBlank
private String password;
private String code;
private String uuid = "";
@Override
public String toString() {
return "{username=" + username + ", password= ******}";

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;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-23
*/
@Getter

View File

@ -1,12 +1,9 @@
package me.zhengjie.modules.security.service;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.security.security.JwtUser;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.DeptDTO;
import me.zhengjie.modules.system.service.dto.JobDTO;
import me.zhengjie.modules.system.service.dto.UserDTO;
import me.zhengjie.modules.system.service.dto.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
@ -16,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-22
*/
@Service
@ -48,8 +45,8 @@ public class JwtUserDetailsService implements UserDetailsService {
user.getAvatar(),
user.getEmail(),
user.getPhone(),
Optional.ofNullable(user.getDept()).map(DeptDTO::getName).orElse(null),
Optional.ofNullable(user.getJob()).map(JobDTO::getName).orElse(null),
Optional.ofNullable(user.getDept()).map(DeptSmallDTO::getName).orElse(null),
Optional.ofNullable(user.getJob()).map(JobSmallDTO::getName).orElse(null),
permissionService.mapToGrantedAuthorities(user),
user.getEnabled(),
user.getCreateTime(),

View File

@ -11,7 +11,7 @@ import java.io.Serializable;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-25
*/
@Entity

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
@Entity

View File

@ -6,7 +6,7 @@ import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
@Entity

View File

@ -11,7 +11,7 @@ import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-29
*/
@Entity

View File

@ -12,7 +12,7 @@ import java.sql.Timestamp;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-17
*/
@Entity

View File

@ -12,7 +12,7 @@ import java.sql.Timestamp;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-03
*/
@Entity

View File

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

View File

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

View File

@ -5,7 +5,7 @@ import lombok.Data;
import java.io.Serializable;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-20
*/
@Data

View File

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

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-25
*/
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;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
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;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
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;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-29
*/
public interface JobRepository extends JpaRepository<Job, Long>, JpaSpecificationExecutor {

View File

@ -11,7 +11,7 @@ import java.util.List;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-17
*/
public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificationExecutor {

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-03
*/
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;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-03
*/
public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificationExecutor {

View File

@ -12,7 +12,7 @@ import java.util.Date;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2018-11-22
*/
public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificationExecutor {

View File

@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-25
*/
@RestController

View File

@ -14,7 +14,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
@RestController

View File

@ -16,7 +16,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author jie
* @author Zheng Jie
* @date 2019-04-10
*/
@RestController

View File

@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.Set;
/**
* @author jie
* @author Zheng Jie
* @date 2019-03-29
*/
@RestController

View File

@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author jie
* @author Zheng Jie
* @date 2018-12-03
*/
@RestController

Some files were not shown because too many files have changed in this diff Show More