Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Sep 21, 2016
1 parent 8451bec commit 101b786
Showing 1 changed file with 1 addition and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import cn.wizzer.common.shiro.exception.EmptyCaptchaException;
import cn.wizzer.common.shiro.exception.IncorrectCaptchaException;
import cn.wizzer.common.shiro.filter.AuthenticationFilter;
import cn.wizzer.common.util.StringUtil;
import cn.wizzer.modules.back.sys.models.Sys_log;
import cn.wizzer.modules.back.sys.models.Sys_menu;
import cn.wizzer.modules.back.sys.models.Sys_user;
import cn.wizzer.modules.back.sys.services.MenuService;
import cn.wizzer.modules.back.sys.services.UserService;
Expand All @@ -34,10 +32,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by wizzer on 2016/6/22.
Expand All @@ -50,8 +44,6 @@ public class LoginController {
@Inject
UserService userService;
@Inject
MenuService menuService;
@Inject
SysLogService sysLogService;

@At("")
Expand Down Expand Up @@ -141,27 +133,7 @@ public Object doLogin(@Attr("loginToken") AuthenticationToken token, HttpServlet
ThreadContext.bind(subject);
subject.login(token);
Sys_user user = (Sys_user) subject.getPrincipal();
//获取用户菜单
user.setMenus(userService.getMenus(user.getId()));
user.setLoginIp(StringUtil.getRemoteAddr());
//计算左侧菜单
List<Sys_menu> firstMenus = new ArrayList<>();
Map<String, List<Sys_menu>> secondMenus = new HashMap<>();
for (Sys_menu menu : user.getMenus()) {
if (menu.getPath().length() > 4) {
List<Sys_menu> s = secondMenus.get(StringUtil.getParentId(menu.getPath()));
if (s == null) s = new ArrayList<>();
s.add(menu);
secondMenus.put(StringUtil.getParentId(menu.getPath()), s);
} else if (menu.getPath().length() == 4) {
firstMenus.add(menu);
}
}
user.setFirstMenus(firstMenus);
user.setSecondMenus(secondMenus);
if (!Strings.isBlank(user.getCustomMenu())) {
user.setCustomMenus(menuService.query(Cnd.where("id", "in", user.getCustomMenu().split(","))));
}

int count = user.getLoginCount() == null ? 0 : user.getLoginCount();
sysLogService.async(Sys_log.c("info", "用户登陆", "成功登录系统!", null));
userService.update(Chain.make("loginIp", user.getLoginIp()).add("loginAt", (int) (System.currentTimeMillis() / 1000))
Expand Down

0 comments on commit 101b786

Please sign in to comment.