Skip to content

Commit

Permalink
SysLoginLog / package optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
geekidea committed Mar 24, 2020
1 parent d89ced7 commit 67954f1
Show file tree
Hide file tree
Showing 83 changed files with 743 additions and 387 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
- Add `SpringBootPlusException`,`DaoException` 自定义异常类
- Add `ShiroConfig`, `ShiroPermissionConfig`, `ShiroProperties` Shiro配置类
- Add `JwtCredentialsMatcher`, `JwtFilter`, `JwtProperties`, `JwtRealm`, `JwtToken` JWT配置
- Add `LoginRedisService`, `LoginRedisServiceImpl` Redis登陆缓存处理
- Add `LoginRedisService`, `LoginRedisServiceImpl` Redis登录缓存处理

### 🐞 Bug Fixes
- fix startup.sh启动jar指定logback.xml
Expand Down
2 changes: 1 addition & 1 deletion admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spring:
url: https://springboot.plus
order: 2000

# Spring Boot Admin 登陆账号密码
# Spring Boot Admin 登录账号密码
spring-boot-plus:
admin:
username: admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* spring-boot-plus 项目启动入口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ protected void getResponseResult(Object result) {

@Override
protected void finish(RequestInfo requestInfo, OperationLogInfo operationLogInfo, Object result, Exception exception) {
// 异步保存日志
// 异步保存操作日志
super.saveSysOperationLog(requestInfo, operationLogInfo, result, exception);
// 异步保存登录日志
super.saveSysLoginLog(requestInfo, operationLogInfo, result, exception);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import io.geekidea.springbootplus.config.constant.DatePattern;
import io.geekidea.springbootplus.framework.config.jackson.deserializer.JacksonDateDeserializer;
import io.geekidea.springbootplus.framework.config.jackson.deserializer.JacksonDoubleDeserializer;
import io.geekidea.springbootplus.framework.config.jackson.serializer.JacksonDateSerializer;
import io.geekidea.springbootplus.framework.config.jackson.serializer.JacksonIntegerDeserializer;
import io.geekidea.springbootplus.config.constant.DatePattern;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import javax.servlet.http.HttpSession;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public ApiResult springBootPlusExceptionHandler(SpringBootPlusException exceptio


/**
* 登陆授权异常处理
* 登录授权异常处理
*
* @param exception
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface CommonConstant {
String LOGIN_SYS_USER = "loginSysUser";

/**
* 登陆token
* 登录token
*/
String JWT_DEFAULT_TOKEN_NAME = "token";

Expand Down Expand Up @@ -113,7 +113,7 @@ public interface CommonConstant {
String SPOT_SPOT_BACKSLASH = "../";

/**
* SpringBootAdmin登陆信息
* SpringBootAdmin登录信息
*/
String ADMIN_LOGIN_SESSION = "adminLoginSession";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@
public interface CommonRedisKey {

/**
* 登陆用户token信息key
* 登录用户token信息key
* login:token:tokenMd5
*/
String LOGIN_TOKEN = "login:token:%s";

/**
* 登陆用户信息key
* 登录用户信息key
* login:user:username
*/
String LOGIN_USER = "login:user:%s";

/**
* 登陆用户盐值信息key
* 登录用户盐值信息key
* login:salt:username
*/
String LOGIN_SALT= "login:salt:%s";

/**
* 登陆用户username token
* 登录用户username token
* login:user:token:username:token
*/
String LOGIN_USER_TOKEN = "login:user:token:%s:%s";

/**
* 登陆用户下的所有token
* 登录用户下的所有token
* login:user:token:username:*
*/
String LOGIN_USER_ALL_TOKEN = "login:user:token:%s:*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class JwtProperties {
private boolean redisCheck;

/**
* 单用户登陆,一个用户只能又一个有效的token
* 单用户登录,一个用户只能又一个有效的token
*/
private boolean singleLogin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

/**
Expand All @@ -49,6 +48,11 @@ public class SpringBootPlusAopProperties {
@NestedConfigurationProperty
private OperationLogConfig operationLog;

/**
* 登录日志配置
*/
private LoginLogConfig loginLog;

@Data
public static class AopConfig {

Expand Down Expand Up @@ -102,4 +106,27 @@ public static class OperationLogConfig {

}

/**
* 登录日志配置
*/
@Data
public static class LoginLogConfig {

/**
* 是否启用
*/
private boolean enable = true;

/**
* 登录路径
*/
private String loginPath = "/login";

/**
* 登出路径
*/
private String logoutPath = "/logout";

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public class SpringBootPlusProperties {
private boolean enableVerifyCode;

/**
* 新建登陆用户初始化盐值
* 新建登录用户初始化盐值
*/
private String loginInitSalt;

/**
* 新建登陆用户初始化密码
* 新建登录用户初始化密码
*/
private String loginInitPassword;

Expand Down
18 changes: 13 additions & 5 deletions config/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ spring-boot-plus:
# 服务器IP地址
server-ip: 127.0.0.1
# 是否启用验证码
enable-verify-code: true
# 默认新建用户登陆初始化密码
enable-verify-code: false
# 默认新建用户登录初始化密码
login-init-salt: 666666
login-init-password: admin
login-init-head: http://${spring-boot-plus.server-ip}:8888/api/resource/logo.png
Expand Down Expand Up @@ -104,6 +104,14 @@ spring-boot-plus:
enable: true
# 排除的路径
exclude-paths:
# 登录日志配置
login-log:
# 是否启用
enable: true
# 登录地址
login-path: /login
# 登出地址
logout-path: /logout

# 文件上传下载配置
# 上传路径配置
Expand Down Expand Up @@ -156,8 +164,8 @@ spring-boot-plus:
enable: false
# 权限配置
anon:
# 排除登陆登出
# 排除登陆登出
# 排除登录登出
# 排除登录登出
- /login,/logout
# 排除静态资源
- /static/**,/templates/**
Expand Down Expand Up @@ -198,7 +206,7 @@ spring-boot-plus:
refresh-token-countdown: 600
# redis校验jwt token是否存在,可选
redis-check: true
# true: 同一个账号只能是最后一次登陆token有效,false:同一个账号可多次登陆
# true: 同一个账号只能是最后一次登录token有效,false:同一个账号可多次登录
single-login: false
# 盐值校验,如果不加自定义盐值,则使用secret校验
salt-check: true
Expand Down
4 changes: 2 additions & 2 deletions docs/bin/install/install-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ TEMP_PWD=$(grep 'temporary password' /var/log/mysqld.log)
PWD=${TEMP_PWD##* }
echo "${PWD}"

# 登陆
# 登录
mysql -uroot -p${PWD}

# 进入到mysql命令行时,修改密码
# 修改密码
# ALTER USER 'root'@'localhost' IDENTIFIED BY 'Springbootplus666!';

# 使用新密码登陆
# 使用新密码登录
# exit
# mysql -uroot -pSpringbootplus666!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@
package com.example.foobar.controller;

import com.example.foobar.entity.FooBar;
import com.example.foobar.service.FooBarService;
import lombok.extern.slf4j.Slf4j;
import com.example.foobar.param.FooBarPageParam;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import com.example.foobar.service.FooBarService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.common.param.IdParam;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import org.springframework.validation.annotation.Validated;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
Expand Down Expand Up @@ -109,6 +108,7 @@ public ApiResult<FooBar> getFooBar(@PathVariable("id") Long id) throws Exception
@ApiOperation(value = "FooBar分页列表", response = FooBar.class)
public ApiResult<Paging<FooBar>> getFooBarPageList(@Validated @RequestBody FooBarPageParam fooBarPageParam) throws Exception {
Paging<FooBar> paging = fooBarService.getFooBarPageList(fooBarPageParam);
System.out.println(1 / 0);
return ApiResult.ok(paging);
}

Expand Down
11 changes: 4 additions & 7 deletions example/src/main/java/com/example/foobar/entity/FooBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

package com.example.foobar.entity;

import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
Expand All @@ -31,8 +29,7 @@

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import java.util.Date;

/**
* FooBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.foobar.entity.FooBar;
import com.example.foobar.param.FooBarPageParam;

import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;

/**
* FooBar Mapper 接口
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package com.example.foobar.param;

import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;

/**
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

package com.example.foobar.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.foobar.entity.FooBar;
import com.example.foobar.mapper.FooBarMapper;
import com.example.foobar.service.FooBarService;
import com.example.foobar.param.FooBarPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.foobar.service.FooBarService;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* FooBar 服务实现类
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

Expand Down
Loading

0 comments on commit 67954f1

Please sign in to comment.