Commit 6b8c26fc05b1a4b9604e97436058e4b44a541cfd

Authored by fangcheng
1 parent db28093d04
Exists in master

获取级联菜单

Showing 9 changed files with 374 additions and 164 deletions

center.manager/src/main/java/com/lyms/cm/controller/LoginController.java View file @ 6b8c26f
1   -//package com.lyms.cm.controller;
2   -//
3   -//import java.util.List;
4   -//
5   -//import org.apache.shiro.SecurityUtils;
6   -//import org.apache.shiro.authc.AccountException;
7   -//import org.apache.shiro.authc.AuthenticationException;
8   -//import org.apache.shiro.authc.AuthenticationToken;
9   -//import org.apache.shiro.authc.LockedAccountException;
10   -//import org.apache.shiro.authc.UnknownAccountException;
11   -//import org.apache.shiro.authc.UsernamePasswordToken;
12   -//import org.springframework.beans.factory.annotation.Autowired;
13   -//import org.springframework.stereotype.Controller;
14   -//import org.springframework.ui.Model;
15   -//import org.springframework.web.bind.annotation.RequestMapping;
16   -//import org.springframework.web.bind.annotation.RequestMethod;
17   -//import org.springframework.web.bind.annotation.RequestParam;
18   -//
19   -//import com.lyms.cm.entity.sys.TreeNode;
20   -//import com.lyms.cm.entity.sys.User;
21   -//import com.lyms.cm.service.sys.ResourceService;
22   -//import com.lyms.cm.service.sys.UserService;
23   -//import com.lyms.constants.Constants;
24   -//import com.lyms.constants.SysResourceType;
25   -//import com.lyms.shiro.ShiroWebUtils;
26   -//import com.lyms.util.StrUtils;
27   -//import com.lyms.web.controller.BaseController;
28   -//
29   -//@Controller
30   -//public class LoginController extends BaseController {
31   -//
32   -// private static final String VIEW_LOGIN = "/login/login";
33   -//
34   -//
35   -//
36   -// @Autowired
37   -// private UserService userService;
38   -//
39   -// @Autowired
40   -// private ResourceService resourceService;
41   -//
42   -// @RequestMapping("/")
43   -// public String index(Model model) {
44   -// if(!ShiroWebUtils.isLogin()){
45   -// return redirectTo(VIEW_LOGIN);
46   -// }
47   -// String username = ShiroWebUtils.getCurrentUserName();
48   -// User user = userService.getUserByUserName(username);
49   -// List<TreeNode> menus = resourceService.getPermissionMenuTreeByPid(SysResourceType.MANAGER_ROOT_MENU_RESOURCE_ID,user);
50   -// model.addAttribute("menus", menus);
51   -// return "/index";
52   -// }
53   -//
54   -// @RequestMapping("/home")
55   -// public String home() {
56   -// return "/home";
57   -// }
58   -// /**
59   -// * <li>@Description:导航到登录(GET)
60   -// * <li>@param model
61   -// * <li>@return
62   -// * <li>创建人:方承
63   -// * <li>创建时间:2016年11月27日
64   -// * <li>修改人:
65   -// * <li>修改时间:
66   -// */
67   -// @RequestMapping(value = "/login", method = RequestMethod.GET)
68   -// public String login(Model model){
69   -// model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
70   -// return VIEW_LOGIN;
71   -// }
72   -//
73   -// /**
74   -// * <li>@Description:登录验证方法,详细查看ShiroRealm.class
75   -// * <li>@param req
76   -// * <li>@param model
77   -// * <li>@return
78   -// * <li>创建人:方承
79   -// * <li>创建时间:2016年11月25日
80   -// * <li>修改人:
81   -// * <li>修改时间:
82   -// */
83   -// @RequestMapping(value = "/login", method = RequestMethod.POST)
84   -// public String login(String username, String password,@RequestParam(value = "rememberMe",defaultValue = "0") int rememberMe, Model model) {
85   -// String view = VIEW_LOGIN;
86   -// if(StrUtils.isEmpty(username) || StrUtils.isEmpty(password)){
87   -// model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
88   -// return view;
89   -// }
90   -// AuthenticationToken token = new UsernamePasswordToken(username, password);
91   -// if (rememberMe == 1) {
92   -// ((UsernamePasswordToken) token).setRememberMe(true);
93   -// }
94   -// try {
95   -// //查看ShiroRealm.class
96   -// SecurityUtils.getSubject().login(token);
97   -// return redirectTo("/");
98   -// } catch (AuthenticationException e) {
99   -// if (e instanceof UnknownAccountException) {
100   -// model.addAttribute("message", "用户不存在");
101   -// } else if (e instanceof AccountException) {
102   -// model.addAttribute("message", "用户名密码错误");
103   -// } else if (e instanceof LockedAccountException) {
104   -// model.addAttribute("message", "用户被禁用");
105   -// } else {
106   -// model.addAttribute("message", "用户认证失败");
107   -// }
108   -// }
109   -// model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
110   -// return view;
111   -// }
112   -//
113   -//}
  1 +package com.lyms.cm.controller;
  2 +
  3 +import java.util.List;
  4 +
  5 +import org.apache.shiro.SecurityUtils;
  6 +import org.apache.shiro.authc.AccountException;
  7 +import org.apache.shiro.authc.AuthenticationException;
  8 +import org.apache.shiro.authc.AuthenticationToken;
  9 +import org.apache.shiro.authc.LockedAccountException;
  10 +import org.apache.shiro.authc.UnknownAccountException;
  11 +import org.apache.shiro.authc.UsernamePasswordToken;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Controller;
  14 +import org.springframework.ui.Model;
  15 +import org.springframework.web.bind.annotation.RequestMapping;
  16 +import org.springframework.web.bind.annotation.RequestMethod;
  17 +import org.springframework.web.bind.annotation.RequestParam;
  18 +
  19 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  20 +import com.lyms.cm.entity.sys.SysUsers;
  21 +import com.lyms.cm.entity.sys.TreeNode;
  22 +import com.lyms.cm.service.sys.SysPermissionsService;
  23 +import com.lyms.cm.service.sys.SysUsersService;
  24 +import com.lyms.constants.Constants;
  25 +import com.lyms.constants.SysResourceType;
  26 +import com.lyms.shiro.ShiroWebUtils;
  27 +import com.lyms.util.StrUtils;
  28 +import com.lyms.web.controller.BaseController;
  29 +
  30 +@Controller
  31 +public class LoginController extends BaseController {
  32 +
  33 + private static final String VIEW_LOGIN = "/login/login";
  34 +
  35 +
  36 +
  37 + @Autowired
  38 + private SysUsersService sysUsersService;
  39 +
  40 + @Autowired
  41 + private SysPermissionsService sysPermissionsService;
  42 +
  43 +
  44 + @RequestMapping("/")
  45 + public String index(Model model) {
  46 + if(!ShiroWebUtils.isLogin()){
  47 + return redirectTo(VIEW_LOGIN);
  48 + }
  49 + SysUsers user = ShiroWebUtils.getCurrentUser();
  50 + List<TreeNode> menus = sysPermissionsService.getPermissionMenuTreeByPuri(SysResourceType.MANAGER_ROOT_MENU_RESOURCE_ID,user);
  51 + model.addAttribute("menus", menus);
  52 + return "/index";
  53 + }
  54 +
  55 + @RequestMapping("/home")
  56 + public String home() {
  57 + return "/home";
  58 + }
  59 + /**
  60 + * <li>@Description:导航到登录(GET)
  61 + * <li>@param model
  62 + * <li>@return
  63 + * <li>创建人:方承
  64 + * <li>创建时间:2016年11月27日
  65 + * <li>修改人:
  66 + * <li>修改时间:
  67 + */
  68 + @RequestMapping(value = "/login", method = RequestMethod.GET)
  69 + public String login(Model model){
  70 + model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
  71 + return VIEW_LOGIN;
  72 + }
  73 +
  74 + /**
  75 + * <li>@Description:登录验证方法,详细查看ShiroRealm.class
  76 + * <li>@param req
  77 + * <li>@param model
  78 + * <li>@return
  79 + * <li>创建人:方承
  80 + * <li>创建时间:2016年11月25日
  81 + * <li>修改人:
  82 + * <li>修改时间:
  83 + */
  84 + @RequestMapping(value = "/login", method = RequestMethod.POST)
  85 + public String login(String username, String password,@RequestParam(value = "rememberMe",defaultValue = "0") int rememberMe, Model model) {
  86 + String view = VIEW_LOGIN;
  87 + if(StrUtils.isEmpty(username) || StrUtils.isEmpty(password)){
  88 + model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
  89 + return view;
  90 + }
  91 + AuthenticationToken token = new UsernamePasswordToken(username, password);
  92 + if (rememberMe == 1) {
  93 + ((UsernamePasswordToken) token).setRememberMe(true);
  94 + }
  95 + try {
  96 + //查看ShiroRealm.class
  97 + SecurityUtils.getSubject().login(token);
  98 + return redirectTo("/");
  99 + } catch (AuthenticationException e) {
  100 + if (e instanceof UnknownAccountException) {
  101 + model.addAttribute("message", "用户不存在");
  102 + } else if (e instanceof AccountException) {
  103 + model.addAttribute("message", "用户名密码错误");
  104 + } else if (e instanceof LockedAccountException) {
  105 + model.addAttribute("message", "用户被禁用");
  106 + } else {
  107 + model.addAttribute("message", "用户认证失败");
  108 + }
  109 + }
  110 + model.addAttribute(Constants.CAPTCHA_TOKEN, StrUtils.uuid());
  111 + return view;
  112 + }
  113 +
  114 +}
center.manager/src/main/java/com/lyms/cm/dao/sys/SysPermissionsMapper.java View file @ 6b8c26f
1 1 package com.lyms.cm.dao.sys;
2 2  
3   -import com.lyms.cm.entity.sys.SysPermissions;
4   -import com.baomidou.mybatisplus.mapper.BaseMapper;
5   -import org.springframework.stereotype.Repository;
6 3 import java.io.Serializable;
  4 +import java.util.List;
  5 +
  6 +import org.springframework.stereotype.Repository;
  7 +
  8 +import com.baomidou.mybatisplus.mapper.BaseMapper;
  9 +import com.lyms.cm.entity.sys.SysPermissions;
  10 +import com.lyms.cm.entity.sys.TreeNode;
7 11 /**
8 12 * <p>
9 13 * Mapper接口
... ... @@ -16,6 +20,10 @@
16 20 public interface SysPermissionsMapper extends BaseMapper<SysPermissions> {
17 21  
18 22 public Integer deleteLogicById(Serializable id);
  23 +
  24 + List<TreeNode> getMenuTreeByPuri(String puri);
  25 +
  26 + List<SysPermissions> getUserPermission(String uid);
19 27  
20 28 }
center.manager/src/main/java/com/lyms/cm/dao/sys/SysPermissionsMapper.xml View file @ 6b8c26f
... ... @@ -21,5 +21,17 @@
21 21 <sql id="Base_Column_List">
22 22 ID AS id, NAME AS name, URI AS uri, TYPE AS type, PURI AS puri, ICON AS icon, IFDEL AS ifdel, ENABLE AS enable, EXTRA_DATA AS extraData, WEIGHT AS weight, FOREIGN_ID AS foreignId
23 23 </sql>
  24 +
  25 + <select id="getMenuTreeByPuri" resultType="TreeNode">
  26 + SELECT uri as id ,puri as pid, uri as url,name as text FROM SYS_PERMISSIONS where type=1 and puri = #{puri}
  27 + </select>
  28 +
  29 + <select id="getUserPermission" resultType="SysPermissions">
  30 + select <include refid="Base_Column_List"></include> from SYS_PERMISSIONS where ID in (
  31 + select PERMISSION_ID from SYS_ROLE_PERMISSION_MAPS rp where ROLE_ID in (
  32 + select role_id from SYS_USER_ROLE_MAPS where user_id= #{uid}
  33 + )
  34 + ) and type = 1
  35 + </select>
24 36 </mapper>
center.manager/src/main/java/com/lyms/cm/enums/PermissionEnum.java View file @ 6b8c26f
  1 +package com.lyms.cm.enums;
  2 +
  3 +public enum PermissionEnum {
  4 +
  5 + /**
  6 + * 中心根节点
  7 + */
  8 + CENTER_MANAGER_ROOT("center"),
  9 + /**
  10 + * 院内根节点
  11 + */
  12 + HOSPITAL_ROOT("hospital");
  13 +
  14 + private String code;
  15 +
  16 + private PermissionEnum(String code) {
  17 + this.code = code;
  18 + }
  19 +
  20 + public String getCode() {
  21 + return code;
  22 + }
  23 +}
center.manager/src/main/java/com/lyms/cm/service/sys/SysPermissionsService.java View file @ 6b8c26f
1 1 package com.lyms.cm.service.sys;
2 2  
3 3 import com.lyms.cm.entity.sys.SysPermissions;
  4 +import com.lyms.cm.entity.sys.SysUsers;
  5 +import com.lyms.cm.entity.sys.TreeNode;
4 6 import com.lyms.web.service.BaseService;
5 7 import java.io.Serializable;
  8 +import java.util.List;
6 9  
7 10 /**
8 11 * <p>
9 12  
... ... @@ -20,6 +23,9 @@
20 23 * <li>@return 大于0修改成功,否则为失败
21 24 */
22 25 public Integer deleteLogicById(Serializable id);
  26 +
  27 + public List<TreeNode> getPermissionMenuTreeByPuri(String puri, SysUsers user);
23 28  
  29 +
24 30 }
center.manager/src/main/java/com/lyms/cm/service/sys/SysUsersService.java View file @ 6b8c26f
... ... @@ -74,6 +74,6 @@
74 74 * <li>修改时间:
75 75 */
76 76 public boolean isAllowUpdate(String account,String userid);
77   -
  77 +
78 78 }
center.manager/src/main/java/com/lyms/cm/service/sys/impl/SysPermissionsServiceImpl.java View file @ 6b8c26f
1 1 package com.lyms.cm.service.sys.impl;
2 2  
3 3 import com.lyms.cm.entity.sys.SysPermissions;
  4 +import com.lyms.cm.entity.sys.SysUsers;
  5 +import com.lyms.cm.entity.sys.TreeNode;
4 6 import com.lyms.cm.dao.sys.SysPermissionsMapper;
5 7 import com.lyms.cm.service.sys.SysPermissionsService;
  8 +import com.lyms.util.InstanceUtils;
  9 +import com.lyms.util.StrUtils;
6 10 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
7 11 import org.springframework.stereotype.Service;
8 12 import java.io.Serializable;
  13 +import java.util.Iterator;
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +import java.util.Set;
9 17  
10 18 /**
11 19 * <p>
... ... @@ -21,5 +29,137 @@
21 29 public Integer deleteLogicById(Serializable id){
22 30 return baseMapper.deleteLogicById(id);
23 31 }
  32 +
  33 +
  34 + public List<TreeNode> getMenuTreeByPid(String puri) {
  35 + List<TreeNode> allMenu = baseMapper.getMenuTreeByPuri(puri);
  36 + //迭代获取子节点
  37 + for (TreeNode menuNode : allMenu) {
  38 + List<TreeNode> subMenu = baseMapper.getMenuTreeByPuri(menuNode.getId()+"");
  39 + if(subMenu != null && subMenu.size() > 0){
  40 + menuNode.setChildren(subMenu);
  41 + getSubMenuTreeByNodeList(subMenu);
  42 + }
  43 + }
  44 + return allMenu;
  45 + }
  46 +
  47 + /**
  48 + * @param treeNodeList 迭代处理子节点
  49 + */
  50 + private void getSubMenuTreeByNodeList(List<TreeNode> treeNodeList) {
  51 + if(treeNodeList != null && treeNodeList.size() > 0){
  52 + //迭代获取子节点
  53 + for (TreeNode menuNode : treeNodeList) {
  54 + List<TreeNode> subMenu = baseMapper.getMenuTreeByPuri(menuNode.getId()+"");
  55 + if(subMenu != null && subMenu.size() > 0){
  56 + menuNode.setChildren(subMenu);
  57 + getSubMenuTreeByNodeList(subMenu);
  58 + }
  59 + }
  60 + }
  61 + }
  62 +
  63 + //权限菜单
  64 + @Override
  65 + public List<TreeNode> getPermissionMenuTreeByPuri(String puri, SysUsers user) {
  66 + //用户权限列表
  67 + Map<String,String> permissionsMap = getUserPermissionMap(getUserPermissionSet(user.getId()));
  68 + //所有菜单
  69 + List<TreeNode> allMenu = baseMapper.getMenuTreeByPuri(puri);
  70 + //初始化要返回的有权限的菜单
  71 + List<TreeNode> allPermissionMenu = InstanceUtils.newArrayList();
  72 + //迭代获取子节点
  73 + for (TreeNode menuNode : allMenu) {
  74 + if(permissionsMap.get(menuNode.getId()) != null){
  75 + allPermissionMenu.add(menuNode);
  76 + List<TreeNode> subMenus = baseMapper.getMenuTreeByPuri(menuNode.getId()+"");
  77 + if(subMenus != null && subMenus.size() > 0){
  78 + List<TreeNode> permissionSubMenu = InstanceUtils.newArrayList();
  79 + for(TreeNode submenu : subMenus){
  80 + if(permissionsMap.get(submenu.getId()) != null){
  81 + permissionSubMenu.add(submenu);
  82 + }
  83 + }
  84 + menuNode.setChildren(permissionSubMenu);
  85 + getPermissionSubMenuTreeByNodeList(permissionSubMenu,permissionsMap);
  86 + }
  87 + }
  88 + }
  89 + return allPermissionMenu;
  90 +
  91 + }
  92 + /**
  93 + * @param treeNodeList 迭代处理获取有权限的子节点
  94 + */
  95 + private void getPermissionSubMenuTreeByNodeList(List<TreeNode> treeNodeList,Map<String,String> permissionMap) {
  96 + if(treeNodeList != null && treeNodeList.size() > 0){
  97 + //迭代获取子节点
  98 + for (TreeNode menuNode : treeNodeList) {
  99 + List<TreeNode> subMenus = baseMapper.getMenuTreeByPuri(menuNode.getId()+"");
  100 + if(subMenus != null && subMenus.size() > 0){
  101 + List<TreeNode> permissionSubMenu = InstanceUtils.newArrayList();
  102 + for(TreeNode subMenu : subMenus){
  103 + if(permissionMap.get(subMenu.getId()) != null){
  104 + permissionSubMenu.add(subMenu);
  105 + }
  106 + }
  107 + menuNode.setChildren(permissionSubMenu);
  108 + getPermissionSubMenuTreeByNodeList(permissionSubMenu,permissionMap);
  109 + }
  110 + }
  111 + }
  112 + }
  113 +
  114 + /**
  115 + * <li>@Description:根据用户id获取用户所有权限列表
  116 + * <li>@param uid
  117 + * <li>@return
  118 + * <li>创建人:方承
  119 + * <li>创建时间:2017年3月9日
  120 + * <li>修改人:
  121 + * <li>修改时间:
  122 + */
  123 + public List<SysPermissions> getUserPermission(String uid){
  124 + return baseMapper.getUserPermission(uid);
  125 + }
  126 +
  127 + /**
  128 + * <li>@Description:权限列表Set,方便Shiro使用
  129 + * <li>@param uid
  130 + * <li>@return
  131 + * <li>创建人:方承
  132 + * <li>创建时间:2017年3月9日
  133 + * <li>修改人:
  134 + * <li>修改时间:
  135 + */
  136 + public Set<String> getUserPermissionSet(String uid){
  137 + Set<String> pSet = InstanceUtils.newHashSet();
  138 + List<SysPermissions> pList = getUserPermission(uid);
  139 + for(SysPermissions p : pList){
  140 + if(StrUtils.isNotEmpty(p.getUri()))
  141 + pSet.add(p.getUri());
  142 + }
  143 + return pSet;
  144 + }
  145 +
  146 + /**
  147 + * <li>@Description:根据Set获取Map,key存uri
  148 + * <li>@param pset
  149 + * <li>@return
  150 + * <li>创建人:方承
  151 + * <li>创建时间:2017年3月9日
  152 + * <li>修改人:
  153 + * <li>修改时间:
  154 + */
  155 + private Map<String,String> getUserPermissionMap(Set<String> pset){
  156 + Map<String,String> pMap = InstanceUtils.newHashMap();
  157 + Iterator<String> it=pset.iterator();
  158 + while(it.hasNext()){
  159 + pMap.put(it.next(), "");
  160 + }
  161 + return pMap;
  162 + }
  163 +
24 164 }
center.manager/src/main/java/com/lyms/cm/shiro/ShiroRealm.java View file @ 6b8c26f
... ... @@ -18,6 +18,11 @@
18 18 import org.slf4j.Logger;
19 19 import org.slf4j.LoggerFactory;
20 20 import org.springframework.beans.factory.annotation.Autowired;
  21 +
  22 +import com.baomidou.mybatisplus.mapper.EntityWrapper;
  23 +import com.lyms.cm.entity.sys.SysUsers;
  24 +import com.lyms.cm.enums.StatusEnum;
  25 +import com.lyms.cm.service.sys.SysUsersService;
21 26 import com.lyms.shiro.HashUtils;
22 27 import com.lyms.shiro.ShiroWebUtils;
23 28 import com.lyms.util.StrUtils;
24 29  
... ... @@ -43,55 +48,69 @@
43 48 return null;
44 49 }
45 50  
46   -// @SuppressWarnings("unused")
47   -// private static Logger logger = LoggerFactory.getLogger(ShiroRealm.class);
48   -//
49   -//
50   -// public ShiroRealm() {
51   -// super(new AllowAllCredentialsMatcher());
52   -// setAuthenticationTokenClass(UsernamePasswordToken.class);
53   -// //FIXME: 暂时禁用Cache
54   -// setCachingEnabled(false);
  51 + @SuppressWarnings("unused")
  52 + private static Logger logger = LoggerFactory.getLogger(ShiroRealm.class);
  53 +
  54 + public ShiroRealm() {
  55 + super(new AllowAllCredentialsMatcher());
  56 + setAuthenticationTokenClass(UsernamePasswordToken.class);
  57 + //FIXME: 暂时禁用Cache
  58 + setCachingEnabled(false);
  59 + }
  60 +
  61 + @Autowired
  62 + private SysUsersService sysUsersService;
  63 +
  64 + // @Autowired
  65 + // private ResourceService resourceService;
  66 +
  67 +// @Override
  68 +// protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
  69 +// // String username = (String) principals.getPrimaryPrincipal();
  70 +// // User user = userService.getUserByUserName(username);
  71 +// // // 授权
  72 +// // SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
  73 +// // if(StrUtils.isNotEmpty(user.getRoles())){
  74 +// // authorizationInfo.setRoles(new HashSet<String>(Arrays.asList(user.getRoles().split(","))));
  75 +// // }
  76 +// // authorizationInfo.setStringPermissions(resourceService.getResourcePermissionSet(userService.getUserResourceIdSet(user)));
  77 +// // return authorizationInfo;
55 78 // }
56 79 //
57   -// @Autowired
58   -// private UserService userService;
59   -//
60   -// @Autowired
61   -// private ResourceService resourceService;
62   -//
63   -// @Override
64   -// protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
65   -// String username = (String) principals.getPrimaryPrincipal();
66   -// User user = userService.getUserByUserName(username);
67   -// // 授权
68   -// SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
69   -// if(StrUtils.isNotEmpty(user.getRoles())){
70   -// authorizationInfo.setRoles(new HashSet<String>(Arrays.asList(user.getRoles().split(","))));
71   -// }
72   -// authorizationInfo.setStringPermissions(resourceService.getResourcePermissionSet(userService.getUserResourceIdSet(user)));
73   -// return authorizationInfo;
74   -// }
75   -//
76   -// @Override
77   -// protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
78   -// UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
79   -// String username = token.getUsername();
80   -// User user = userService.getUserByUserName(username);
81   -// if (user == null) {
82   -// throw new UnknownAccountException("未知用户");
83   -// }
84   -// StringBuilder pwd = new StringBuilder(100);
85   -// for (int i = 0; i < token.getPassword().length; i++) {
86   -// pwd.append(token.getPassword()[i]);
87   -// }
88   -// if (!StrUtils.equals(user.getPassword(), HashUtils.md5(pwd.toString()))) {
89   -// throw new AccountException("用户名密码不一致");
90   -// }
91   -// ShiroWebUtils.saveCurrentUser(user);
92   -// AuthenticationInfo authcInfo = new SimpleAuthenticationInfo(username, pwd.toString(), username);
93   -// return authcInfo;
94   -// }
  80 +// @Override
  81 +// protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException {
  82 +// UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
  83 +// String username = token.getUsername();
  84 +// SysUsers user = sysUsersService
  85 +// .selectOne(new EntityWrapper<SysUsers>().where("name={0}", username).and("ifDel=0"));
  86 +// if (StatusEnum.isDisEnabled(user.getEnable())) {
  87 +// throw new AccountException("用户已经被禁用,请联系管理员!");
  88 +// }
  89 +// StringBuilder pwd = new StringBuilder(100);
  90 +// for (int i = 0; i < token.getPassword().length; i++) {
  91 +// pwd.append(token.getPassword()[i]);
  92 +// }
  93 +// if (!StrUtils.equals(user.getPwd(), HashUtils.md5(pwd.toString()))) {
  94 +// throw new AccountException("用户名密码不一致");
  95 +// }
  96 +// ShiroWebUtils.saveCurrentUser(user);
  97 +// AuthenticationInfo authcInfo = new SimpleAuthenticationInfo(username, pwd.toString(), username);
  98 +// return authcInfo;
  99 +// // User user = userService.getUserByUserName(username);
  100 +// // if (user == null) {
  101 +// // throw new UnknownAccountException("未知用户");
  102 +// // }
  103 +// // StringBuilder pwd = new StringBuilder(100);
  104 +// // for (int i = 0; i < token.getPassword().length; i++) {
  105 +// // pwd.append(token.getPassword()[i]);
  106 +// // }
  107 +// // if (!StrUtils.equals(user.getPassword(), HashUtils.md5(pwd.toString()))) {
  108 +// // throw new AccountException("用户名密码不一致");
  109 +// // }
  110 +// // ShiroWebUtils.saveCurrentUser(user);
  111 +// // AuthenticationInfo authcInfo = new SimpleAuthenticationInfo(username, pwd.toString(), username);
  112 +// // return authcInfo;
  113 +// }
95 114  
96 115 }
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/generator/.gitignore View file @ 6b8c26f
  1 +/MysqlGenerator.java