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
deee3fb1
Commit
deee3fb1
authored
Mar 29, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整一些格式
parent
0f10764c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
320 additions
and
101 deletions
+320
-101
README.md
+254
-1
src/main/java/com/stylefeng/guns/modular/system/controller/DeptController.java
+4
-7
src/main/java/com/stylefeng/guns/modular/system/controller/MenuController.java
+19
-29
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
+17
-27
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
+26
-37
No files found.
README.md
View file @
deee3fb1
#guns
#Guns
## 感谢
1.[
SpringBlade
](
http://git.oschina.net/smallc/SpringBlade
)
## 内置功能
1.
用户管理
2.
角色管理
3.
菜单管理
4.
字典管理
5.
部门管理
6.
附件管理
7.
参数管理
8.
连接池监视
9.
日志管理
10.
代码生成
## 技术选型
1、后端
*
核心框架:Spring Framework
*
安全框架:Apache Shiro
*
视图框架:Spring MVC
*
服务端验证:Blade Validator
*
任务调度:Spring Task
*
持久层框架:beetlsql
*
模板引擎:beetl
*
数据库连接池:Alibaba Druid
*
缓存框架:Ehcache
*
日志管理:SLF4J、LOGBACKUP
*
工具类:Apache Commons、FastJson、EASYPOI、BladeToolBox
2、前端
*
JS框架:jQuery
*
CSS框架:Twitter Bootstrap
*
客户端验证:JQuery-html5Validate
*
富文本:KindEcitor
*
数据表格:jqGrid
*
树结构控件:jQuery zTree
*
弹出层:Layer
*
日期控件: LayDate
*
图表控件:echarts
## 后台界面







## 代码示例
实体类
```
@Table(name = "notice")
@BindID(name = "id")
@SuppressWarnings("serial")
public class Notice extends BaseModel {
private String id;
private Integer creater;
private String content;
private String title;
private Date createTime;
@AutoID
@SeqID(name = "SEQ_NOTICE")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
.....................
}
```
新增
```
@Json
@RequestMapping(KEY_SAVE)
public AjaxResult save() {
Notice notice = mapping(PREFIX, Notice.class);
boolean temp = Blade.create(Notice.class).save(notice);
if (temp) {
return success(SAVE_SUCCESS_MSG);
} else {
return error(SAVE_FAIL_MSG);
}
}
```
修改
```
@Json
@RequestMapping(KEY_UPDATE)
public AjaxResult update() {
Notice notice = mapping(PREFIX, Notice.class);
boolean temp = Blade.create(Notice.class).update(notice);
if (temp) {
return success(UPDATE_SUCCESS_MSG);
} else {
return error(UPDATE_FAIL_MSG);
}
}
```
删除
```
@Json
@RequestMapping(KEY_REMOVE)
public AjaxResult remove(@RequestParam String ids) {
int cnt = Blade.create(Notice.class).deleteByIds(ids);
if (cnt > 0) {
return success(DEL_SUCCESS_MSG);
} else {
return error(DEL_FAIL_MSG);
}
}
```
自定义sql查询,返回map
```
List<Map> list = Db.selectList("select * form news where title = #{title}", CMap.init().set("title", "标题测试"));
```
自定义sql查询,返回String(使用多数据源)
```
String editor = Db.init("otherDb").queryStr("select editor form news where newsId = #{newsId}", CMap.init().set("newsId", 123));
```
根据md文件的sql执行修改
```
int cnt = Md.update("news.update", CMap.init().set("title", "标题测试").set("id", "1"));
```
根据条件修改
```
boolean temp = Blade.create(News.class).updateBy("editor = #{editor}", "title = #{title}", CMap.init().set("title", "测试标题").set("editor", "编辑一"));
```
根据条件删除
```
String ids = "1,2,3,4,5";
String[] idArr = ids.split(",");
int cnt = Blade.create(News.class).deleteBy("status in (#{join(ids)})", CMap.init().set("ids", idArr));
```
## 通用Service
```
public interface NoticeService extends IService<Notice> {
}
@Service
public class NoticeServiceImpl extends BaseService<Notice> implements NoticeService {
}
@Autowired
NoticeService service;
@Json
@RequestMapping(KEY_SAVE)
public AjaxResult save() {
Notice notice = mapping(PREFIX, Notice.class);
boolean temp = service.save(notice);
if (temp) {
return success(SAVE_SUCCESS_MSG);
} else {
return error(SAVE_FAIL_MSG);
}
}
```
## 分页
```
@Json
@RequestMapping(KEY_LIST)
public Object list() {
Object grid = paginate(LIST_SOURCE, new IQuery() {
@Override
public void queryBefore(AopContext ac) {
if (ShiroKit.lacksRole(ConstShiro.ADMINISTRATOR)) {
String condition = "and creater = #{creater}";
ac.setCondition(condition);
ac.getParam().put("creater", ShiroKit.getUser().getId());
}
}
@Override
public void queryAfter(AopContext ac) {
@SuppressWarnings("unchecked")
BladePage<Map<String, Object>> page = (BladePage<Map<String, Object>>) ac.getObject();
List<Map<String, Object>> list = page.getRows();
for (Map<String, Object> map : list) {
map.put("createrName", SysCache.getDictName(102, map.get("creater")));
}
}
});
return grid;
}
```
注:
=======
欢迎提出更好的意见, 大家共同进步
SpringBlade主要用于交流学习, 开源协议署名为smallchill的代码也可以进行商用
但是如果因为商业用途引起的纠纷和造成的一切后果请自行承担
登陆名密码:两个 admin
SpringBlade交流群:
`477853168`
主要给大家交流学习, 本人工作比较忙, 回复的少请见谅
SpringBlade不搞捐赠, 不打广告, 只做最单纯的开源项目
如果需要非maven版,请点击
[
SpringBlade
](
http://git.oschina.net/smallc/SpringBlade_General
)
常见问题
=======
##1.linux下登陆报未知错误
发布在linux的小伙伴需要做如下操作:
`vi /etc/my.cnf`
在
[
mysqld
]
节点下增加
`lower_case_table_names = 1`
`:wq`
`service mysqld restart`
取消大小写敏感,就可以正常运行了
##2.连接oracle报未知错误
到resource文件夹下config.properties修改oracle链接,然后到resource/spring/applicationContext.xml找到
```
<property name="dbStyle">
<bean class="org.beetl.sql.core.db.MySqlStyle"></bean>
</property>
```
将
`MySqlStyle`
改为
`OracleStyle`
##3.创建model后有没有自动生成javabean字段和sql的办法?
有,访问如下两个地址:
`localhost:8080/blade/generate/pojo/blade_menu`
`localhost:8080/blade/generate/sql/com.smallchill.system.model.Menu`
查看控制台打印结果,按自己需求复制粘贴到model和md文件中
src/main/java/com/stylefeng/guns/modular/system/controller/DeptController.java
View file @
deee3fb1
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.modular.system.dao.DeptDao
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.stylefeng.guns.modular.system.dao.DeptDao
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* 部门控制器
* 部门控制器
...
@@ -31,9 +29,8 @@ public class DeptController extends BaseController {
...
@@ -31,9 +29,8 @@ public class DeptController extends BaseController {
* 获取部门的tree列表
* 获取部门的tree列表
*/
*/
@RequestMapping
(
value
=
"/tree"
)
@RequestMapping
(
value
=
"/tree"
)
public
@ResponseBody
@ResponseBody
List
<
ZTreeNode
>
tree
()
{
public
List
<
ZTreeNode
>
tree
()
{
return
this
.
deptDao
.
tree
();
return
this
.
deptDao
.
tree
();
}
}
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/MenuController.java
View file @
deee3fb1
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
java.util.List
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.state.MenuStatus
;
import
com.stylefeng.guns.common.constant.state.MenuStatus
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.co
mmon.annotion.Permission
;
import
com.stylefeng.guns.co
re.util.ToolUtil
;
import
com.stylefeng.guns.modular.system.dao.MenuDao
;
import
com.stylefeng.guns.modular.system.dao.MenuDao
;
import
com.stylefeng.guns.modular.system.warpper.MenuWarpper
;
import
com.stylefeng.guns.persistence.dao.MenuMapper
;
import
com.stylefeng.guns.persistence.model.Menu
;
import
com.stylefeng.guns.persistence.model.Menu
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
...
@@ -20,12 +20,10 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -20,12 +20,10 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
javax.annotation.Resource
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
javax.validation.Valid
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
java.util.List
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
java.util.Map
;
import
com.stylefeng.guns.modular.system.warpper.MenuWarpper
;
import
com.stylefeng.guns.persistence.dao.MenuMapper
;
/**
/**
* 菜单控制器
* 菜单控制器
...
@@ -78,9 +76,8 @@ public class MenuController extends BaseController {
...
@@ -78,9 +76,8 @@ public class MenuController extends BaseController {
* 获取菜单列表
* 获取菜单列表
*/
*/
@RequestMapping
(
value
=
"/list"
)
@RequestMapping
(
value
=
"/list"
)
public
@ResponseBody
@ResponseBody
Object
list
()
{
public
Object
list
()
{
List
<
Map
<
String
,
Object
>>
menus
=
this
.
menuDao
.
selectMenus
(
null
);
List
<
Map
<
String
,
Object
>>
menus
=
this
.
menuDao
.
selectMenus
(
null
);
return
super
.
warpObject
(
new
MenuWarpper
(
menus
));
return
super
.
warpObject
(
new
MenuWarpper
(
menus
));
}
}
...
@@ -89,9 +86,8 @@ public class MenuController extends BaseController {
...
@@ -89,9 +86,8 @@ public class MenuController extends BaseController {
* 获取菜单列表
* 获取菜单列表
*/
*/
@RequestMapping
(
value
=
"/list/{condition}"
)
@RequestMapping
(
value
=
"/list/{condition}"
)
public
@ResponseBody
@ResponseBody
Object
list
(
@PathVariable
String
condition
)
{
public
Object
list
(
@PathVariable
String
condition
)
{
if
(
ToolUtil
.
isEmpty
(
condition
))
{
if
(
ToolUtil
.
isEmpty
(
condition
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -104,9 +100,8 @@ public class MenuController extends BaseController {
...
@@ -104,9 +100,8 @@ public class MenuController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/add"
)
@RequestMapping
(
value
=
"/add"
)
public
@ResponseBody
@ResponseBody
Tip
add
(
@Valid
Menu
menu
,
BindingResult
result
)
{
public
Tip
add
(
@Valid
Menu
menu
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -120,9 +115,8 @@ public class MenuController extends BaseController {
...
@@ -120,9 +115,8 @@ public class MenuController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/edit"
)
@RequestMapping
(
value
=
"/edit"
)
public
@ResponseBody
@ResponseBody
Tip
edit
(
@Valid
Menu
menu
,
BindingResult
result
)
{
public
Tip
edit
(
@Valid
Menu
menu
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -135,9 +129,8 @@ public class MenuController extends BaseController {
...
@@ -135,9 +129,8 @@ public class MenuController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/remove/{menuId}"
)
@RequestMapping
(
value
=
"/remove/{menuId}"
)
public
@ResponseBody
@ResponseBody
Tip
remove
(
@PathVariable
Integer
menuId
)
{
public
Tip
remove
(
@PathVariable
Integer
menuId
)
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -155,9 +148,8 @@ public class MenuController extends BaseController {
...
@@ -155,9 +148,8 @@ public class MenuController extends BaseController {
* 查看菜单
* 查看菜单
*/
*/
@RequestMapping
(
value
=
"/view/{menuId}"
)
@RequestMapping
(
value
=
"/view/{menuId}"
)
public
@ResponseBody
@ResponseBody
Tip
view
(
@PathVariable
Integer
menuId
)
{
public
Tip
view
(
@PathVariable
Integer
menuId
)
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
if
(
ToolUtil
.
isEmpty
(
menuId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -169,9 +161,8 @@ public class MenuController extends BaseController {
...
@@ -169,9 +161,8 @@ public class MenuController extends BaseController {
* 获取菜单列表
* 获取菜单列表
*/
*/
@RequestMapping
(
value
=
"/menuTreeList"
)
@RequestMapping
(
value
=
"/menuTreeList"
)
public
@ResponseBody
@ResponseBody
List
<
ZTreeNode
>
menuTreeList
()
{
public
List
<
ZTreeNode
>
menuTreeList
()
{
List
<
ZTreeNode
>
roleTreeList
=
this
.
menuDao
.
menuTreeList
();
List
<
ZTreeNode
>
roleTreeList
=
this
.
menuDao
.
menuTreeList
();
return
roleTreeList
;
return
roleTreeList
;
}
}
...
@@ -180,9 +171,8 @@ public class MenuController extends BaseController {
...
@@ -180,9 +171,8 @@ public class MenuController extends BaseController {
* 获取角色列表
* 获取角色列表
*/
*/
@RequestMapping
(
value
=
"/menuTreeListByRoleId/{roleId}"
)
@RequestMapping
(
value
=
"/menuTreeListByRoleId/{roleId}"
)
public
@ResponseBody
@ResponseBody
List
<
ZTreeNode
>
menuTreeListByRoleId
(
@PathVariable
Integer
roleId
)
{
public
List
<
ZTreeNode
>
menuTreeListByRoleId
(
@PathVariable
Integer
roleId
)
{
List
<
Integer
>
menuIds
=
this
.
menuDao
.
getMenuIdsByRoleId
(
roleId
);
List
<
Integer
>
menuIds
=
this
.
menuDao
.
getMenuIdsByRoleId
(
roleId
);
if
(
ToolUtil
.
isEmpty
(
menuIds
))
{
if
(
ToolUtil
.
isEmpty
(
menuIds
))
{
List
<
ZTreeNode
>
roleTreeList
=
this
.
menuDao
.
menuTreeList
();
List
<
ZTreeNode
>
roleTreeList
=
this
.
menuDao
.
menuTreeList
();
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/RoleController.java
View file @
deee3fb1
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
java.util.List
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.factory.ConstantFactory
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.common.node.ZTreeNode
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.Convert
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
com.stylefeng.guns.modular.system.dao.RoleDao
;
import
com.stylefeng.guns.modular.system.dao.RoleDao
;
import
com.stylefeng.guns.modular.system.service.IRoleService
;
import
com.stylefeng.guns.modular.system.service.IRoleService
;
import
com.stylefeng.guns.modular.system.warpper.RoleWarpper
;
import
com.stylefeng.guns.modular.system.warpper.RoleWarpper
;
import
com.stylefeng.guns.persistence.dao.RoleMapper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.model.Role
;
import
com.stylefeng.guns.persistence.model.Role
;
import
com.stylefeng.guns.persistence.model.User
;
import
com.stylefeng.guns.persistence.model.User
;
...
@@ -27,10 +25,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -27,10 +25,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
javax.annotation.Resource
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
javax.validation.Valid
;
import
com.stylefeng.guns.core.util.ToolUtil
;
import
java.util.List
;
import
com.stylefeng.guns.persistence.dao.RoleMapper
;
import
java.util.Map
;
/**
/**
* 角色控制器
* 角色控制器
...
@@ -104,9 +102,8 @@ public class RoleController extends BaseController {
...
@@ -104,9 +102,8 @@ public class RoleController extends BaseController {
* 获取角色列表
* 获取角色列表
*/
*/
@RequestMapping
(
value
=
"/list"
)
@RequestMapping
(
value
=
"/list"
)
public
@ResponseBody
@ResponseBody
Object
list
()
{
public
Object
list
()
{
List
<
Map
<
String
,
Object
>>
roles
=
this
.
roleDao
.
selectRoles
(
super
.
getPara
(
"condition"
));
List
<
Map
<
String
,
Object
>>
roles
=
this
.
roleDao
.
selectRoles
(
super
.
getPara
(
"condition"
));
return
super
.
warpObject
(
new
RoleWarpper
(
roles
));
return
super
.
warpObject
(
new
RoleWarpper
(
roles
));
}
}
...
@@ -116,9 +113,8 @@ public class RoleController extends BaseController {
...
@@ -116,9 +113,8 @@ public class RoleController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/add"
)
@RequestMapping
(
value
=
"/add"
)
public
@ResponseBody
@ResponseBody
Tip
add
(
@Valid
Role
role
,
BindingResult
result
)
{
public
Tip
add
(
@Valid
Role
role
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -132,9 +128,8 @@ public class RoleController extends BaseController {
...
@@ -132,9 +128,8 @@ public class RoleController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/edit"
)
@RequestMapping
(
value
=
"/edit"
)
public
@ResponseBody
@ResponseBody
Tip
edit
(
@Valid
Role
role
,
BindingResult
result
)
{
public
Tip
edit
(
@Valid
Role
role
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -147,9 +142,8 @@ public class RoleController extends BaseController {
...
@@ -147,9 +142,8 @@ public class RoleController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
value
=
"/remove/{roleId}"
)
@RequestMapping
(
value
=
"/remove/{roleId}"
)
public
@ResponseBody
@ResponseBody
Tip
remove
(
@PathVariable
Integer
roleId
)
{
public
Tip
remove
(
@PathVariable
Integer
roleId
)
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -164,9 +158,8 @@ public class RoleController extends BaseController {
...
@@ -164,9 +158,8 @@ public class RoleController extends BaseController {
* 查看角色
* 查看角色
*/
*/
@RequestMapping
(
value
=
"/view/{roleId}"
)
@RequestMapping
(
value
=
"/view/{roleId}"
)
public
@ResponseBody
@ResponseBody
Tip
view
(
@PathVariable
Integer
roleId
)
{
public
Tip
view
(
@PathVariable
Integer
roleId
)
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
if
(
ToolUtil
.
isEmpty
(
roleId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -179,9 +172,8 @@ public class RoleController extends BaseController {
...
@@ -179,9 +172,8 @@ public class RoleController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/setAuthority"
)
@RequestMapping
(
"/setAuthority"
)
public
@ResponseBody
@ResponseBody
Tip
setAuthority
(
@RequestParam
(
"roleId"
)
Integer
roleId
,
@RequestParam
(
"ids"
)
String
ids
)
{
public
Tip
setAuthority
(
@RequestParam
(
"roleId"
)
Integer
roleId
,
@RequestParam
(
"ids"
)
String
ids
)
{
if
(
ToolUtil
.
isOneEmpty
(
roleId
))
{
if
(
ToolUtil
.
isOneEmpty
(
roleId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -193,9 +185,8 @@ public class RoleController extends BaseController {
...
@@ -193,9 +185,8 @@ public class RoleController extends BaseController {
* 获取角色列表
* 获取角色列表
*/
*/
@RequestMapping
(
value
=
"/roleTreeList"
)
@RequestMapping
(
value
=
"/roleTreeList"
)
public
@ResponseBody
@ResponseBody
List
<
ZTreeNode
>
roleTreeList
()
{
public
List
<
ZTreeNode
>
roleTreeList
()
{
List
<
ZTreeNode
>
roleTreeList
=
this
.
roleDao
.
roleTreeList
();
List
<
ZTreeNode
>
roleTreeList
=
this
.
roleDao
.
roleTreeList
();
roleTreeList
.
add
(
ZTreeNode
.
createParent
());
roleTreeList
.
add
(
ZTreeNode
.
createParent
());
return
roleTreeList
;
return
roleTreeList
;
...
@@ -205,9 +196,8 @@ public class RoleController extends BaseController {
...
@@ -205,9 +196,8 @@ public class RoleController extends BaseController {
* 获取角色列表
* 获取角色列表
*/
*/
@RequestMapping
(
value
=
"/roleTreeListByUserId/{userId}"
)
@RequestMapping
(
value
=
"/roleTreeListByUserId/{userId}"
)
public
@ResponseBody
@ResponseBody
List
<
ZTreeNode
>
roleTreeListByUserId
(
@PathVariable
Integer
userId
)
{
public
List
<
ZTreeNode
>
roleTreeListByUserId
(
@PathVariable
Integer
userId
)
{
User
theUser
=
this
.
userMapper
.
selectById
(
userId
);
User
theUser
=
this
.
userMapper
.
selectById
(
userId
);
String
roleid
=
theUser
.
getRoleid
();
String
roleid
=
theUser
.
getRoleid
();
if
(
ToolUtil
.
isEmpty
(
roleid
))
{
if
(
ToolUtil
.
isEmpty
(
roleid
))
{
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
View file @
deee3fb1
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
package
com
.
stylefeng
.
guns
.
modular
.
system
.
controller
;
import
java.util.Date
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
javax.naming.NoPermissionException
;
import
javax.validation.Valid
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.stylefeng.guns.common.constant.Const
;
import
com.stylefeng.guns.common.constant.Const
;
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.constant.tips.Tip
;
import
com.stylefeng.guns.common.constant.tips.Tip
;
import
com.stylefeng.guns.common.controller.BaseController
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BizExceptionEnum
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
com.stylefeng.guns.common.exception.BussinessException
;
import
com.stylefeng.guns.common.annotion.Permission
;
import
com.stylefeng.guns.core.db.Db
;
import
com.stylefeng.guns.core.db.Db
;
import
com.stylefeng.guns.core.shiro.ShiroKit
;
import
com.stylefeng.guns.core.shiro.ShiroKit
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
import
com.stylefeng.guns.core.shiro.ShiroUser
;
...
@@ -33,6 +16,21 @@ import com.stylefeng.guns.modular.system.dao.UserMgrDao;
...
@@ -33,6 +16,21 @@ import com.stylefeng.guns.modular.system.dao.UserMgrDao;
import
com.stylefeng.guns.modular.system.warpper.UserWarpper
;
import
com.stylefeng.guns.modular.system.warpper.UserWarpper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.dao.UserMapper
;
import
com.stylefeng.guns.persistence.model.User
;
import
com.stylefeng.guns.persistence.model.User
;
import
org.apache.shiro.authc.AuthenticationException
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
javax.naming.NoPermissionException
;
import
javax.validation.Valid
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 系统管理员控制器
* 系统管理员控制器
...
@@ -116,9 +114,8 @@ public class UserMgrController extends BaseController {
...
@@ -116,9 +114,8 @@ public class UserMgrController extends BaseController {
* 查询管理员列表
* 查询管理员列表
*/
*/
@RequestMapping
(
"/list"
)
@RequestMapping
(
"/list"
)
public
@ResponseBody
@ResponseBody
Object
list
()
{
public
Object
list
()
{
List
<
Map
<
String
,
Object
>>
users
=
managerDao
.
selectUsers
(
super
.
getPara
(
"condition"
));
List
<
Map
<
String
,
Object
>>
users
=
managerDao
.
selectUsers
(
super
.
getPara
(
"condition"
));
return
new
UserWarpper
(
users
).
warp
();
return
new
UserWarpper
(
users
).
warp
();
}
}
...
@@ -128,9 +125,8 @@ public class UserMgrController extends BaseController {
...
@@ -128,9 +125,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/add"
)
@RequestMapping
(
"/add"
)
public
@ResponseBody
@ResponseBody
Tip
add
(
@Valid
User
user
,
BindingResult
result
)
{
public
Tip
add
(
@Valid
User
user
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -156,9 +152,8 @@ public class UserMgrController extends BaseController {
...
@@ -156,9 +152,8 @@ public class UserMgrController extends BaseController {
* @throws NoPermissionException
* @throws NoPermissionException
*/
*/
@RequestMapping
(
"/edit"
)
@RequestMapping
(
"/edit"
)
public
@ResponseBody
@ResponseBody
Tip
edit
(
@Valid
User
user
,
BindingResult
result
)
throws
NoPermissionException
{
public
Tip
edit
(
@Valid
User
user
,
BindingResult
result
)
throws
NoPermissionException
{
if
(
result
.
hasErrors
())
{
if
(
result
.
hasErrors
())
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -181,9 +176,8 @@ public class UserMgrController extends BaseController {
...
@@ -181,9 +176,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/delete/{userId}"
)
@RequestMapping
(
"/delete/{userId}"
)
public
@ResponseBody
@ResponseBody
Tip
delete
(
@PathVariable
Integer
userId
)
{
public
Tip
delete
(
@PathVariable
Integer
userId
)
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -195,9 +189,8 @@ public class UserMgrController extends BaseController {
...
@@ -195,9 +189,8 @@ public class UserMgrController extends BaseController {
* 查看管理员详情
* 查看管理员详情
*/
*/
@RequestMapping
(
"/view/{userId}"
)
@RequestMapping
(
"/view/{userId}"
)
public
@ResponseBody
@ResponseBody
User
view
(
@PathVariable
Integer
userId
)
{
public
User
view
(
@PathVariable
Integer
userId
)
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -209,9 +202,8 @@ public class UserMgrController extends BaseController {
...
@@ -209,9 +202,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/reset/{userId}"
)
@RequestMapping
(
"/reset/{userId}"
)
public
@ResponseBody
@ResponseBody
Tip
reset
(
@PathVariable
Integer
userId
)
{
public
Tip
reset
(
@PathVariable
Integer
userId
)
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -227,9 +219,8 @@ public class UserMgrController extends BaseController {
...
@@ -227,9 +219,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/freeze/{userId}"
)
@RequestMapping
(
"/freeze/{userId}"
)
public
@ResponseBody
@ResponseBody
Tip
freeze
(
@PathVariable
Integer
userId
)
{
public
Tip
freeze
(
@PathVariable
Integer
userId
)
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -242,9 +233,8 @@ public class UserMgrController extends BaseController {
...
@@ -242,9 +233,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/unfreeze/{userId}"
)
@RequestMapping
(
"/unfreeze/{userId}"
)
public
@ResponseBody
@ResponseBody
Tip
unfreeze
(
@PathVariable
Integer
userId
)
{
public
Tip
unfreeze
(
@PathVariable
Integer
userId
)
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
if
(
ToolUtil
.
isEmpty
(
userId
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
@@ -257,9 +247,8 @@ public class UserMgrController extends BaseController {
...
@@ -257,9 +247,8 @@ public class UserMgrController extends BaseController {
*/
*/
@Permission
(
Const
.
ADMIN_NAME
)
@Permission
(
Const
.
ADMIN_NAME
)
@RequestMapping
(
"/setRole"
)
@RequestMapping
(
"/setRole"
)
public
@ResponseBody
@ResponseBody
Tip
setRole
(
@RequestParam
(
"userId"
)
Integer
userId
,
@RequestParam
(
"roleIds"
)
String
roleIds
)
{
public
Tip
setRole
(
@RequestParam
(
"userId"
)
Integer
userId
,
@RequestParam
(
"roleIds"
)
String
roleIds
)
{
if
(
ToolUtil
.
isOneEmpty
(
userId
,
roleIds
))
{
if
(
ToolUtil
.
isOneEmpty
(
userId
,
roleIds
))
{
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
throw
new
BussinessException
(
BizExceptionEnum
.
REQUEST_NULL
);
}
}
...
...
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