首页>代码>ssm开发生产管理ERP系统>/src/main/java/com/megagao/production/ssm/controller/AuthorityJudgeController.java
package com.megagao.production.ssm.controller; import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import com.megagao.production.ssm.domain.customize.ActiveUser; import com.megagao.production.ssm.util.CollectionsFactory; import org.apache.shiro.SecurityUtils; import org.apache.shiro.subject.Subject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import static com.megagao.production.ssm.common.Constants.NO_PERMISSION; /** * * 权限判断controller * */ @RestController public class AuthorityJudgeController { private static final Logger logger = LoggerFactory.getLogger(AuthorityJudgeController.class); @RequestMapping("*/*_judge") public Map<String,Object> authorityJudge(HttpServletRequest request) throws Exception{ Subject subject = SecurityUtils.getSubject(); ActiveUser activeUser = (ActiveUser) subject.getPrincipal(); //根据uri,使用shiro判断相应权限 String uri = request.getRequestURI(); String[] names = uri.split("/"); String featureName = names[2]; String operateName = names[3].split("_")[0]; Map<String,Object> map = CollectionsFactory.newHashMap(); if(!activeUser.getUserStatus().equals("1")){ if (logger.isDebugEnabled()) { logger.debug(NO_PERMISSION, "账户已被锁定!"); } map.put("msg", "您的账户已被锁定,请切换账户登录!"); }else if(!activeUser.getRoleStatus().equals("1")){ if (logger.isDebugEnabled()) { logger.debug(NO_PERMISSION, "角色已被锁定!"); } map.put("msg", "当前角色已被锁定,请切换账户登录!"); }else{ if (logger.isDebugEnabled()) { logger.debug(NO_PERMISSION, "没有权限!"); } if(!subject.isPermitted(featureName+":"+operateName)){ map.put("msg", "您没有权限,请切换用户登录!"); } } return map; } }

chutianyu LV4
7月22日
13188866605 LV12
4月18日
爱情的本质 LV16
2024年8月8日
泓鼎168 LV20
2024年6月18日
educationAAA LV11
2024年4月30日
weilaizhisheng LV21
2024年3月27日
pureshyness LV6
2024年2月14日
403401 LV2
2023年12月17日
guanrenan LV10
2023年11月28日
daguocai001 LV3
2023年11月4日

dazi001
8月10日
暂无贡献等级
chutianyu LV4
7月22日
萌萌哒的泰迪熊 LV4
6月16日
xmjying LV13
6月11日
哪里的完整版 LV8
3月1日
xianyu091012 LV5
2024年12月26日
蛋蛋蛋蛋的糕糕
2024年12月17日
暂无贡献等级
别让自己无聊 LV13
2024年12月10日
微信网友_7269098639953920 LV2
2024年11月25日
shunlun8855 LV1
2024年10月29日