登录日志系统日志

master
shijie 4 years ago
parent 21f8e314a9
commit 39f77de163
  1. 24
      dq-financial-api/src/main/java/com/daqing/financial/hrauth/SystemLogControllerApi.java
  2. 83
      dq-financial-crms/src/main/java/com/daqing/financial/crms/config/CorsConfig.java
  3. 9
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/aspect/SysLogAspect.java
  4. 55
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/SystemLogController.java
  5. 3
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/LoginLogMapper.java
  6. 8
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/SystemLogMapper.java
  7. 2
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/LoginLogService.java
  8. 11
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/SystemLogService.java
  9. 17
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/LoginLogServiceImpl.java
  10. 32
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/SystemLogServiceImpl.java
  11. 4
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  12. 3
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/util/IpUtils.java
  13. 14
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/LoginLogMapper.xml
  14. 16
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/SystemLogMapper.xml
  15. 66
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/config/CorsConfig.java
  16. 3
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/ApiGlobalFilter.java
  17. 9
      dq-govern-gateway/src/main/java/com/daqing/financial/gateway/config/FinancialCorsConfiguration.java
  18. 5
      dq-govern-gateway/src/main/resources/jwt.properties

@ -0,0 +1,24 @@
package com.daqing.financial.hrauth;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* @Author: gongsj.
* @Description: 登录controllerApi定义
* @Date:Created in 2020/09/07 11:33.
* @Modified By:
*/
@Api(value = "系统日志相关操作", tags = "提供系统日志相关操作")
public interface SystemLogControllerApi {
@ApiOperation(value = "系统日志列表")
ResponseResult list(Integer page, Integer size);
@ApiOperation(value = "登录日志列表")
ResponseResult loginLogList(Integer page, Integer size);
}

@ -1,33 +1,50 @@
package com.daqing.financial.crms.config; //package com.daqing.financial.crms.config;
//
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Configuration; //import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.cors.CorsConfiguration; //import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; //import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.filter.CorsFilter; //import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
//
/** //import javax.servlet.http.HttpServletRequest;
* 实现基本的跨域请求 //import javax.servlet.http.HttpServletResponse;
* //
* @auther River ///**
* @date 2020/9/25 15:09 // * 实现基本的跨域请求
*/ // *
@Configuration // * @auther River
public class CorsConfig { // * @date 2020/9/25 15:09
// */
@Bean //@Configuration
public CorsFilter corsFilter() { //public class CorsConfig extends WebMvcConfigurerAdapter {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); //
final CorsConfiguration corsConfiguration = new CorsConfiguration(); //
/*是否允许请求带有验证信息*/ // @Override
corsConfiguration.setAllowCredentials(true); // public void addInterceptors(InterceptorRegistry registry) {
/*允许访问的客户端域名*/ // registry.addInterceptor(new HandlerInterceptor() {
corsConfiguration.addAllowedOrigin("*"); // @Override
/*允许服务端访问的客户端请求头*/ // public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
corsConfiguration.addAllowedHeader("*"); // throws Exception {
/*允许访问的方法名,GET POST等*/ // // boolean isTrue = envConfig.getIsDev();//判断是测试服才需要解决跨域问题
corsConfiguration.addAllowedMethod("*"); // //if (isTrue) {
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); // response.addHeader("Access-Control-Allow-Origin", "*");
return new CorsFilter(urlBasedCorsConfigurationSource); // response.addHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
} // response.addHeader("Access-Control-Allow-Headers",
} // "Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,token");
// // }
// return true;
// }
//
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// ModelAndView modelAndView) throws Exception {
//
// }
//
// @Override
// public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
// Exception ex) throws Exception {
// }
// });
// }
//}

@ -22,20 +22,15 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* @ClassName actionLogAspect * @ClassName SysLogAspect
* @Description 操作日志切面 * @Description 操作日志切面
* @Author Rogers * @Date 2020/9/30
* @Date 2020/7/3 23:24
* @Version 1.0 * @Version 1.0
*/ */
@Slf4j @Slf4j
@Aspect @Aspect
@Component @Component
public class SysLogAspect { public class SysLogAspect {
/* @Resource
private ISystemLogService logService;
@Resource
private SystemLogMapper systemLogMapper;*/
@Resource @Resource
private Operation operation; private Operation operation;

@ -0,0 +1,55 @@
package com.daqing.financial.hrauth.controller;
import com.daqing.financial.hrauth.SystemLogControllerApi;
import com.daqing.financial.hrauth.UserLoginControllerApi;
import com.daqing.financial.hrauth.annotation.Log;
import com.daqing.financial.hrauth.enums.OperationType;
import com.daqing.financial.hrauth.enums.OperationUnit;
import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.financial.hrauth.service.SystemLogService;
import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
/**
* @auther River
* @date 2020/9/22 15:27
*/
@RestController
@RequestMapping("/hrms/auth/systemLog")
@Api(tags = {"日志管理"})
public class SystemLogController implements SystemLogControllerApi {
@Autowired
private SystemLogService systemLogService;
@Autowired
private LoginLogService loginLogService;
@GetMapping("/list")
@Log(detail = "系统日志列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.SELECT)
public ResponseResult list(@RequestParam("page") Integer page,
@RequestParam("size") Integer size) {
PageUtils data = systemLogService.queryPage(page, size);
return new ResponseResult<PageUtils>().SUCCESS(data);
}
@GetMapping("/loginLogList")
@Log(detail = "登录日志列表",level = 3,operationUnit = OperationUnit.ROLE,operationType = OperationType.SELECT)
public ResponseResult loginLogList(@RequestParam("page") Integer page,
@RequestParam("size") Integer size) {
PageUtils data = loginLogService.queryPage(page, size);
return new ResponseResult<PageUtils>().SUCCESS(data);
}
}

@ -1,9 +1,12 @@
package com.daqing.financial.hrauth.dao; package com.daqing.financial.hrauth.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface LoginLogMapper extends BaseMapper<LoginLog> { public interface LoginLogMapper extends BaseMapper<LoginLog> {
IPage<LoginLog> pageByCondition(Page page);
} }

@ -2,17 +2,19 @@ package com.daqing.financial.hrauth.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.daqing.framework.domain.hrms.SystemLog; import com.daqing.framework.domain.hrms.SystemLog;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* @ClassName UserActionMapper * @ClassName SystemLogMapper
* @Description 用户动作记录 * @Description 用户动作记录
* @Author Rogers * @Date 2020/9/30
* @Date 2020/7/3 22:08
* @Version 1.0 * @Version 1.0
*/ */
@Mapper @Mapper
public interface SystemLogMapper extends BaseMapper<SystemLog> { public interface SystemLogMapper extends BaseMapper<SystemLog> {
IPage<SystemLog> pageByCondition(Page page);
} }

@ -2,6 +2,8 @@ package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.utils.PageUtils;
public interface LoginLogService extends IService<LoginLog> { public interface LoginLogService extends IService<LoginLog> {
PageUtils queryPage(Integer page, Integer size);
} }

@ -0,0 +1,11 @@
package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.utils.PageUtils;
public interface SystemLogService extends IService<SystemLog> {
PageUtils queryPage(Integer page, Integer size);
}

@ -1,11 +1,28 @@
package com.daqing.financial.hrauth.service.impl; package com.daqing.financial.hrauth.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrauth.dao.LoginLogMapper; import com.daqing.financial.hrauth.dao.LoginLogMapper;
import com.daqing.financial.hrauth.service.LoginLogService; import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.framework.domain.hrms.LoginLog; import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.utils.PageUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService { public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, LoginLog> implements LoginLogService {
@Override
public PageUtils queryPage(Integer page, Integer size) {
//分页参数
if (page <= 0) {
page = 1;
}
if (size <= 0) {
size = 10;
}
IPage<LoginLog> loginLogVo = this.getBaseMapper().pageByCondition(new Page(page, size));
return new PageUtils(loginLogVo);
}
} }

@ -0,0 +1,32 @@
package com.daqing.financial.hrauth.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.daqing.financial.hrauth.dao.LoginLogMapper;
import com.daqing.financial.hrauth.dao.SystemLogMapper;
import com.daqing.financial.hrauth.service.LoginLogService;
import com.daqing.financial.hrauth.service.SystemLogService;
import com.daqing.framework.domain.hrms.EmployeeEntity;
import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.SystemLog;
import com.daqing.framework.domain.hrms.ext.EmployeeVO;
import com.daqing.framework.utils.PageUtils;
import org.springframework.stereotype.Service;
@Service
public class SystemLogServiceImpl extends ServiceImpl<SystemLogMapper, SystemLog> implements SystemLogService {
@Override
public PageUtils queryPage(Integer page, Integer size) {
//分页参数
if (page <= 0) {
page = 1;
}
if (size <= 0) {
size = 10;
}
IPage<SystemLog> systemLogVo = this.getBaseMapper().pageByCondition(new Page(page, size));
return new PageUtils(systemLogVo);
}
}

@ -134,9 +134,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
} }
//登录成功,token生成 //登录成功,token生成
long times = 84600; long times = 8460000;
if(loginRequest.getTenDayEffective() == 1){ if(loginRequest.getTenDayEffective() == 1){
times = 846000; times = 846000000;
} }
String token = JwtUtils.createJWT(userEntity.getId()+"","token", times); String token = JwtUtils.createJWT(userEntity.getId()+"","token", times);
Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("user_id", userEntity.getId())); Token userToken = tokenService.getOne(new QueryWrapper<Token>().eq("user_id", userEntity.getId()));

@ -8,8 +8,7 @@ import java.util.Enumeration;
/** /**
* @ClassName IpUtils * @ClassName IpUtils
* @Description Ip工具类获取ip * @Description Ip工具类获取ip
* @Author Rogers * @Date 2020/9/30
* @Date 2020/7/4 14:36
* @Version 1.0 * @Version 1.0
*/ */
public class IpUtils { public class IpUtils {

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.LoginLogMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.LoginLog" id="LoginLogMap">
<result property="id" column="id"/>
</resultMap>
<select id="pageByCondition" resultMap="LoginLogMap">
SELECT * FROM hrms_login_log
</select>
</mapper>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.daqing.financial.hrauth.dao.SystemLogMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.daqing.framework.domain.hrms.SystemLog" id="SystemLogMap">
<result property="id" column="id"/>
</resultMap>
<select id="pageByCondition" resultMap="SystemLogMap">
SELECT *
FROM
sys_action_log
</select>
</mapper>

@ -1,33 +1,33 @@
package com.daqing.financial.hrms.config; //package com.daqing.financial.hrms.config;
//
import org.springframework.context.annotation.Bean; //import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; //import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration; //import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; //import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter; //import org.springframework.web.filter.CorsFilter;
//
/** ///**
* 实现基本的跨域请求 // * 实现基本的跨域请求
* // *
* @auther River // * @auther River
* @date 2020/9/25 15:09 // * @date 2020/9/25 15:09
*/ // */
@Configuration //@Configuration
public class CorsConfig { //public class CorsConfig {
//
@Bean // @Bean
public CorsFilter corsFilter() { // public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); // final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource();
final CorsConfiguration corsConfiguration = new CorsConfiguration(); // final CorsConfiguration corsConfiguration = new CorsConfiguration();
/*是否允许请求带有验证信息*/ // /*是否允许请求带有验证信息*/
corsConfiguration.setAllowCredentials(true); // corsConfiguration.setAllowCredentials(true);
/*允许访问的客户端域名*/ // /*允许访问的客户端域名*/
corsConfiguration.addAllowedOrigin("*"); // corsConfiguration.addAllowedOrigin("*");
/*允许服务端访问的客户端请求头*/ // /*允许服务端访问的客户端请求头*/
corsConfiguration.addAllowedHeader("*"); // corsConfiguration.addAllowedHeader("*");
/*允许访问的方法名,GET POST等*/ // /*允许访问的方法名,GET POST等*/
corsConfiguration.addAllowedMethod("*"); // corsConfiguration.addAllowedMethod("*");
urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); // urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(urlBasedCorsConfigurationSource); // return new CorsFilter(urlBasedCorsConfigurationSource);
} // }
} //}

@ -14,6 +14,9 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;

@ -1,5 +1,9 @@
package com.daqing.financial.gateway.config; package com.daqing.financial.gateway.config;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.gateway.discovery.DiscoveryClientRouteDefinitionLocator;
import org.springframework.cloud.gateway.discovery.DiscoveryLocatorProperties;
import org.springframework.cloud.gateway.route.RouteDefinitionLocator;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.CorsConfiguration;
@ -24,4 +28,9 @@ public class FinancialCorsConfiguration {
source.registerCorsConfiguration("/**",corsConfiguration); source.registerCorsConfiguration("/**",corsConfiguration);
return new CorsWebFilter(source); return new CorsWebFilter(source);
} }
@Bean
public RouteDefinitionLocator discoveryClientRouteDefinitionLocator(DiscoveryClient discoveryClient,
DiscoveryLocatorProperties properties) {
return new DiscoveryClientRouteDefinitionLocator(discoveryClient, properties);
}
} }

@ -1,4 +1,7 @@
jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,\ jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,\
/apiHrmsAuth/hrms/auth/userlogin/login,\ /apiHrmsAuth/hrms/auth/userlogin/login,\
/apiHrmsAuth/hrms/auth/userlogin/verifyMobile,\ /apiHrmsAuth/hrms/auth/userlogin/verifyMobile,\
/api-crms/sweagger-ui.html /api-crms/sweagger-ui.html,\
/api-crms/crms/customer/excelTemplate,\
/api-crms/crms/customer/excelExport,\
/api-crms/crms/customer/excelImport
Loading…
Cancel
Save