删除无用文件
parent
8949af75a9
commit
6239cc67ff
@ -1,153 +0,0 @@
|
|||||||
package com.ibeetl.admin.core.web;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
|
|
||||||
import com.ibeetl.admin.core.util.TimeTool;
|
|
||||||
import com.ibeetl.admin.core.util.Tool;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public static final String previewIndex = ResourceBundle.getBundle("application").getString("we_chat.baseUrl").replace("server","")+"previewIndex.html";
|
|
||||||
public static final String webSocketServer = ResourceBundle.getBundle("application").getString("we_chat.baseUrl").replace("8080","9090");
|
|
||||||
|
|
||||||
@RequestMapping("/")
|
|
||||||
public ModelAndView login() {
|
|
||||||
ModelAndView view = new ModelAndView("/login.html");
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/getNowTime.json")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResult getNowTime() {
|
|
||||||
return JsonResult.success(TimeTool.getNowTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/login.json")
|
|
||||||
@ResponseBody
|
|
||||||
public JsonResult login(String code, String password) {
|
|
||||||
UserLoginInfo info = null;
|
|
||||||
try {
|
|
||||||
info = userService.login(code, password);
|
|
||||||
}catch (Exception e){
|
|
||||||
return JsonResult.failMessage(e.getMessage());
|
|
||||||
}
|
|
||||||
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());
|
|
||||||
return JsonResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
//跳转到电脑端首页
|
|
||||||
@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);
|
|
||||||
view.addObject("htmlUrl", previewIndex);
|
|
||||||
view.addObject("webSocketServer", webSocketServer);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
//跳转到手机端首页
|
|
||||||
@RequestMapping("/phoneIndex.do")
|
|
||||||
public ModelAndView phoneIndex() {
|
|
||||||
ModelAndView view = new ModelAndView("/phoneIndex.html");
|
|
||||||
|
|
||||||
CoreUser currentUser = platformService.getCurrentUser();
|
|
||||||
Long orgId = platformService.getCurrentOrgId();
|
|
||||||
MenuItem menuItem = platformService.getMenuItem(currentUser.getId(), orgId);
|
|
||||||
List<MenuItem> childrenMenuItemList = new ArrayList<>();
|
|
||||||
if(null != menuItem){
|
|
||||||
List<MenuItem> menuItemList = menuItem.getChildren();
|
|
||||||
if(null != menuItemList && menuItemList.size() > 0){
|
|
||||||
if(null != menuItem && menuItem.getChildren().size() == 1){
|
|
||||||
menuItem = menuItemList.get(0);
|
|
||||||
if(null != menuItem){
|
|
||||||
menuItemList = menuItem.getChildren();
|
|
||||||
for(int i=0;null != menuItemList && i<menuItemList.size();i++){
|
|
||||||
if(null != menuItemList.get(i) && null != menuItemList.get(i).getChildren() && menuItemList.get(i).getChildren().size() > 0){
|
|
||||||
List<MenuItem> menuItems = Tool.deepCopy(menuItemList.get(i).getChildren());
|
|
||||||
for(int j=0;j<menuItems.size();j++){
|
|
||||||
Object accessUrl = menuItems.get(j).getData().get("accessUrl");
|
|
||||||
if(null != accessUrl && StringUtils.isNotBlank(accessUrl.toString())){
|
|
||||||
//跳转地址统一替换为 phone 开头
|
|
||||||
String doUrl = accessUrl.toString().substring(accessUrl.toString().lastIndexOf("/")+1);
|
|
||||||
String phoneDoUrl = "phone" + StringUtils.upperCase(doUrl.substring(0,1)) + doUrl.substring(1);
|
|
||||||
menuItems.get(j).getData().set("accessUrl",accessUrl.toString().replace(doUrl,phoneDoUrl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
childrenMenuItemList.addAll(menuItems);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
view.addObject("childrenMenus", childrenMenuItemList);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue