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
0dc0c8af
Commit
0dc0c8af
authored
Mar 30, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整理
parent
f38ee05b
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
112 additions
and
171 deletions
+112
-171
README.md
+2
-2
src/main/java/com/stylefeng/guns/common/controller/BaseController.java
+1
-1
src/main/java/com/stylefeng/guns/core/aop/LogAop.java
+17
-9
src/main/java/com/stylefeng/guns/core/beetl/Feng.java
+0
-12
src/main/java/com/stylefeng/guns/core/log/ILog.java
+2
-1
src/main/java/com/stylefeng/guns/core/log/LogFactory.java
+16
-26
src/main/java/com/stylefeng/guns/core/shiro/ShiroUser.java
+0
-0
src/main/java/project/config/web/beetl/BeetlConfiguration.java
+2
-4
src/main/java/project/generator/MpGenerator.java
+4
-51
src/main/webapp/WEB-INF/view/system/role/role_assign.html
+12
-20
src/main/webapp/WEB-INF/view/system/user/user_roleassign.html
+17
-22
src/main/webapp/static/js/common/Feng.js
+29
-23
src/test/java/com/stylefeng/guns/base/BaseTest.java
+10
-0
No files found.
README.md
View file @
0dc0c8af
#Guns
一款简洁并且通用的后台管理系统!整合了spring+mybatis-plus+beetl!
\ No newline at end of file
一款简洁通用的后台管理系统!整合了spring+mybatis-plus+beetl!
\ No newline at end of file
src/main/java/com/stylefeng/guns/common/controller/BaseController.java
View file @
0dc0c8af
...
...
@@ -73,7 +73,7 @@ public class BaseController {
/**
* 删除cookie
*/
protected
void
delete
PhoneCooki
e
(
String
cookieName
)
{
protected
void
delete
CookieByNam
e
(
String
cookieName
)
{
Cookie
[]
cookies
=
this
.
getHttpServletRequest
().
getCookies
();
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
cookieName
))
{
...
...
src/main/java/com/stylefeng/guns/core/aop/LogAop.java
View file @
0dc0c8af
package
com
.
stylefeng
.
guns
.
core
.
aop
;
import
com.stylefeng.guns.core.log.ILog
;
import
com.stylefeng.guns.core.shiro.ShiroKit
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.core.support.StrKit
;
import
com.stylefeng.guns.core.util.DateUtil
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
org.apache.log4j.Logger
;
...
...
@@ -8,13 +12,14 @@ import org.aspectj.lang.annotation.Around;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.lang.reflect.Method
;
/**
* @Description 日志记录
* @author fengshuonan
* @Description 日志记录
* @date 2016年12月6日 下午8:48:30
*/
@Aspect
...
...
@@ -23,7 +28,10 @@ public class LogAop {
private
Logger
log
=
Logger
.
getLogger
(
this
.
getClass
());
@Pointcut
(
"execution(* com.stylefeng.guns.*..service.*.*(..))"
)
@Autowired
ILog
factory
;
@Pointcut
(
"execution(* com.stylefeng.guns..service.*.*(..))"
)
public
void
cutService
()
{
}
...
...
@@ -36,24 +44,24 @@ public class LogAop {
String
methodName
=
method
.
getName
();
//如果当前用户未登录,不做日志
//
ShiroUser user = ShiroKit.getUser();
// if(null == user)
{
//
return point.proceed();
//
}
ShiroUser
user
=
ShiroKit
.
getUser
();
if
(
null
==
user
)
{
return
point
.
proceed
();
}
//获取拦截方法的参数
String
className
=
point
.
getTarget
().
getClass
().
getName
();
Object
[]
params
=
point
.
getArgs
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
Object
param
:
params
)
{
for
(
Object
param
:
params
)
{
sb
.
append
(
param
);
sb
.
append
(
" & "
);
}
String
msg
=
ToolUtil
.
format
(
"[时间]:{} [类名]:{} [方法]:{} [参数]:{}"
,
DateUtil
.
getTime
(),
className
,
methodName
,
sb
.
toString
());
// LogFactory.me().doLog("例如:新增",msg,true
);
log
.
info
(
msg
);
log
.
info
(
StrKit
.
removeSuffix
(
msg
,
"& "
)
);
factory
.
doLog
(
methodName
,
StrKit
.
removeSuffix
(
msg
,
"& "
),
true
);
return
point
.
proceed
();
}
...
...
src/main/java/com/stylefeng/guns/core/beetl/Feng.java
deleted
100644 → 0
View file @
f38ee05b
package
com
.
stylefeng
.
guns
.
core
.
beetl
;
public
class
Feng
{
public
Integer
parseInt
(
Double
value
){
if
(
value
!=
null
){
return
value
.
intValue
();
}
else
{
return
0
;
}
}
}
src/main/java/com/stylefeng/guns/core/log/ILog.java
View file @
0dc0c8af
...
...
@@ -9,7 +9,8 @@ package com.stylefeng.guns.core.log;
public
interface
ILog
{
/**
* @Description 日志记录
* 日志记录
*
* @author fengshuonan
*/
void
doLog
(
String
logName
,
String
msg
,
boolean
succeed
);
...
...
src/main/java/com/stylefeng/guns/core/log/LogFactory.java
View file @
0dc0c8af
package
com
.
stylefeng
.
guns
.
core
.
log
;
import
org.springframework.context.annotation.DependsOn
;
import
com.stylefeng.guns.core.shiro.ShiroKit
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.persistence.dao.OperationLogMapper
;
import
com.stylefeng.guns.persistence.model.OperationLog
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
java.util.Date
;
/**
* 日志记录工厂
...
...
@@ -12,34 +16,20 @@ import com.stylefeng.guns.core.util.SpringContextHolder;
* @date 2016年12月6日 下午9:18:27
*/
@Component
@DependsOn
(
"springContextHolder"
)
public
class
LogFactory
implements
ILog
{
private
LogFactory
()
{
}
public
static
ILog
me
()
{
return
SpringContextHolder
.
getBean
(
ILog
.
class
);
}
@Autowired
OperationLogMapper
operationLogMapper
;
@Override
public
void
doLog
(
String
logName
,
String
msg
,
boolean
succeed
)
{
//添加到数据库
// ShiroUser user = ShiroKit.getUser();
// if (null == user) {
// return true;
// }
// try {
// OperationLog log = new OperationLog();
// log.setMethod(msg);
// log.setCreatetime(new Date());
// log.setSucceed((succeed)?"1":"0");
// log.setUserid(Func.toStr(user.getId()));
// log.setLogname(logName);
// boolean temp = Blade.create(OperationLog.class).save(log);
// return temp;
// } catch (Exception ex) {
// return false;
// }
ShiroUser
user
=
ShiroKit
.
getUser
();
OperationLog
log
=
new
OperationLog
();
log
.
setMethod
(
msg
);
log
.
setCreatetime
(
new
Date
());
log
.
setSucceed
((
succeed
)
?
"1"
:
"0"
);
log
.
setUserid
(
String
.
valueOf
(
user
.
getId
()));
log
.
setLogname
(
logName
);
operationLogMapper
.
insert
(
log
);
}
}
src/main/java/com/stylefeng/guns/core/shiro/ShiroUser.java
View file @
0dc0c8af
src/main/java/project/config/web/beetl/BeetlConfiguration.java
View file @
0dc0c8af
package
project
.
config
.
web
.
beetl
;
import
org.beetl.ext.spring.BeetlGroupUtilConfiguration
;
import
com.stylefeng.guns.core.beetl.Feng
;
import
com.stylefeng.guns.core.beetl.ShiroExt
;
import
org.beetl.ext.spring.BeetlGroupUtilConfiguration
;
public
class
BeetlConfiguration
extends
BeetlGroupUtilConfiguration
{
...
...
@@ -11,7 +9,7 @@ public class BeetlConfiguration extends BeetlGroupUtilConfiguration {
public
void
initOther
()
{
groupTemplate
.
registerFunctionPackage
(
"shiro"
,
new
ShiroExt
());
groupTemplate
.
registerFunctionPackage
(
"feng"
,
new
Feng
());
}
}
src/main/java/project/generator/MpGenerator.java
View file @
0dc0c8af
...
...
@@ -32,30 +32,22 @@ public class MpGenerator {
// 全局配置
GlobalConfig
gc
=
new
GlobalConfig
();
gc
.
setOutputDir
(
"D:\\ideaSpace\\guns\\src\\main\\java"
);
gc
.
setOutputDir
(
"D:\\ideaSpace\\guns\\src\\main\\java"
);
//这里写你自己的java目录
gc
.
setFileOverride
(
true
);
gc
.
setActiveRecord
(
true
);
gc
.
setEnableCache
(
false
);
// XML 二级缓存
gc
.
setBaseResultMap
(
true
);
// XML ResultMap
gc
.
setBaseColumnList
(
false
);
// XML columList
gc
.
setAuthor
(
"stylefeng"
);
// 自定义文件命名,注意 %s 会自动填充表实体属性!
// gc.setMapperName("%sMapper");
// gc.setXmlName("%sMapper");
// gc.setServiceName(null);
// gc.setServiceImplName(null);
// gc.setControllerName(null);
mpg
.
setGlobalConfig
(
gc
);
// 数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
dsc
.
setDbType
(
DbType
.
MYSQL
);
dsc
.
setTypeConvert
(
new
MySqlTypeConvert
(){
dsc
.
setTypeConvert
(
new
MySqlTypeConvert
()
{
// 自定义数据库表字段类型转换【可选】
@Override
public
DbColumnType
processTypeConvert
(
String
fieldType
)
{
// System.out.println("转换类型:" + fieldType);
return
super
.
processTypeConvert
(
fieldType
);
}
});
...
...
@@ -67,30 +59,12 @@ public class MpGenerator {
// 策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setTablePrefix
(
new
String
[]{
"
dd_"
,
"
_"
});
// 此处可以修改为您的表前缀
strategy
.
setTablePrefix
(
new
String
[]{
"_"
});
// 此处可以修改为您的表前缀
strategy
.
setNaming
(
NamingStrategy
.
remove_prefix_and_camel
);
// 表名生成策略
// strategy.setInclude(new String[] { "user" }); // 需要生成的表
// strategy.setExclude(new String[]{"test"}); // 排除生成的表
// 字段名生成策略
strategy
.
setFieldNaming
(
NamingStrategy
.
nochange
);
// 自定义实体父类
// strategy.setSuperEntityClass("com.baomidou.demo.TestEntity");
// 自定义实体,公共字段
// strategy.setSuperEntityColumns(new String[] { "test_id", "age" });
// 自定义 mapper 父类
// strategy.setSuperMapperClass("com.baomidou.demo.TestMapper");
// 自定义 service 父类
// strategy.setSuperServiceClass("com.baomidou.demo.TestService");
// 自定义 service 实现类父类
// strategy.setSuperServiceImplClass("com.baomidou.demo.TestServiceImpl");
// 自定义 controller 父类
// strategy.setSuperControllerClass("com.baomidou.demo.TestController");
// 【实体】是否生成字段常量(默认 false)
// public static final String ID = "test_id";
// strategy.setEntityColumnConstant(true);
// 【实体】是否为构建者模型(默认 false)
// public User setName(String name) {this.name = name; return this;}
// strategy.setEntityBuliderModel(true);
mpg
.
setStrategy
(
strategy
);
// 包配置
...
...
@@ -108,34 +82,13 @@ public class MpGenerator {
InjectionConfig
cfg
=
new
InjectionConfig
()
{
@Override
public
void
initMap
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"abc"
,
this
.
getConfig
().
getGlobalConfig
().
getAuthor
()
+
"-mp"
);
this
.
setMap
(
map
);
}
};
// 自定义 xxList.jsp 生成
// List<FileOutConfig> focList = new ArrayList<FileOutConfig>();
// focList.add(new FileOutConfig("/template/list.jsp.vm") {
// @Override
// public String outputFile(TableInfo tableInfo) {
// // 自定义输入文件名称
// return "D://my_" + tableInfo.getEntityName() + ".jsp";
// }
// });
// cfg.setFileOutConfigList(focList);
mpg
.
setCfg
(
cfg
);
// 自定义模板配置,可以 copy 源码 mybatis-plus/src/main/resources/template 下面内容修改,
// 放置自己项目的 src/main/resources/template 目录下, 默认名称一下可以不配置,也可以自定义模板名称
// TemplateConfig tc = new TemplateConfig();
// tc.setController("...");
// tc.setEntity("...");
// tc.setMapper("...");
// tc.setXml("...");
// tc.setService("...");
// tc.setServiceImpl("...");
// mpg.setTemplate(tc);
// 执行生成
mpg
.
execute
();
...
...
src/main/webapp/WEB-INF/view/system/role/role_assign.html
View file @
0dc0c8af
...
...
@@ -2,28 +2,20 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
function
()
{
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
//获取窗口索引
$
(
"#btn_close"
).
bind
(
"click"
,
function
()
{
$
(
"#btn_close"
).
bind
(
"click"
,
function
()
{
parent
.
layer
.
close
(
index
);
});
$
(
"#btn_save"
).
bind
(
"click"
,
function
()
{
var
zTree
=
$
.
fn
.
zTree
.
getZTreeObj
(
"zTree"
);
var
nodes
=
zTree
.
getCheckedNodes
();
var
ids
=
""
;
for
(
var
i
=
0
,
l
=
nodes
.
length
;
i
<
l
;
i
++
)
{
ids
+=
","
+
nodes
[
i
].
id
;
}
ids
=
ids
.
substring
(
1
);
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/setAuthority"
,
function
(
data
)
{
$
(
"#btn_save"
).
bind
(
"click"
,
function
()
{
var
ids
=
Feng
.
zTreeCheckedNodes
(
"zTree"
);
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/role/setAuthority"
,
function
(
data
)
{
Feng
.
success
(
"分配角色成功!"
);
window
.
parent
.
Role
.
table
.
refresh
();
parent
.
layer
.
close
(
index
);
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"分配角色失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
...
...
@@ -37,12 +29,12 @@
function
initZtree
()
{
var
setting
=
{
check
:
{
enable
:
true
check
:
{
enable
:
true
},
data
:
{
simpleData
:
{
enable
:
true
data
:
{
simpleData
:
{
enable
:
true
}
}
};
...
...
src/main/webapp/WEB-INF/view/system/user/user_roleassign.html
View file @
0dc0c8af
...
...
@@ -2,25 +2,21 @@
<script
type=
"text/javascript"
>
$
(
function
()
{
$
(
function
()
{
var
index
=
parent
.
layer
.
getFrameIndex
(
window
.
name
);
//获取窗口索引
$
(
"#btn_close"
).
bind
(
"click"
,
function
()
{
$
(
"#btn_close"
).
bind
(
"click"
,
function
()
{
parent
.
layer
.
close
(
index
);
});
$
(
"#btn_save"
).
bind
(
"click"
,
function
()
{
var
zTree
=
$
.
fn
.
zTree
.
getZTreeObj
(
"zTree"
);
var
nodes
=
zTree
.
getCheckedNodes
();
var
ids
=
""
;
for
(
var
i
=
0
,
l
=
nodes
.
length
;
i
<
l
;
i
++
)
{
ids
+=
","
+
nodes
[
i
].
id
;
}
ids
=
ids
.
substring
(
1
);
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/setRole"
,
function
(
data
)
{
$
(
"#btn_save"
).
bind
(
"click"
,
function
()
{
var
ids
=
Feng
.
zTreeCheckedNodes
(
"zTree"
);
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/setRole"
,
function
(
data
)
{
Feng
.
success
(
"分配角色成功!"
);
window
.
parent
.
MgrUser
.
table
.
refresh
();
parent
.
layer
.
close
(
index
);
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
"分配角色失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
"roleIds"
,
ids
);
...
...
@@ -33,22 +29,21 @@
function
initZtree
()
{
var
setting
=
{
check
:
{
enable
:
true
,
chkboxType
:
{
"Y"
:
""
,
"N"
:
""
check
:
{
enable
:
true
,
chkboxType
:
{
"Y"
:
""
,
"N"
:
""
}
},
data
:
{
simpleData
:
{
enable
:
true
data
:
{
simpleData
:
{
enable
:
true
}
}
};
var
ztree
=
new
$ZTree
(
"zTree"
,
"/role/roleTreeListByUserId/"
+
"${userId}"
);
var
ztree
=
new
$ZTree
(
"zTree"
,
"/role/roleTreeListByUserId/${userId}"
);
ztree
.
setSettings
(
setting
);
ztree
.
init
();
}
...
...
src/main/webapp/static/js/common/Feng.js
View file @
0dc0c8af
var
Feng
=
{
ctxPath
:
""
,
addCtx
:
function
(
ctx
)
{
ctxPath
:
""
,
addCtx
:
function
(
ctx
)
{
if
(
this
.
ctxPath
==
""
)
{
this
.
ctxPath
=
ctx
;
}
},
log
:
function
(
info
)
{
log
:
function
(
info
)
{
console
.
log
(
info
);
},
alert
:
function
(
info
,
iconIndex
)
{
alert
:
function
(
info
,
iconIndex
)
{
parent
.
layer
.
msg
(
info
,
{
icon
:
iconIndex
icon
:
iconIndex
});
},
info
:
function
(
info
)
{
info
:
function
(
info
)
{
Feng
.
alert
(
info
,
0
);
},
success
:
function
(
info
)
{
success
:
function
(
info
)
{
Feng
.
alert
(
info
,
1
);
},
error
:
function
(
info
)
{
error
:
function
(
info
)
{
Feng
.
alert
(
info
,
2
);
},
writeObj
:
function
(
obj
)
{
writeObj
:
function
(
obj
)
{
var
description
=
""
;
for
(
var
i
in
obj
)
{
for
(
var
i
in
obj
)
{
var
property
=
obj
[
i
];
description
+=
i
+
" = "
+
property
+
","
;
}
layer
.
alert
(
description
,
{
skin
:
'layui-layer-molv'
,
closeBtn
:
0
skin
:
'layui-layer-molv'
,
closeBtn
:
0
});
},
showInputTree
:
function
(
inputId
,
inputTreeContentId
)
{
var
onBodyDown
=
function
(
event
)
{
showInputTree
:
function
(
inputId
,
inputTreeContentId
)
{
var
onBodyDown
=
function
(
event
)
{
if
(
!
(
event
.
target
.
id
==
"menuBtn"
||
event
.
target
.
id
==
inputTreeContentId
||
$
(
event
.
target
).
parents
(
"#"
+
inputTreeContentId
).
length
>
0
))
{
$
(
"#"
+
inputTreeContentId
).
fadeOut
(
"fast"
);
$
(
"body"
).
unbind
(
"mousedown"
,
onBodyDown
);
// mousedown当鼠标按下就可以触发,不用弹起
...
...
@@ -45,24 +45,30 @@ var Feng = {
var
inputDivOffset
=
$
(
"#"
+
inputId
).
offset
();
$
(
"#"
+
inputTreeContentId
).
css
({
left
:
inputDivOffset
.
left
+
"px"
,
top
:
inputDivOffset
.
top
+
inputDiv
.
outerHeight
()
+
"px"
left
:
inputDivOffset
.
left
+
"px"
,
top
:
inputDivOffset
.
top
+
inputDiv
.
outerHeight
()
+
"px"
}).
slideDown
(
"fast"
);
$
(
"body"
).
bind
(
"mousedown"
,
onBodyDown
);
},
baseAjax
:
function
(
url
,
tip
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
url
,
function
(
data
)
{
baseAjax
:
function
(
url
,
tip
)
{
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
url
,
function
(
data
)
{
Feng
.
success
(
tip
+
"成功!"
);
},
function
(
data
)
{
},
function
(
data
)
{
Feng
.
error
(
tip
+
"失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
return
ajax
;
},
changeAjax
:
function
(
url
)
{
return
Feng
.
baseAjax
(
url
,
"修改"
);
changeAjax
:
function
(
url
)
{
return
Feng
.
baseAjax
(
url
,
"修改"
);
},
addAjax
:
function
(
url
){
return
Feng
.
baseAjax
(
url
,
"添加"
);
zTreeCheckedNodes
:
function
(
zTreeId
)
{
var
zTree
=
$
.
fn
.
zTree
.
getZTreeObj
(
zTreeId
);
var
nodes
=
zTree
.
getCheckedNodes
();
var
ids
=
""
;
for
(
var
i
=
0
,
l
=
nodes
.
length
;
i
<
l
;
i
++
)
{
ids
+=
","
+
nodes
[
i
].
id
;
}
return
ids
.
substring
(
1
);
}
};
src/test/java/com/stylefeng/guns/base/BaseTest.java
View file @
0dc0c8af
package
com
.
stylefeng
.
guns
.
base
;
import
com.stylefeng.guns.core.log.ILog
;
import
com.stylefeng.guns.core.util.SpringContextHolder
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
...
...
@@ -10,4 +13,11 @@ import project.config.root.RootSpringConfig;
@ContextConfiguration
(
classes
=
RootSpringConfig
.
class
)
public
class
BaseTest
{
@Test
public
void
test
()
{
ILog
logFactory
=
SpringContextHolder
.
getBean
(
ILog
.
class
);
logFactory
.
doLog
(
"12"
,
"message"
,
true
);
}
}
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