找传奇、传世资源到传世资源站!

基于 SpringBoot 2 的管理后台系统 SpringBoot

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

一个基于SpringBoot 2 的管理后台系统,包含了用户管理,组织机构管理,角色管理,功能点管理,菜单管理,权限分配,数据权限分配,代码生成等功能 系统基于Spring Boot2技术 doc/readme/user.png package com.ibeetl.admin.core.web;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ibeetl.admin.core.entity.CoreOrg;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.rbac.UserLoginInfo;
import com.ibeetl.admin.core.rbac.tree.MenuItem;
import com.ibeetl.admin.core.service.CorePlatformService;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.admin.core.util.HttpRequestLocal;
import com.ibeetl.admin.core.util.PlatformException;

@Controller
public class IndexController {

@Autowired
CorePlatformService platformService;

@Autowired
CoreUserService userService;

@Autowired
HttpRequestLocal httpRequestLocal;

@RequestMapping("/")
public ModelAndView login() {
ModelAndView view = new ModelAndView("/login.html");
return view;
}

@PostMapping("/login.do")
public ModelAndView login(String code, String password) {
UserLoginInfo info = userService.login(code, password);
if (info == null) {
throw new PlatformException("用户名密码错");
}
CoreUser user = info.getUser();
CoreOrg currentOrg = info.getOrgs().get(0);
for (CoreOrg org : info.getOrgs()) {
if (org.getId() == user.getOrgId()) {
currentOrg = org;
break;
}
}

info.setCurrentOrg(currentOrg);
// 记录登录信息到session
this.platformService.setLoginUser(info.getUser(), info.getCurrentOrg(), info.getOrgs());
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}

@RequestMapping("/index.do")
public ModelAndView index() {
ModelAndView view = new ModelAndView("/index.html");
CoreUser currentUser = platformService.getCurrentUser();
Long orgId = platformService.getCurrentOrgId();
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
view.addObject("menus", menuItem);
return view;
}

@RequestMapping("/logout.do")
public ModelAndView logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration eum = session.getAttributeNames();
while(eum.hasMoreElements()) {
String key = (String)eum.nextElement();
session.removeAttribute(key);
}
ModelAndView view = new ModelAndView("redirect:/");
return view;
}
@RequestMapping("/changeOrg.do")
public ModelAndView changeOrg(HttpServletRequest request,Long orgId) {
platformService.changeOrg(orgId);
ModelAndView view = new ModelAndView("redirect:/index.do");
return view;
}

}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复