一、项目运行
环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax 等等
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
public String saveRoleMenu(String ids,Integer roleId){
Map map = new HashMap();
//调用保存角色菜单关系的方法
if(roleService.saveRoleMenu(ids,roleId)>0){
map.put(SystemConstant.MESSAGE,"菜单分配成功");
}else{
map.put(SystemConstant.MESSAGE,"菜单分配失败");
}
return JSON.toJSONString(map);
}
@RequestMapping("/initRoleListByEmpId")
public DataGridViewResult initRoleListByEmpId(int id){
List
Mapmap = new HashMap (); int updateRole = roleService.updateRole(role); if(updateRole>0){ map.put(SystemConstant.SUCCESS,true); map.put(SystemConstant.MESSAGE,"修改成功"); }else{ map.put(SystemConstant.SUCCESS,false); map.put(SystemConstant.MESSAGE,"修改失败"); } //map中存放的信息已json形式返回 return JSON.toJSONString(map); } //删除角色信息 @RequestMapping("/deleteById") public String deleteById(Integer id){ Map map = new HashMap (); int deleteById = roleService.deleteById(id); if (deleteById>0){ map.put(SystemConstant.SUCCESS,true);//删除成功 map.put(SystemConstant.MESSAGE,"删除成功"); }else{ map.put(SystemConstant.SUCCESS,false);//删除失败 map.put(SystemConstant.MESSAGE,"删除失败"); } return JSON.toJSONString(map); }
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"很遗憾,注册失败,请重新尝试!");
}
return JSON.toJSONString(map);
}
@RequestMapping("/login")
@ResponseBody
public String login(String loginName, String password, HttpSession Session){
Map map = new HashMap();
//调用注册的方法
User loginUser = userService.login(loginName, password);
//登录判断
if(loginUser!=null){
//将密码清空
loginUser.setPassword(null);
}
//创建集合保存树节点信息
List treeNodes = new ArrayList();
//循环遍历集合
for (Menu menu : menuList) {
//定义变量,标识是否选中
String checkArr = "0";//0表示复选框不选中,1表示选中复选框
//内层循环遍历当前角色拥有的权限菜单
//循环比较的原因:比较两个集合中的数据是否有相同的,有相同的表示当前角色拥有这个权限
for (Menu currentMenu : currentMenus) {
//如果ID相等,表示当前角色有这个菜单,有这个菜单则需要将复选框选中
if(menu.getId() == currentMenu.getId()){
checkArr ="1";//选中
Mapmap = new HashMap (); //调用注册的方法 if(userService.addUser(user)>0){ map.put(SystemConstant.SUCCESS,true); map.put(SystemConstant.MESSAGE,"恭喜你,注册成功!"); }else{ map.put(SystemConstant.SUCCESS,false); map.put(SystemConstant.MESSAGE,"很遗憾,注册失败,请重新尝试!"); } return JSON.toJSONString(map); } @RequestMapping("/login") @ResponseBody public String login(String loginName, String password, HttpSession Session){ Map map = new HashMap (); //调用注册的方法 User loginUser = userService.login(loginName, password); //登录判断 if(loginUser!=null){
}
//创建集合保存树节点信息
List treeNodes = new ArrayList();
//循环遍历集合
for (Menu menu : menuList) {
//定义变量,标识是否选中
String checkArr = "0";//0表示复选框不选中,1表示选中复选框
//内层循环遍历当前角色拥有的权限菜单
//循环比较的原因:比较两个集合中的数据是否有相同的,有相同的表示当前角色拥有这个权限
for (Menu currentMenu : currentMenus) {
//如果ID相等,表示当前角色有这个菜单,有这个菜单则需要将复选框选中
if(menu.getId() == currentMenu.getId()){
checkArr ="1";//选中
break;
}
}
//定义变量,表示菜单是否展开
Boolean spread = (menu.getSpread()==null || menu.getSpread()==1) ? true : false;
treeNodes.add(new TreeNode(menu.getId(),menu.getPid(),menu.getTitle(),spread,checkArr));
}
//将数据返回到页面
if(userService.addUser(user)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"恭喜你,注册成功!");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"很遗憾,注册失败,请重新尝试!");
}
return JSON.toJSONString(map);
}
@RequestMapping("/login")
@ResponseBody
public String login(String loginName, String password, HttpSession Session){
Map map = new HashMap();
//调用注册的方法
User loginUser = userService.login(loginName, password);
//登录判断
public DataGridViewResult list(RoleVo roleVo){
//设置分页信息
PageHelper.startPage(roleVo.getPage(),roleVo.getLimit());
//调用分页查询的方法
List roleList = roleService.findRoleList(roleVo);
//创建分页对象
PageInfo pageInfo = new PageInfo(roleList);
//返回数据
return new DataGridViewResult(pageInfo.getTotal(),pageInfo.getList());
}
//添加部门信息
@RequestMapping("/addRole")
public String addRole(Role role){
//创建map存放信息
Map map = new HashMap();
int addRole = roleService.addRole(role);
if(addRole>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"添加成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"添加失败");
}
//map中存放的信息已json形式返回
return JSON.toJSONString(map);
}
//修改角色信息
if(ordersService.addOrders(orders)>0){
map.put(SystemConstant.SUCCESS,true);
map.put(SystemConstant.MESSAGE,"酒店预订成功");
}else{
map.put(SystemConstant.SUCCESS,false);
map.put(SystemConstant.MESSAGE,"酒店预订失败,请重试!");
}
return JSON.toJSONString(map);
}
}
角色管理控制层:
@RequestMapping("/admin/role")
@RestController
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private EmployeeService employeeService;
@Autowired
private MenuService menuService;



