package com.zjt.web;
import com.github.pagehelper.PageHelper;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.zjt.entity.Tmenu;
import com.zjt.entity.Trole;
import com.zjt.entity.Trolemenu;
import com.zjt.entity.Tuserrole;
import com.zjt.model.JqgridBean;
import com.zjt.model.PageRusult;
import com.zjt.service.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import java.util.*;
/**
* 后台管理用户Controller
*
* @author zjt
*/
@Controller
@RequestMapping("/admin/role")
public class RoleAdminController {
@Resource
private TuserService userService;
@Resource
private TroleService roleService;
@Resource
private TuserroleService userRoleService;
@Resource
private TmenuService tmenuService;
@Resource
private TrolemenuService trolemenuService;
@RequestMapping("/torolemanage")
@RequiresPermissions(value = {"角色管理"})
public String tousermanage() {
return "power/role";
}
/**
* 分页查询角色信息
*/
@ResponseBody
@RequestMapping(value = "/list")
@RequiresPermissions(value = {"角色管理"})
public Map<String, Object> list(JqgridBean jqgridbean
/*String userName,@RequestParam(value="page",required=false)Integer page*/
) throws Exception {
LinkedHashMap<String, Object> resultmap = new LinkedHashMap<String, Object>();
LinkedHashMap<String, Object> datamap = new LinkedHashMap<String, Object>();
Example troleExample = new Example(Trole.class);
//tuserExample.or().andIdNotEqualTo(1L);
Example.Criteria criteria = troleExample.or();
if (StringUtils.isNotEmpty(jqgridbean.getSearchField())) {
if ("name".equalsIgnoreCase(jqgridbean.getSearchField())) {
if ("eq".contentEquals(jqgridbean.getSearchOper())) {
criteria.andEqualTo("name",jqgridbean.getSearchString());
}
}
}
PageHelper.startPage(jqgridbean.getPage(), jqgridbean.getLength());
List<Trole> roleList = roleService.selectByExample(troleExample);
PageRusult<Trole> pageRusult =new PageRusult<Trole>(roleList);
/*Integer totalrecords = roleService.countByExample(troleExample);//总记录数
Page pagebean = new Page(jqgridbean.getLength() * ((jqgridbean.getPage() > 0 ? jqgridbean.getPage() : 1) - 1), jqgridbean.getLength(), totalrecords);
troleExample.setPage(pagebean);
troleExample.setOrderByClause(jqgridbean.getSidx() + " " + jqgridbean.getSord());
List<Trole> roleList = roleService.selectByExample(troleExample);*/
resultmap.put("currpage", String.valueOf(pageRusult.getPageNum()));
resultmap.put("totalpages", String.valueOf(pageRusult.getPages()));
resultmap.put("totalrecords", String.valueOf(pageRusult.getTotal()));
resultmap.put("datamap", roleList);
return resultmap;
}
@ResponseBody
@RequestMapping(value = "/addupdaterole")
@RequiresPermissions(value = {"角色管理"})
public Map<String, Object> addupdaterole(Trole trole) {
LinkedHashMap<String, Object> resultmap = new LinkedHashMap<String, Object>();
try {
if (trole.getId() == null) {//新建
//首先判断用户名是否可用
Example troleExample = new Example(Trole.class);
troleExample.or().andEqualTo("name",trole.getName());
List<Trole> rolelist = roleService.selectByExample(troleExample);
if (rolelist != null && rolelist.size() > 0) {
resultmap.put("state", "fail");
resultmap.put("mesg", "当前角色名已存在");
return resultmap;
}
roleService.saveNotNull(trole);
} else {//编辑
Trole oldObject = roleService.selectByKey(trole.getId());
if (oldObject == null) {
resultmap.put("state", "fail");
resultmap.put("mesg", "当前角色名不存在");
return resultmap;
} else {
roleService.updateNotNull(trole);
}
}
resultmap.put("state", "success");
resultmap.put("mesg", "操作成功");
return resultmap;
} catch (Exception e) {
e.printStackTrace();
resultmap.put("state", "fail");
resultmap.put("mesg", "操作失败,系统异常");
return resultmap;
}
}
@ResponseBody
@RequestMapping(value = "/deleterole")
@RequiresPermissions(value = {"角色管理"})
public Map<String, Object> deleteuser(Trole trole) {
LinkedHashMap<String, Object> resultmap = new LinkedHashMap<String, Object>();
try {
if (trole.getId() != null && !trole.getId().equals(0)) {
Trole role = roleService.selectByKey(trole.getId());
if (role == null) {
resultmap.put("state", "fail");
resultmap.put("mesg", "删除失败,无法找到该记录");
return resultmap;
} else {
//还需删除用户角色中间表
Example tuserroleexample = new Example(Tuserrole.class);
tuserroleexample.or().andEqualTo("roleId",trole.getId());
userRoleService.deleteByExample(tuserroleexample);
Example trolemenuexample = new Example(Trolemenu.class);
trolemenuexample.or().andEqualTo("roleId",trole.getId());
trolemenuService.deleteByExample(trolemenuexample);
roleService.delete(trole.getId());
}
} else {
resultmap.put("state", "fail");
resultmap.put("mesg", "删除失败");
}
resultmap.put("state", "success");
resultmap.put("mesg", "删除成功");
return resultmap;
} catch (Exception e) {
e.printStackTrace();
resultmap.put("state", "fail");
resultmap.put("mesg", "删除失败,系统异常");
return resultmap;
}
}
@ResponseBody
@RequestMapping(value = "/selectRoleById")
@RequiresPermissions(value = {"角色管理"})
public Map<String, Object> selectRoleById(Trole trole) {
LinkedHashMap<String, Object> resultmap = new LinkedHashMap<String, Object>();
try {
if (trole.getId() != null && !trole.getId().equals(0)) {
trole = roleService.selectByKey(trole.getId());
if (trole == null) {
resultmap.put("state", "fail");
resultmap.put("mesg", "无法找到该记录");
return resultmap;
}
} else {
resultmap.put("state", "fail");
resultmap.put("mesg", "无法找到该记录的id");
return resultmap;
}
resultmap.put("trole", trole);
resultmap.put("state", "success");
resultmap.put("mesg", "获取成功");
return resultmap;
} catch (Exception e) {
e.printStackTrace();
resultmap.put("state", "fail");
resultmap.put("mesg", "获取失败,系统异常");
return resultmap;
}
}
/**
* 根据父节点获取所有复选框权限�
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Java实现管理系统,包括电商系统、学生管理系统、图书管理系统、员工管理系统、宿舍管理系统、合同管理系统、酒店管理系统、资产管理系统、企业管理系统ERP等,基于SpringBoot、MySQL、MyBatis、SpringMVC、EasyUI、SSM等技术实现,适合于期末课设、毕设和工程商用。
资源推荐
资源详情
资源评论
收起资源包目录
通用的java后台管理系统(权限管理+用户管理+菜单管理).zip (460个子文件)
mvnw.cmd 5KB
bootstrap.min.css 118KB
layui.css 59KB
font-awesome.css 37KB
jquery-ui.css 36KB
jquery-ui-1.8.16.custom.css 33KB
jquery-ui-1.8.16.custom.css 33KB
jquery-ui-1.8.16.custom.css 33KB
jquery-ui-1.8.16.custom.css 33KB
jquery-ui-1.8.20.custom.css 33KB
font-awesome.min.css 30KB
layuiGlobalForIcon.css 23KB
global.css 19KB
jquery-ui-1.8.16.custom.css 19KB
jquery-ui.theme.css 18KB
layer.css 14KB
ui.jqgrid.css 13KB
public.css 12KB
index.css 10KB
layui.mobile.css 10KB
awesome.css 8KB
laydate.css 7KB
metroStyle.css 6KB
zTreeStyle.css 6KB
demo.css 2KB
ui.multiselect.css 2KB
code.css 1KB
searchFilter.css 393B
fontawesome-webfont.eot 162KB
iconfont.eot 38KB
glyphicons-halflings-regular.eot 20KB
role.ftl 28KB
user.ftl 25KB
welcome.ftl 16KB
menu.ftl 15KB
login.ftl 7KB
updatePassword.ftl 3KB
common.ftl 1KB
main.ftl 960B
errordeal.ftl 31B
unauthorized.ftl 31B
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
zTreeStandard.gif 5KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
metro.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
共 460 条
- 1
- 2
- 3
- 4
- 5
资源评论
AI码东道主
- 粉丝: 5466
- 资源: 165
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 写入三菱plcD位寄存器的值
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- HDMI 虚拟软件欺骗器
- 确保你的操作系统符合Docker的要求 Docker支持的操作系统包括Ubuntu、Debian、CentOS、Fedora和m
- 读取三菱PLC D位寄存器
- HDMI edid 编辑工具
- 要在你的计算机上安装Docker,你可以按照以下步骤进行:
- 要在你的计算机上安装Docker,你可以按照以下步骤进行:
- html加JavaScript进行表单验证
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功