From 6cfc5bfab7ff5a1d2b23c3848418163d22f010da Mon Sep 17 00:00:00 2001 From: tamguo Date: Sat, 21 Jul 2018 23:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/shiro/ShiroConfiguration.java | 4 ++ .../tamguo/modules/sys/utils/ShiroUtils.java | 2 +- .../modules/sys/web/IndexController.java | 2 +- .../modules/sys/web/LoginController.java | 10 +++-- .../modules/sys/web/ValidCodeController.java | 2 +- .../main/resources/mappers/SysMenuMapper.xml | 37 ++++++++++++++++ .../main/resources/mappers/SysRoleMapper.xml | 17 +++++++ .../main/resources/mappers/SysUserMapper.xml | 44 +++++++++++++++++++ .../src/main/resources/static/global.min.js | 2 +- .../resources/static/modules/sys/sysLogin.js | 8 ++-- .../main/resources/templates/sysLogin.html | 5 ++- 11 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml create mode 100644 tamguo-oms/src/main/resources/mappers/SysRoleMapper.xml create mode 100644 tamguo-oms/src/main/resources/mappers/SysUserMapper.xml diff --git a/tamguo-oms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java b/tamguo-oms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java index e9bb779..f443826 100644 --- a/tamguo-oms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java +++ b/tamguo-oms/src/main/java/com/tamguo/config/shiro/ShiroConfiguration.java @@ -80,10 +80,14 @@ public class ShiroConfiguration { filterChainDefinitionMap.put("/my97/**", "anon"); filterChainDefinitionMap.put("/select2/**", "anon"); filterChainDefinitionMap.put("/sysLogin/**", "anon"); + filterChainDefinitionMap.put("/images/**", "anon"); filterChainDefinitionMap.put("/validCode", "anon"); filterChainDefinitionMap.put("/checkCode", "anon"); filterChainDefinitionMap.put("/wdScrollTab/**", "anon"); filterChainDefinitionMap.put("/jquery-timeago/**", "anon"); + filterChainDefinitionMap.put("/favicon.ico", "anon"); + filterChainDefinitionMap.put("/global.min.js", "anon"); + filterChainDefinitionMap.put("/**", "authc"); shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/utils/ShiroUtils.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/utils/ShiroUtils.java index 3b14e88..5bc4f17 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/utils/ShiroUtils.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/utils/ShiroUtils.java @@ -42,7 +42,7 @@ public class ShiroUtils { public static String getKaptcha(String key) { String kaptcha = getSessionAttribute(key).toString(); - getSession().removeAttribute(key); +// getSession().removeAttribute(key); return kaptcha; } diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/IndexController.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/IndexController.java index 18d8b97..88094a4 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/IndexController.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/IndexController.java @@ -9,7 +9,7 @@ public class IndexController { @RequestMapping(path="sysIndex") public String sysLogin(ModelAndView model) { - return "sysIndex.html"; + return "sysIndex"; } } diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/LoginController.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/LoginController.java index 622d718..77a6221 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/LoginController.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/LoginController.java @@ -26,19 +26,21 @@ public class LoginController { @RequestMapping(path="sysLogin") public String sysLogin(ModelAndView model) { - return "sysLogin.html"; + if(ShiroUtils.isLogin()) { + return "sysIndex"; + } + return "sysLogin"; } @ResponseBody @RequestMapping(value = "sysLogin", method = RequestMethod.POST) - public Result toLogin(HttpServletRequest request, String username, String password, String captcha) + public Result toLogin(HttpServletRequest request, String username, String password, String validCode) throws IOException { try { String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); - if (!captcha.equalsIgnoreCase(kaptcha)) { + if (!validCode.equalsIgnoreCase(kaptcha)) { return Result.failResult("验证码错误"); } - Subject subject = ShiroUtils.getSubject(); // sha256加密 password = new Sha256Hash(password).toHex(); diff --git a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/ValidCodeController.java b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/ValidCodeController.java index ba42c31..b73a681 100644 --- a/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/ValidCodeController.java +++ b/tamguo-oms/src/main/java/com/tamguo/modules/sys/web/ValidCodeController.java @@ -43,7 +43,7 @@ public class ValidCodeController { public Boolean checkCode(String validCode) throws ServletException, IOException { try { String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); - if (!validCode.equalsIgnoreCase(kaptcha)) { + if (validCode.equalsIgnoreCase(kaptcha)) { return true; } } catch (Exception e) { diff --git a/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml b/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml new file mode 100644 index 0000000..d75c0d3 --- /dev/null +++ b/tamguo-oms/src/main/resources/mappers/SysMenuMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + uid, parent_id, name, url, type, perms , order_num + + + + + + + + + + + \ No newline at end of file diff --git a/tamguo-oms/src/main/resources/mappers/SysRoleMapper.xml b/tamguo-oms/src/main/resources/mappers/SysRoleMapper.xml new file mode 100644 index 0000000..b01e6d2 --- /dev/null +++ b/tamguo-oms/src/main/resources/mappers/SysRoleMapper.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/tamguo-oms/src/main/resources/mappers/SysUserMapper.xml b/tamguo-oms/src/main/resources/mappers/SysUserMapper.xml new file mode 100644 index 0000000..42b00ba --- /dev/null +++ b/tamguo-oms/src/main/resources/mappers/SysUserMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + \ No newline at end of file diff --git a/tamguo-oms/src/main/resources/static/global.min.js b/tamguo-oms/src/main/resources/static/global.min.js index 10e4c04..d6ad42c 100644 --- a/tamguo-oms/src/main/resources/static/global.min.js +++ b/tamguo-oms/src/main/resources/static/global.min.js @@ -1 +1 @@ -lang='zh_CN',ctx='/js',ctxPath='/js',ctxAdmin='/js/a',ctxFront='/js/f',ctxStatic='/js/static',Global={SHOW:'1',HIDE:'0',OP_AUTH:'auth',OP_ADD:'add',FALSE:'false',USERFILES_BASE_URL:'/userfiles/',YES:'1',TRUE:'true',NO:'0',OP_EDIT:'edit',STATUS_DELETE:'1',STATUS_NORMAL:'0',STATUS_DRAFT:'9',STATUS_AUDIT_BACK:'5',STATUS_DISABLE:'2',STATUS_FREEZE:'3',STATUS_AUDIT:'4'} \ No newline at end of file +lang='zh_CN',ctx='http://localhost/',ctxPath='/',ctxAdmin='/',ctxFront='/f',ctxStatic='static',Global={SHOW:'1',HIDE:'0',OP_AUTH:'auth',OP_ADD:'add',FALSE:'false',USERFILES_BASE_URL:'/userfiles/',YES:'1',TRUE:'true',NO:'0',OP_EDIT:'edit',STATUS_DELETE:'1',STATUS_NORMAL:'0',STATUS_DRAFT:'9',STATUS_AUDIT_BACK:'5',STATUS_DISABLE:'2',STATUS_FREEZE:'3',STATUS_AUDIT:'4'} \ No newline at end of file diff --git a/tamguo-oms/src/main/resources/static/modules/sys/sysLogin.js b/tamguo-oms/src/main/resources/static/modules/sys/sysLogin.js index c90f402..8b934ab 100644 --- a/tamguo-oms/src/main/resources/static/modules/sys/sysLogin.js +++ b/tamguo-oms/src/main/resources/static/modules/sys/sysLogin.js @@ -13,11 +13,11 @@ $("#loginForm").validate({ , a = $("#password").val() , b = $("#validCode").val(); js.ajaxSubmitForm($(c), function(f, e, g) { - if (f.result != 0) { - js.showMessage(f.message) - } else { + if (f.result.code != 0) { js.loading($("#btnSubmit").data("loading")); - location = ctx + "/index" + location = ctx + "sysIndex" + } else { + js.showMessage(f.message) } }, "json", true, $("#btnSubmit").data("loginValid")); $("#username").val(d); diff --git a/tamguo-oms/src/main/resources/templates/sysLogin.html b/tamguo-oms/src/main/resources/templates/sysLogin.html index af045b2..9d14530 100644 --- a/tamguo-oms/src/main/resources/templates/sysLogin.html +++ b/tamguo-oms/src/main/resources/templates/sysLogin.html @@ -11,6 +11,7 @@ 登录 - Tamguo OMS + @@ -48,7 +49,7 @@ class="form-control required" data-msg-required="请填写登录密码." placeholder="登录密码" autocomplete="off" /> - +