Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
7b37b6fa
Commit
7b37b6fa
authored
Feb 22, 2018
by
stylefeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新结构和注释
parent
52131ee4
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
68 additions
and
88 deletions
+68
-88
guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java
+2
-20
guns-admin/src/main/java/com/stylefeng/guns/GunsServletInitializer.java
+0
-1
guns-admin/src/main/java/com/stylefeng/guns/config/MybatisPlusConfig.java
+5
-6
guns-admin/src/main/java/com/stylefeng/guns/config/web/WebConfig.java
+25
-7
guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java
+7
-21
guns-admin/src/main/java/com/stylefeng/guns/core/beetl/BeetlConfiguration.java
+6
-3
guns-admin/src/main/java/com/stylefeng/guns/core/intercept/SessionHolderInterceptor.java
+0
-1
guns-admin/src/main/java/com/stylefeng/guns/core/listener/ConfigListener.java
+10
-1
guns-admin/src/main/java/com/stylefeng/guns/core/log/factory/LogFactory.java
+1
-7
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/check/ICheck.java
+2
-6
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/check/PermissionCheckManager.java
+1
-1
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/factory/ShiroFactroy.java
+9
-9
guns-admin/src/main/java/com/stylefeng/guns/core/util/ApiMenuFilter.java
+0
-1
guns-admin/src/main/java/com/stylefeng/guns/core/util/KaptchaUtil.java
+0
-3
guns-admin/src/main/resources/application.yml
+0
-1
No files found.
guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java
View file @
7b37b6fa
package
com
.
stylefeng
.
guns
;
package
com
.
stylefeng
.
guns
;
import
com.stylefeng.guns.config.properties.GunsProperties
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
/**
/**
* SpringBoot方式启动类
* SpringBoot方式启动类
...
@@ -16,23 +12,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
...
@@ -16,23 +12,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* @Date 2017/5/21 12:06
* @Date 2017/5/21 12:06
*/
*/
@SpringBootApplication
@SpringBootApplication
public
class
GunsApplication
extends
WebMvcConfigurerAdapter
{
public
class
GunsApplication
{
protected
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GunsApplication
.
class
);
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GunsApplication
.
class
);
@Autowired
GunsProperties
gunsProperties
;
/**
* 增加swagger的支持
*/
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
if
(
gunsProperties
.
getSwaggerOpen
())
{
registry
.
addResourceHandler
(
"swagger-ui.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GunsApplication
.
class
,
args
);
SpringApplication
.
run
(
GunsApplication
.
class
,
args
);
...
...
guns-admin/src/main/java/com/stylefeng/guns/GunsServletInitializer.java
View file @
7b37b6fa
...
@@ -15,5 +15,4 @@ public class GunsServletInitializer extends SpringBootServletInitializer {
...
@@ -15,5 +15,4 @@ public class GunsServletInitializer extends SpringBootServletInitializer {
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
builder
)
{
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
builder
)
{
return
builder
.
sources
(
GunsApplication
.
class
);
return
builder
.
sources
(
GunsApplication
.
class
);
}
}
}
}
guns-admin/src/main/java/com/stylefeng/guns/config/MybatisPlusConfig.java
View file @
7b37b6fa
package
com
.
stylefeng
.
guns
.
config
;
package
com
.
stylefeng
.
guns
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor
;
import
com.baomidou.mybatisplus.plugins.PaginationInterceptor
;
import
com.baomidou.mybatisplus.plugins.PaginationInterceptor
;
import
com.stylefeng.guns.common.constant.DatasourceEnum
;
import
com.stylefeng.guns.common.constant.DatasourceEnum
;
import
com.stylefeng.guns.core.datascope.DataScopeInterceptor
;
import
com.stylefeng.guns.core.datascope.DataScopeInterceptor
;
...
@@ -105,10 +104,10 @@ public class MybatisPlusConfig {
...
@@ -105,10 +104,10 @@ public class MybatisPlusConfig {
return
new
DataScopeInterceptor
();
return
new
DataScopeInterceptor
();
}
}
/**
/
//
**
* 乐观锁mybatis插件
//
* 乐观锁mybatis插件
*/
//
*/
@Bean
//
@Bean
public
OptimisticLockerInterceptor
optimisticLockerInterceptor
()
{
return
new
OptimisticLockerInterceptor
();
}
//
public OptimisticLockerInterceptor optimisticLockerInterceptor() { return new OptimisticLockerInterceptor(); }
}
}
guns-admin/src/main/java/com/stylefeng/guns/config/web/WebConfig.java
View file @
7b37b6fa
...
@@ -7,17 +7,21 @@ import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator;
...
@@ -7,17 +7,21 @@ import com.alibaba.druid.support.spring.stat.BeanTypeAutoProxyCreator;
import
com.alibaba.druid.support.spring.stat.DruidStatInterceptor
;
import
com.alibaba.druid.support.spring.stat.DruidStatInterceptor
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.impl.DefaultKaptcha
;
import
com.google.code.kaptcha.util.Config
;
import
com.google.code.kaptcha.util.Config
;
import
com.stylefeng.guns.config.properties.GunsProperties
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.listener.ConfigListener
;
import
com.stylefeng.guns.core.xss.XssFilter
;
import
com.stylefeng.guns.core.xss.XssFilter
;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.Advisor
;
import
org.springframework.aop.support.DefaultPointcutAdvisor
;
import
org.springframework.aop.support.DefaultPointcutAdvisor
;
import
org.springframework.aop.support.JdkRegexpMethodPointcut
;
import
org.springframework.aop.support.JdkRegexpMethodPointcut
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletListenerRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
import
org.springframework.boot.web.servlet.ServletRegistrationBean
;
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.context.request.RequestContextListener
;
import
org.springframework.web.context.request.RequestContextListener
;
import
org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Properties
;
import
java.util.Properties
;
...
@@ -29,7 +33,21 @@ import java.util.Properties;
...
@@ -29,7 +33,21 @@ import java.util.Properties;
* @date 2016年11月12日 下午5:03:32
* @date 2016年11月12日 下午5:03:32
*/
*/
@Configuration
@Configuration
public
class
WebConfig
{
public
class
WebConfig
extends
WebMvcConfigurerAdapter
{
@Autowired
private
GunsProperties
gunsProperties
;
/**
* 增加swagger的支持
*/
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
if
(
gunsProperties
.
getSwaggerOpen
())
{
registry
.
addResourceHandler
(
"swagger-ui.html"
).
addResourceLocations
(
"classpath:/META-INF/resources/"
);
registry
.
addResourceHandler
(
"/webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
}
/**
/**
* druidServlet注册
* druidServlet注册
...
@@ -43,18 +61,17 @@ public class WebConfig {
...
@@ -43,18 +61,17 @@ public class WebConfig {
/**
/**
* druid监控 配置URI拦截策略
* druid监控 配置URI拦截策略
* @return
*/
*/
@Bean
@Bean
public
FilterRegistrationBean
druidStatFilter
(){
public
FilterRegistrationBean
druidStatFilter
()
{
FilterRegistrationBean
filterRegistrationBean
=
new
FilterRegistrationBean
(
new
WebStatFilter
());
FilterRegistrationBean
filterRegistrationBean
=
new
FilterRegistrationBean
(
new
WebStatFilter
());
//添加过滤规则.
//添加过滤规则.
filterRegistrationBean
.
addUrlPatterns
(
"/*"
);
filterRegistrationBean
.
addUrlPatterns
(
"/*"
);
//添加不需要忽略的格式信息.
//添加不需要忽略的格式信息.
filterRegistrationBean
.
addInitParameter
(
filterRegistrationBean
.
addInitParameter
(
"exclusions"
,
"/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*"
);
"exclusions"
,
"/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*"
);
//用于session监控页面的用户名显示 需要登录后主动将username注入到session里
//用于session监控页面的用户名显示 需要登录后主动将username注入到session里
filterRegistrationBean
.
addInitParameter
(
"principalSessionName"
,
"username"
);
filterRegistrationBean
.
addInitParameter
(
"principalSessionName"
,
"username"
);
return
filterRegistrationBean
;
return
filterRegistrationBean
;
}
}
...
@@ -67,7 +84,7 @@ public class WebConfig {
...
@@ -67,7 +84,7 @@ public class WebConfig {
}
}
@Bean
@Bean
public
JdkRegexpMethodPointcut
druidStatPointcut
(){
public
JdkRegexpMethodPointcut
druidStatPointcut
()
{
JdkRegexpMethodPointcut
druidStatPointcut
=
new
JdkRegexpMethodPointcut
();
JdkRegexpMethodPointcut
druidStatPointcut
=
new
JdkRegexpMethodPointcut
();
String
patterns
=
"com.stylefeng.guns.modular.*.service.*"
;
String
patterns
=
"com.stylefeng.guns.modular.*.service.*"
;
//可以set多个
//可以set多个
...
@@ -88,6 +105,7 @@ public class WebConfig {
...
@@ -88,6 +105,7 @@ public class WebConfig {
/**
/**
* druid 为druidStatPointcut添加拦截
* druid 为druidStatPointcut添加拦截
*
* @return
* @return
*/
*/
@Bean
@Bean
...
@@ -101,7 +119,7 @@ public class WebConfig {
...
@@ -101,7 +119,7 @@ public class WebConfig {
@Bean
@Bean
public
FilterRegistrationBean
xssFilterRegistration
()
{
public
FilterRegistrationBean
xssFilterRegistration
()
{
XssFilter
xssFilter
=
new
XssFilter
();
XssFilter
xssFilter
=
new
XssFilter
();
xssFilter
.
setUrlExclusion
(
Arrays
.
asList
(
"/notice/update"
,
"/notice/add"
));
xssFilter
.
setUrlExclusion
(
Arrays
.
asList
(
"/notice/update"
,
"/notice/add"
));
FilterRegistrationBean
registration
=
new
FilterRegistrationBean
(
xssFilter
);
FilterRegistrationBean
registration
=
new
FilterRegistrationBean
(
xssFilter
);
registration
.
addUrlPatterns
(
"/*"
);
registration
.
addUrlPatterns
(
"/*"
);
return
registration
;
return
registration
;
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java
View file @
7b37b6fa
...
@@ -39,8 +39,6 @@ public class GlobalExceptionHandler {
...
@@ -39,8 +39,6 @@ public class GlobalExceptionHandler {
/**
/**
* 拦截业务异常
* 拦截业务异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
GunsException
.
class
)
@ExceptionHandler
(
GunsException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
...
@@ -53,9 +51,7 @@ public class GlobalExceptionHandler {
...
@@ -53,9 +51,7 @@ public class GlobalExceptionHandler {
}
}
/**
/**
* 用户未登录
* 用户未登录异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
AuthenticationException
.
class
)
@ExceptionHandler
(
AuthenticationException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
...
@@ -65,9 +61,7 @@ public class GlobalExceptionHandler {
...
@@ -65,9 +61,7 @@ public class GlobalExceptionHandler {
}
}
/**
/**
* 账号被冻结
* 账号被冻结异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
DisabledAccountException
.
class
)
@ExceptionHandler
(
DisabledAccountException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
...
@@ -79,9 +73,7 @@ public class GlobalExceptionHandler {
...
@@ -79,9 +73,7 @@ public class GlobalExceptionHandler {
}
}
/**
/**
* 账号密码错误
* 账号密码错误异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
CredentialsException
.
class
)
@ExceptionHandler
(
CredentialsException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
...
@@ -93,9 +85,7 @@ public class GlobalExceptionHandler {
...
@@ -93,9 +85,7 @@ public class GlobalExceptionHandler {
}
}
/**
/**
* 验证码错误
* 验证码错误异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
InvalidKaptchaException
.
class
)
@ExceptionHandler
(
InvalidKaptchaException
.
class
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
@ResponseStatus
(
HttpStatus
.
BAD_REQUEST
)
...
@@ -107,9 +97,7 @@ public class GlobalExceptionHandler {
...
@@ -107,9 +97,7 @@ public class GlobalExceptionHandler {
}
}
/**
/**
* 无权访问该资源
* 无权访问该资源异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
UndeclaredThrowableException
.
class
)
@ExceptionHandler
(
UndeclaredThrowableException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
...
@@ -117,13 +105,11 @@ public class GlobalExceptionHandler {
...
@@ -117,13 +105,11 @@ public class GlobalExceptionHandler {
public
ErrorTip
credentials
(
UndeclaredThrowableException
e
)
{
public
ErrorTip
credentials
(
UndeclaredThrowableException
e
)
{
getRequest
().
setAttribute
(
"tip"
,
"权限异常"
);
getRequest
().
setAttribute
(
"tip"
,
"权限异常"
);
log
.
error
(
"权限异常!"
,
e
);
log
.
error
(
"权限异常!"
,
e
);
return
new
ErrorTip
(
BizExceptionEnum
.
NO_PERMITION
.
getCode
(),
BizExceptionEnum
.
NO_PERMITION
.
getMessage
());
return
new
ErrorTip
(
BizExceptionEnum
.
NO_PERMITION
.
getCode
(),
BizExceptionEnum
.
NO_PERMITION
.
getMessage
());
}
}
/**
/**
* 拦截未知的运行时异常
* 拦截未知的运行时异常
*
* @author fengshuonan
*/
*/
@ExceptionHandler
(
RuntimeException
.
class
)
@ExceptionHandler
(
RuntimeException
.
class
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
...
@@ -132,6 +118,6 @@ public class GlobalExceptionHandler {
...
@@ -132,6 +118,6 @@ public class GlobalExceptionHandler {
LogManager
.
me
().
executeLog
(
LogTaskFactory
.
exceptionLog
(
ShiroKit
.
getUser
().
getId
(),
e
));
LogManager
.
me
().
executeLog
(
LogTaskFactory
.
exceptionLog
(
ShiroKit
.
getUser
().
getId
(),
e
));
getRequest
().
setAttribute
(
"tip"
,
"服务器未知运行时异常"
);
getRequest
().
setAttribute
(
"tip"
,
"服务器未知运行时异常"
);
log
.
error
(
"运行时异常:"
,
e
);
log
.
error
(
"运行时异常:"
,
e
);
return
new
ErrorTip
(
BizExceptionEnum
.
SERVER_ERROR
.
getCode
(),
BizExceptionEnum
.
SERVER_ERROR
.
getMessage
());
return
new
ErrorTip
(
BizExceptionEnum
.
SERVER_ERROR
.
getCode
(),
BizExceptionEnum
.
SERVER_ERROR
.
getMessage
());
}
}
}
}
guns-admin/src/main/java/com/stylefeng/guns/core/beetl/BeetlConfiguration.java
View file @
7b37b6fa
...
@@ -4,15 +4,18 @@ import com.stylefeng.guns.core.util.KaptchaUtil;
...
@@ -4,15 +4,18 @@ import com.stylefeng.guns.core.util.KaptchaUtil;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
org.beetl.ext.spring.BeetlGroupUtilConfiguration
;
import
org.beetl.ext.spring.BeetlGroupUtilConfiguration
;
/**
* beetl拓展配置,绑定一些工具类,方便在模板中直接调用
*
* @author stylefeng
* @Date 2018/2/22 21:03
*/
public
class
BeetlConfiguration
extends
BeetlGroupUtilConfiguration
{
public
class
BeetlConfiguration
extends
BeetlGroupUtilConfiguration
{
@Override
@Override
public
void
initOther
()
{
public
void
initOther
()
{
groupTemplate
.
registerFunctionPackage
(
"shiro"
,
new
ShiroExt
());
groupTemplate
.
registerFunctionPackage
(
"shiro"
,
new
ShiroExt
());
groupTemplate
.
registerFunctionPackage
(
"tool"
,
new
ToolUtil
());
groupTemplate
.
registerFunctionPackage
(
"tool"
,
new
ToolUtil
());
groupTemplate
.
registerFunctionPackage
(
"kaptcha"
,
new
KaptchaUtil
());
groupTemplate
.
registerFunctionPackage
(
"kaptcha"
,
new
KaptchaUtil
());
}
}
}
}
guns-admin/src/main/java/com/stylefeng/guns/core/intercept/SessionHolderInterceptor.java
View file @
7b37b6fa
...
@@ -24,7 +24,6 @@ public class SessionHolderInterceptor extends BaseController {
...
@@ -24,7 +24,6 @@ public class SessionHolderInterceptor extends BaseController {
@Around
(
"cutService()"
)
@Around
(
"cutService()"
)
public
Object
sessionKit
(
ProceedingJoinPoint
point
)
throws
Throwable
{
public
Object
sessionKit
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpSessionHolder
.
put
(
super
.
getHttpServletRequest
().
getSession
());
HttpSessionHolder
.
put
(
super
.
getHttpServletRequest
().
getSession
());
try
{
try
{
return
point
.
proceed
();
return
point
.
proceed
();
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/listener/ConfigListener.java
View file @
7b37b6fa
...
@@ -21,6 +21,12 @@ import javax.servlet.ServletContextListener;
...
@@ -21,6 +21,12 @@ import javax.servlet.ServletContextListener;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
/**
* ServletContext监听器
*
* @author stylefeng
* @Date 2018/2/22 21:07
*/
public
class
ConfigListener
implements
ServletContextListener
{
public
class
ConfigListener
implements
ServletContextListener
{
private
static
Map
<
String
,
String
>
conf
=
new
HashMap
<>();
private
static
Map
<
String
,
String
>
conf
=
new
HashMap
<>();
...
@@ -37,8 +43,11 @@ public class ConfigListener implements ServletContextListener {
...
@@ -37,8 +43,11 @@ public class ConfigListener implements ServletContextListener {
@Override
@Override
public
void
contextInitialized
(
ServletContextEvent
evt
)
{
public
void
contextInitialized
(
ServletContextEvent
evt
)
{
ServletContext
sc
=
evt
.
getServletContext
();
ServletContext
sc
=
evt
.
getServletContext
();
// 项目路径
//项目发布,当前运行环境的绝对路径
conf
.
put
(
"realPath"
,
sc
.
getRealPath
(
"/"
).
replaceFirst
(
"/"
,
""
));
conf
.
put
(
"realPath"
,
sc
.
getRealPath
(
"/"
).
replaceFirst
(
"/"
,
""
));
//servletContextPath,默认""
conf
.
put
(
"contextPath"
,
sc
.
getContextPath
());
conf
.
put
(
"contextPath"
,
sc
.
getContextPath
());
}
}
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/log/factory/LogFactory.java
View file @
7b37b6fa
...
@@ -17,9 +17,6 @@ public class LogFactory {
...
@@ -17,9 +17,6 @@ public class LogFactory {
/**
/**
* 创建操作日志
* 创建操作日志
*
* @author fengshuonan
* @Date 2017/3/30 18:45
*/
*/
public
static
OperationLog
createOperationLog
(
LogType
logType
,
Integer
userId
,
String
bussinessName
,
String
clazzName
,
String
methodName
,
String
msg
,
LogSucceed
succeed
)
{
public
static
OperationLog
createOperationLog
(
LogType
logType
,
Integer
userId
,
String
bussinessName
,
String
clazzName
,
String
methodName
,
String
msg
,
LogSucceed
succeed
)
{
OperationLog
operationLog
=
new
OperationLog
();
OperationLog
operationLog
=
new
OperationLog
();
...
@@ -36,11 +33,8 @@ public class LogFactory {
...
@@ -36,11 +33,8 @@ public class LogFactory {
/**
/**
* 创建登录日志
* 创建登录日志
*
* @author fengshuonan
* @Date 2017/3/30 18:46
*/
*/
public
static
LoginLog
createLoginLog
(
LogType
logType
,
Integer
userId
,
String
msg
,
String
ip
)
{
public
static
LoginLog
createLoginLog
(
LogType
logType
,
Integer
userId
,
String
msg
,
String
ip
)
{
LoginLog
loginLog
=
new
LoginLog
();
LoginLog
loginLog
=
new
LoginLog
();
loginLog
.
setLogname
(
logType
.
getMessage
());
loginLog
.
setLogname
(
logType
.
getMessage
());
loginLog
.
setUserid
(
userId
);
loginLog
.
setUserid
(
userId
);
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/check/ICheck.java
View file @
7b37b6fa
...
@@ -15,22 +15,18 @@
...
@@ -15,22 +15,18 @@
*/
*/
package
com
.
stylefeng
.
guns
.
core
.
shiro
.
check
;
package
com
.
stylefeng
.
guns
.
core
.
shiro
.
check
;
/**
/**
* 检查用接口
* 检查用接口
*/
*/
public
interface
ICheck
{
public
interface
ICheck
{
/**
/**
* 检查指定角色
* 检查当前登录用户是否拥有指定的角色访问当
* @param permissions
* @return boolean
*/
*/
boolean
check
(
Object
[]
permissions
);
boolean
check
(
Object
[]
permissions
);
/**
/**
* 检查全体角色
* 检查当前登录用户是否拥有当前请求的servlet的权限
* @return boolean
*/
*/
boolean
checkAll
();
boolean
checkAll
();
}
}
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/check/PermissionCheckManager.java
View file @
7b37b6fa
...
@@ -18,7 +18,7 @@ package com.stylefeng.guns.core.shiro.check;
...
@@ -18,7 +18,7 @@ package com.stylefeng.guns.core.shiro.check;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
/**
/**
* 权限检查
工厂
* 权限检查
管理器(入口)
*/
*/
public
class
PermissionCheckManager
{
public
class
PermissionCheckManager
{
private
final
static
PermissionCheckManager
me
=
new
PermissionCheckManager
();
private
final
static
PermissionCheckManager
me
=
new
PermissionCheckManager
();
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/shiro/factory/ShiroFactroy.java
View file @
7b37b6fa
...
@@ -2,12 +2,12 @@ package com.stylefeng.guns.core.shiro.factory;
...
@@ -2,12 +2,12 @@ package com.stylefeng.guns.core.shiro.factory;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.state.ManagerStatus
;
import
com.stylefeng.guns.common.constant.state.ManagerStatus
;
import
com.stylefeng.guns.common.persistence.model.User
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
com.stylefeng.guns.modular.system.dao.MenuDao
;
import
com.stylefeng.guns.modular.system.dao.MenuDao
;
import
com.stylefeng.guns.modular.system.dao.UserMgrDao
;
import
com.stylefeng.guns.modular.system.dao.UserMgrDao
;
import
com.stylefeng.guns.common.persistence.model.User
;
import
org.apache.shiro.authc.CredentialsException
;
import
org.apache.shiro.authc.CredentialsException
;
import
org.apache.shiro.authc.LockedAccountException
;
import
org.apache.shiro.authc.LockedAccountException
;
import
org.apache.shiro.authc.SimpleAuthenticationInfo
;
import
org.apache.shiro.authc.SimpleAuthenticationInfo
;
...
@@ -56,13 +56,13 @@ public class ShiroFactroy implements IShiro {
...
@@ -56,13 +56,13 @@ public class ShiroFactroy implements IShiro {
public
ShiroUser
shiroUser
(
User
user
)
{
public
ShiroUser
shiroUser
(
User
user
)
{
ShiroUser
shiroUser
=
new
ShiroUser
();
ShiroUser
shiroUser
=
new
ShiroUser
();
shiroUser
.
setId
(
user
.
getId
());
// 账号id
shiroUser
.
setId
(
user
.
getId
());
shiroUser
.
setAccount
(
user
.
getAccount
());
// 账号
shiroUser
.
setAccount
(
user
.
getAccount
());
shiroUser
.
setDeptId
(
user
.
getDeptid
());
// 部门id
shiroUser
.
setDeptId
(
user
.
getDeptid
());
shiroUser
.
setDeptName
(
ConstantFactory
.
me
().
getDeptName
(
user
.
getDeptid
()));
// 部门名称
shiroUser
.
setDeptName
(
ConstantFactory
.
me
().
getDeptName
(
user
.
getDeptid
()));
shiroUser
.
setName
(
user
.
getName
());
// 用户名称
shiroUser
.
setName
(
user
.
getName
());
Integer
[]
roleArray
=
Convert
.
toIntArray
(
user
.
getRoleid
());
// 角色集合
Integer
[]
roleArray
=
Convert
.
toIntArray
(
user
.
getRoleid
());
List
<
Integer
>
roleList
=
new
ArrayList
<
Integer
>();
List
<
Integer
>
roleList
=
new
ArrayList
<
Integer
>();
List
<
String
>
roleNameList
=
new
ArrayList
<
String
>();
List
<
String
>
roleNameList
=
new
ArrayList
<
String
>();
for
(
int
roleId
:
roleArray
)
{
for
(
int
roleId
:
roleArray
)
{
...
@@ -77,8 +77,7 @@ public class ShiroFactroy implements IShiro {
...
@@ -77,8 +77,7 @@ public class ShiroFactroy implements IShiro {
@Override
@Override
public
List
<
String
>
findPermissionsByRoleId
(
Integer
roleId
)
{
public
List
<
String
>
findPermissionsByRoleId
(
Integer
roleId
)
{
List
<
String
>
resUrls
=
menuDao
.
getResUrlsByRoleId
(
roleId
);
return
menuDao
.
getResUrlsByRoleId
(
roleId
);
return
resUrls
;
}
}
@Override
@Override
...
@@ -89,6 +88,7 @@ public class ShiroFactroy implements IShiro {
...
@@ -89,6 +88,7 @@ public class ShiroFactroy implements IShiro {
@Override
@Override
public
SimpleAuthenticationInfo
info
(
ShiroUser
shiroUser
,
User
user
,
String
realmName
)
{
public
SimpleAuthenticationInfo
info
(
ShiroUser
shiroUser
,
User
user
,
String
realmName
)
{
String
credentials
=
user
.
getPassword
();
String
credentials
=
user
.
getPassword
();
// 密码加盐处理
// 密码加盐处理
String
source
=
user
.
getSalt
();
String
source
=
user
.
getSalt
();
ByteSource
credentialsSalt
=
new
Md5Hash
(
source
);
ByteSource
credentialsSalt
=
new
Md5Hash
(
source
);
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/util/ApiMenuFilter.java
View file @
7b37b6fa
...
@@ -15,7 +15,6 @@ import java.util.List;
...
@@ -15,7 +15,6 @@ import java.util.List;
*/
*/
public
class
ApiMenuFilter
extends
MenuNode
{
public
class
ApiMenuFilter
extends
MenuNode
{
public
static
List
<
MenuNode
>
build
(
List
<
MenuNode
>
nodes
)
{
public
static
List
<
MenuNode
>
build
(
List
<
MenuNode
>
nodes
)
{
//如果关闭了接口文档,则不显示接口文档菜单
//如果关闭了接口文档,则不显示接口文档菜单
...
...
guns-admin/src/main/java/com/stylefeng/guns/core/util/KaptchaUtil.java
View file @
7b37b6fa
...
@@ -9,9 +9,6 @@ public class KaptchaUtil {
...
@@ -9,9 +9,6 @@ public class KaptchaUtil {
/**
/**
* 获取验证码开关
* 获取验证码开关
*
* @author stylefeng
* @Date 2017/5/23 22:34
*/
*/
public
static
Boolean
getKaptchaOnOff
()
{
public
static
Boolean
getKaptchaOnOff
()
{
return
SpringContextHolder
.
getBean
(
GunsProperties
.
class
).
getKaptchaOpen
();
return
SpringContextHolder
.
getBean
(
GunsProperties
.
class
).
getKaptchaOpen
();
...
...
guns-admin/src/main/resources/application.yml
View file @
7b37b6fa
...
@@ -55,7 +55,6 @@ spring:
...
@@ -55,7 +55,6 @@ spring:
mybatis-plus
:
mybatis-plus
:
mapper-locations
:
classpath*:com/stylefeng/guns/**/mapping/*.xml
mapper-locations
:
classpath*:com/stylefeng/guns/**/mapping/*.xml
typeAliasesPackage
:
com.stylefeng.guns.common.persistence.model
typeAliasesPackage
:
com.stylefeng.guns.common.persistence.model
typeEnumsPackage
:
com.stylefeng.guns.common.constant.enums
global-config
:
global-config
:
id-type
:
0
#0:数据库ID自增 1:用户输入id 2:全局唯一id(IdWorker) 3:全局唯一ID(uuid)
id-type
:
0
#0:数据库ID自增 1:用户输入id 2:全局唯一id(IdWorker) 3:全局唯一ID(uuid)
db-column-underline
:
false
db-column-underline
:
false
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment