Pu Zhibing
2 天以前 11d649e0de6490c53efe6df0ee10212ee6088d14
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/system/LoginController.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.google.code.kaptcha.Constants;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.constant.Const;
import com.stylefeng.guns.core.common.exception.InvalidKaptchaException;
import com.stylefeng.guns.core.log.LogManager;
@@ -45,6 +46,7 @@
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static com.stylefeng.guns.core.support.HttpKit.getIp;
@@ -78,13 +80,16 @@
    @Autowired
    private IRelationService relationService;
    @Autowired
    private ShiroExtUtil shiroExtUtil;
    /**
     * 跳转到主页
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String index(Model model, HttpServletRequest request) throws UnsupportedEncodingException {
        //session中解析用户数据
        HttpSession session = request.getSession();
@@ -111,6 +116,8 @@
        List<MenuNode> titles = MenuNode.buildTitle(menus);
        titles = ApiMenuFilter.build(titles);
        shiroUser.setMenuIds(menuList.stream().map(Menu::getUrl).collect(Collectors.toList()));
        shiroUser.setRoleType(user.getRoleType());
        shiroUser.setObjectId(user.getObjectId());
        model.addAttribute("titles", titles);
@@ -123,21 +130,22 @@
                null == user.getPassWordUpdate()
                        || user.getPassWordUpdate().getTime() + 7776000000L <= System.currentTimeMillis()
                        ? "您的密码已经90天未更换了,请及时更换密码!!!" : "");
        redisUtil.setStrValue(loginUser.getOnconUUID(), JSON.toJSONString(shiroUser), 36000);
        return "/index.html";
    }
    /**
     * 跳转到登录页面
     */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(Model model) {
        model.addAttribute("number",0);
        if (ShiroKit.isAuthenticated() || shiroExtUtil.getUser() != null) {
            return REDIRECT + "/";
        } else {
            return "/login.html";
        }
    }
//    /**
//     * 跳转到登录页面
//     */
//    @RequestMapping(value = "/login", method = RequestMethod.GET)
//    public String login(Model model) {
//        model.addAttribute("number",0);
//        if (shiroExtUtil.authenticated() || shiroExtUtil.getUser() != null) {
//            return REDIRECT + "/";
//        } else {
//            return "/login.html";
//        }
//    }
    /**
     * 点击登录执行的动作