Skip to content

Commit

Permalink
system module
Browse files Browse the repository at this point in the history
  • Loading branch information
geekidea committed Mar 24, 2020
1 parent 0e7cfa0 commit d89ced7
Show file tree
Hide file tree
Showing 98 changed files with 669 additions and 418 deletions.
6 changes: 6 additions & 0 deletions bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
<groupId>io.geekidea.springbootplus</groupId>
<artifactId>example</artifactId>
</dependency>
<dependency>
<groupId>io.geekidea.springbootplus</groupId>
<artifactId>system</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.config.properties.ShiroPermissionProperties;
import io.geekidea.springbootplus.config.properties.ShiroProperties;
import io.geekidea.springbootplus.config.properties.SpringBootPlusFilterProperties;
import io.geekidea.springbootplus.framework.shiro.cache.LoginRedisService;
import io.geekidea.springbootplus.framework.shiro.exception.ShiroConfigException;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtCredentialsMatcher;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtFilter;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtRealm;
import io.geekidea.springbootplus.framework.system.service.LoginService;
import io.geekidea.springbootplus.framework.shiro.service.ShiroLoginService;
import io.geekidea.springbootplus.framework.util.IniUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
Expand Down Expand Up @@ -147,13 +146,13 @@ public SecurityManager securityManager(LoginRedisService loginRedisService) {
*/
@Bean(SHIRO_FILTER_NAME)
public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager,
LoginService loginService,
ShiroLoginService shiroLoginService,
LoginRedisService loginRedisService,
ShiroProperties shiroProperties,
JwtProperties jwtProperties) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager);
Map<String, Filter> filterMap = getFilterMap(loginService, loginRedisService, jwtProperties);
Map<String, Filter> filterMap = getFilterMap(shiroLoginService, loginRedisService, jwtProperties);
shiroFilterFactoryBean.setFilters(filterMap);
Map<String, String> filterChainMap = getFilterChainDefinitionMap(shiroProperties);
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainMap);
Expand All @@ -166,11 +165,11 @@ public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityMan
*
* @return
*/
private Map<String, Filter> getFilterMap(LoginService loginService,
private Map<String, Filter> getFilterMap(ShiroLoginService shiroLoginService,
LoginRedisService loginRedisService,
JwtProperties jwtProperties) {
Map<String, Filter> filterMap = new LinkedHashMap();
filterMap.put(JWT_FILTER_NAME, new JwtFilter(loginService, loginRedisService, jwtProperties));
filterMap.put(JWT_FILTER_NAME, new JwtFilter(shiroLoginService, loginRedisService, jwtProperties));
return filterMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package io.geekidea.springbootplus.config;

import com.alibaba.fastjson.JSON;
import io.geekidea.springbootplus.framework.core.interceptor.PermissionInterceptor;
import io.geekidea.springbootplus.framework.util.IniUtil;
import io.geekidea.springbootplus.config.properties.SpringBootPlusInterceptorProperties;
import io.geekidea.springbootplus.config.properties.SpringBootPlusProperties;
import io.geekidea.springbootplus.framework.system.interceptor.DownloadInterceptor;
import io.geekidea.springbootplus.framework.system.interceptor.ResourceInterceptor;
import io.geekidea.springbootplus.framework.system.interceptor.UploadInterceptor;
import io.geekidea.springbootplus.framework.core.interceptor.PermissionInterceptor;
import io.geekidea.springbootplus.framework.util.IniUtil;
import io.geekidea.springbootplus.system.interceptor.DownloadInterceptor;
import io.geekidea.springbootplus.system.interceptor.ResourceInterceptor;
import io.geekidea.springbootplus.system.interceptor.UploadInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.common.exception;
package io.geekidea.springbootplus.handler;

import com.alibaba.fastjson.JSON;
import com.auth0.jwt.exceptions.JWTDecodeException;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.system.exception.SysLoginException;
import io.geekidea.springbootplus.framework.system.exception.VerificationCodeException;
import io.geekidea.springbootplus.framework.common.exception.BusinessException;
import io.geekidea.springbootplus.framework.common.exception.DaoException;
import io.geekidea.springbootplus.framework.common.exception.SpringBootPlusException;
import io.geekidea.springbootplus.system.exception.SysLoginException;
import io.geekidea.springbootplus.system.exception.VerificationCodeException;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.UnauthenticatedException;
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ spring-boot-plus:
# 服务器IP地址
server-ip: 127.0.0.1
# 是否启用验证码
enable-verify-code: false
enable-verify-code: true
# 默认新建用户登陆初始化密码
login-init-salt: 666666
login-init-password: admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class EnumController {

private static final List<String> FRAMEWORK_ENUM_PACKAGES = Arrays.asList(
"io.geekidea.springbootplus.framework.common.enums",
"io.geekidea.springbootplus.framework.system.enums");
"io.geekidea.springbootplus.system.enums");

/**
* 枚举包路径
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@

package io.geekidea.springbootplus.framework.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import io.geekidea.springbootplus.framework.system.enums.StateEnum;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
* 枚举类型父接口
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package io.geekidea.springbootplus.framework.common.vo;

import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import io.geekidea.springbootplus.framework.system.enums.StateEnum;
import lombok.Data;
import lombok.experimental.Accessors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@

package io.geekidea.springbootplus.framework.core.pagination;

import cn.hutool.db.sql.Order;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.google.common.base.CaseFormat;
import io.geekidea.springbootplus.framework.system.entity.SysUser;
import io.geekidea.springbootplus.framework.util.PropertyColumnUtil;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -44,11 +41,11 @@ public class OrderMapping {

private boolean underLineMode;

public OrderMapping(){
public OrderMapping() {

}

public OrderMapping(boolean underLineMode){
public OrderMapping(boolean underLineMode) {
this.underLineMode = underLineMode;
}

Expand Down Expand Up @@ -92,15 +89,15 @@ public void filterOrderItems(List<OrderItem> orderItems) {
return;
}
// 如果集合不为空,则按照PropertyColumnUtil映射
if (MapUtils.isNotEmpty(map)){
if (MapUtils.isNotEmpty(map)) {
orderItems.forEach(item -> {
item.setColumn(this.getMappingColumn(item.getColumn()));
});
}else if (underLineMode){
} else if (underLineMode) {
// 如果开启下划线模式,自动转换成下划线
orderItems.forEach(item -> {
// 驼峰转换成下划线
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE,item.getColumn());
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, item.getColumn());
item.setColumn(column);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@

package io.geekidea.springbootplus.framework.core.pagination;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.geekidea.springbootplus.framework.system.entity.SysUser;
import io.geekidea.springbootplus.framework.util.LambdaColumn;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.system.entity;
package io.geekidea.springbootplus.framework.ip.entity;

import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.system.mapper;
package io.geekidea.springbootplus.framework.ip.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.geekidea.springbootplus.framework.system.entity.Ip;
import io.geekidea.springbootplus.framework.ip.entity.Ip;

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;

/**
* IP地址 Mapper 接口
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.system.service;
package io.geekidea.springbootplus.framework.ip.service;

import io.geekidea.springbootplus.framework.system.entity.Ip;
import io.geekidea.springbootplus.framework.ip.entity.Ip;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;

/**
* IP地址 服务类
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.system.service.impl;
package io.geekidea.springbootplus.framework.ip.service.impl;

import io.geekidea.springbootplus.config.constant.CommonConstant;
import io.geekidea.springbootplus.framework.system.entity.Ip;
import io.geekidea.springbootplus.framework.system.mapper.IpMapper;
import io.geekidea.springbootplus.framework.system.service.IpService;
import io.geekidea.springbootplus.framework.ip.entity.Ip;
import io.geekidea.springbootplus.framework.ip.mapper.IpMapper;
import io.geekidea.springbootplus.framework.ip.service.IpService;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.bean.ClientInfo;
import io.geekidea.springbootplus.framework.common.exception.SpringBootPlusException;
import io.geekidea.springbootplus.framework.ip.entity.Ip;
import io.geekidea.springbootplus.framework.ip.service.IpService;
import io.geekidea.springbootplus.framework.log.annotation.Module;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.annotation.OperationLogIgnore;
Expand All @@ -33,9 +35,6 @@
import io.geekidea.springbootplus.framework.log.entity.SysOperationLog;
import io.geekidea.springbootplus.framework.log.service.SysOperationLogService;
import io.geekidea.springbootplus.framework.shiro.util.JwtTokenUtil;
import io.geekidea.springbootplus.framework.system.entity.Ip;
import io.geekidea.springbootplus.framework.system.service.IpService;
import io.geekidea.springbootplus.framework.system.util.LoginUtil;
import io.geekidea.springbootplus.framework.util.*;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
package io.geekidea.springbootplus.framework.shiro.cache.impl;

import io.geekidea.springbootplus.config.constant.CommonRedisKey;
import io.geekidea.springbootplus.framework.util.ClientInfoUtil;
import io.geekidea.springbootplus.framework.util.HttpServletRequestUtil;
import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.framework.common.bean.ClientInfo;
import io.geekidea.springbootplus.framework.shiro.cache.LoginRedisService;
import io.geekidea.springbootplus.framework.shiro.convert.LoginSysUserVoConvert;
import io.geekidea.springbootplus.framework.shiro.convert.ShiroMapstructConvert;
import io.geekidea.springbootplus.config.properties.JwtProperties;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.geekidea.springbootplus.framework.common.bean.ClientInfo;
import io.geekidea.springbootplus.framework.shiro.vo.JwtTokenRedisVo;
import io.geekidea.springbootplus.framework.shiro.vo.LoginSysUserRedisVo;
import io.geekidea.springbootplus.framework.shiro.vo.LoginSysUserVo;
import io.geekidea.springbootplus.framework.system.convert.SysUserConvert;
import io.geekidea.springbootplus.framework.util.ClientInfoUtil;
import io.geekidea.springbootplus.framework.util.HttpServletRequestUtil;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void cacheLoginInfo(JwtToken jwtToken, LoginSysUserVo loginSysUserVo) {

// Redis缓存登陆用户信息
// 将LoginSysUserVo对象复制到LoginSysUserRedisVo,使用mapstruct进行对象属性复制
LoginSysUserRedisVo loginSysUserRedisVo = SysUserConvert.INSTANCE.loginSysUserVoToLoginSysUserRedisVo(loginSysUserVo);
LoginSysUserRedisVo loginSysUserRedisVo = LoginSysUserVoConvert.INSTANCE.voToRedisVo(loginSysUserVo);
loginSysUserRedisVo.setSalt(salt);
loginSysUserRedisVo.setClientInfo(clientInfo);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.geekidea.springbootplus.framework.shiro.convert;

import io.geekidea.springbootplus.framework.shiro.vo.LoginSysUserRedisVo;
import io.geekidea.springbootplus.framework.shiro.vo.LoginSysUserVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
* 登陆系统用户VO对象属性复制转换器
*
* @author geekidea
* @date 2020/3/24
**/
@Mapper
public interface LoginSysUserVoConvert {

LoginSysUserVoConvert INSTANCE = Mappers.getMapper(LoginSysUserVoConvert.class);

/**
* LoginSysUserVo对象转换成LoginSysUserRedisVo
*
* @param loginSysUserVo
* @return
*/
LoginSysUserRedisVo voToRedisVo(LoginSysUserVo loginSysUserVo);

}
Loading

0 comments on commit d89ced7

Please sign in to comment.