当前位置: 首页>>代码示例>>Java>>正文


Java RequiresPermissions类代码示例

本文整理汇总了Java中org.apache.shiro.authz.annotation.RequiresPermissions的典型用法代码示例。如果您正苦于以下问题:Java RequiresPermissions类的具体用法?Java RequiresPermissions怎么用?Java RequiresPermissions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RequiresPermissions类属于org.apache.shiro.authz.annotation包,在下文中一共展示了RequiresPermissions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: code

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 生成代码
 */
@RequestMapping("/code")
@RequiresPermissions("sys:generator:code")
public void code(HttpServletRequest request, HttpServletResponse response) throws IOException{
	String[] tableNames = new String[]{};
	//获取表名,不进行xss过滤
	HttpServletRequest orgRequest = XssHttpServletRequestWrapper.getOrgRequest(request);
	String tables = orgRequest.getParameter("tables");
	tableNames = JSON.parseArray(tables).toArray(tableNames);
	
	byte[] data = sysGeneratorService.generatorCode(tableNames);
	
	response.reset();  
       response.setHeader("Content-Disposition", "attachment; filename=\"renren.zip\"");  
       response.addHeader("Content-Length", "" + data.length);  
       response.setContentType("application/octet-stream; charset=UTF-8");  
 
       IOUtils.write(data, response.getOutputStream());  
}
 
开发者ID:guolf,项目名称:pds,代码行数:22,代码来源:SysGeneratorController.java

示例2: delete

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 删除用户
 */
@SysLog("删除用户")
@RequestMapping("/delete")
@RequiresPermissions("sys:user:delete")
public Result delete(@RequestBody Long[] userIds) {
    if (ArrayUtils.contains(userIds, 1L)) {
        return Result.error("系统管理员不能删除");
    }

    if (ArrayUtils.contains(userIds, getUserId())) {
        return Result.error("当前用户不能删除");
    }

    try {
        sysUserService.deleteBatch(userIds);
    } catch (Exception e) {
        logger.error("删除用户异常", e);
        return Result.error("删除用户异常");
    }

    return Result.ok();
}
 
开发者ID:davichi11,项目名称:my-spring-boot-project,代码行数:25,代码来源:SysUserController.java

示例3: editPermission

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 编辑资源
 * @param id 资源的id,Permission.id 
 */
@RequiresPermissions("adminRolePermission")
@RequestMapping("editPermission")
public String editPermission(@RequestParam(value = "id", required = true) int id,Model model, HttpServletRequest request){
	if(id>0){
		Permission permission = sqlService.findById(Permission.class, id);
		if(permission!=null){
			String parentPermissionDescription="顶级";
			if(permission.getParentId()>0){
				Permission parentPermission = sqlService.findById(Permission.class, permission.getParentId());
				parentPermissionDescription = parentPermission.getName() +","+ parentPermission.getDescription();
			}
			
			ActionLogCache.insert(request, permission.getId(), "进入修改资源Permission页面", "所属上级:"+parentPermissionDescription);
			
			model.addAttribute("permission", permission);
			model.addAttribute("parentPermissionDescription", parentPermissionDescription);
			return "iw/admin/role/permission";
		}
	}
	return error(model, "出错,参数错误");
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:26,代码来源:RoleAdminController_.java

示例4: saveExportModel

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 保存导出的模型
 * @param modelName 模型名称
 * @param cnames 中文字段集合
 * @param enames 英文字段集合
 * @return
 */
@ResponseBody
@RequiresPermissions("system:export:add")
@MumuLog(name = "添加导出模型",operater = "POST")
@RequestMapping(value="/add",method=RequestMethod.POST)
public ResponseEntity saveExportModel(String modelName, String cnames, String enames){
	SysExportModel exportModel=new SysExportModel();
	exportModel.setCnames(cnames);
	exportModel.setEnames(enames);
	exportModel.setModelName(modelName);
	try {
		exportModelService.addExportModel(exportModel);
		return new ResponseEntity(200,"导出模型保存成功",null);
	} catch (Exception e) {
		log.error(e);
		return new ResponseEntity(500, "保存模型出现异常", null);
	}
}
 
开发者ID:babymm,项目名称:mumu,代码行数:25,代码来源:SystemExportModelController.java

示例5: update

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
@ApiOperation(value = "修改系统")
@RequiresPermissions("upms:system:update")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable("id") int id, UpmsSystem upmsSystem) {
	ComplexResult result = FluentValidator.checkAll()
			.on(upmsSystem.getTitle(), new LengthValidator(1, 20, "标题"))
			.on(upmsSystem.getName(), new LengthValidator(1, 20, "名称"))
			.doValidate()
			.result(ResultCollectors.toComplex());
	if (!result.isSuccess()) {
		return new UpmsResult(UpmsResultConstant.INVALID_LENGTH, result.getErrors());
	}
	upmsSystem.setSystemId(id);
	int count = upmsSystemService.updateByPrimaryKeySelective(upmsSystem);
	return new UpmsResult(UpmsResultConstant.SUCCESS, count);
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:18,代码来源:UpmsSystemController.java

示例6: updateTask

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
@PostMapping
@ApiOperation(value = "新增任务")
@RequiresPermissions("sys.task.scheduled.update")
public Object updateTask(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	Assert.notNull(scheduled.getJobType(), "JOBTYPE");
	Assert.notNull(scheduled.getTaskType(), "TASKTYPE");
	Assert.notNull(scheduled.getTargetObject(), "TARGETOBJECT");
	Assert.notNull(scheduled.getTargetMethod(), "TARGETMETHOD");
	Assert.notNull(scheduled.getTaskCron(), "TASKCRON");
	Assert.notNull(scheduled.getTaskDesc(), "TASKDESC");
	if (TaskType.dubbo.equals(scheduled.getTaskType())) {
		Assert.notNull(scheduled.getTargetSystem(), "TARGETSYSTEM");
	}
	Parameter parameter = new Parameter(getService(), "updateTask").setModel(scheduled);
	provider.execute(parameter);
	return setSuccessModelMap(modelMap);
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:20,代码来源:ScheduledController.java

示例7: delete

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 删除
 */
@SysLog("删除菜单")
@RequestMapping("/delete")
@RequiresPermissions("sys:menu:delete")
public R delete(long menuId){
	if(menuId <= 30){
		return R.error("系统菜单,不能删除");
	}

	//判断是否有子菜单或按钮
	List<SysMenuEntity> menuList = sysMenuService.queryListParentId(menuId);
	if(menuList.size() > 0){
		return R.error("请先删除子菜单或按钮");
	}

	sysMenuService.deleteBatch(new Long[]{menuId});
	
	return R.ok();
}
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:22,代码来源:SysMenuController.java

示例8: groupEdit

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 编辑用户组
 * @param groupId 用户组id
 * @return
 */
@RequiresPermissions("system:group:edit")
@RequestMapping(value="/edit/{groupId}",method=RequestMethod.GET)
public String groupEdit(@PathVariable String groupId,HttpServletRequest request){
	SysGroup group=groupService.getSysGroupById(groupId);
	request.setAttribute("group", group);
	
	List<SysOrganize> organizes = organizeService.querySysOrganizeByCondition(null);
	List<NodeUtil.NodeBean> nodeBeans = new ArrayList<NodeUtil.NodeBean>();
	for (SysOrganize org : organizes) {
		nodeBeans.add(new NodeUtil.NodeBean(String.valueOf(org.getOrgId()), String.valueOf(org.getParentOrgId()), org));
	}
	List<T> organizesList = NodeUtil.iterator(nodeBeans, "﹎﹎", "orgName");
	request.setAttribute("organizes", organizesList);
	return "system/group/edit";
}
 
开发者ID:babymm,项目名称:mumu,代码行数:21,代码来源:SystemGroupController.java

示例9: userRole

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
@ApiOperation(value = "修改用户角色")
@PostMapping(value = "/user/update/role")
@RequiresPermissions("sys.permisson.userRole.update")
public Object userRole(ModelMap modelMap, @RequestBody List<SysUserRole> list) {
    Long userId = null;
    Long currentUserId = getCurrUser();
    for (SysUserRole sysUserRole : list) {
        if (sysUserRole.getUserId() != null) {
            if (userId != null && sysUserRole.getUserId() != null
                && userId.longValue() != sysUserRole.getUserId()) {
                throw new IllegalParameterException("参数错误.");
            }
            userId = sysUserRole.getUserId();
        }
        sysUserRole.setCreateBy(currentUserId);
        sysUserRole.setUpdateBy(currentUserId);
        sysUserRole.setCreateTime(new Date());
        sysUserRole.setUpdateTime(new Date());
    }
    Parameter parameter = new Parameter(getService(), "updateUserRole").setList(list);
    logger.info("{} execute updateUserRole start...", parameter.getNo());
    provider.execute(parameter);
    logger.info("{} execute updateUserRole end.", parameter.getNo());
    return setSuccessModelMap(modelMap);
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:26,代码来源:SysAuthorizeController.java

示例10: list

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
@ApiOperation(value = "类目列表")
@RequiresPermissions("cms:category:read")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(
		@RequestParam(required = false, defaultValue = "0", value = "offset") int offset,
		@RequestParam(required = false, defaultValue = "10", value = "limit") int limit,
		@RequestParam(required = false, value = "sort") String sort,
		@RequestParam(required = false, value = "order") String order) {
	CmsCategoryExample cmsCategoryExample = new CmsCategoryExample();
	if (!StringUtils.isBlank(sort) && !StringUtils.isBlank(order)) {
		cmsCategoryExample.setOrderByClause(sort + " " + order);
	}
	List<CmsCategory> rows = cmsCategoryService.selectByExampleForOffsetPage(cmsCategoryExample, offset, limit);
	long total = cmsCategoryService.countByExample(cmsCategoryExample);
	Map<String, Object> result = new HashMap<>();
	result.put("rows", rows);
	result.put("total", total);
	return result;
}
 
开发者ID:youngMen1,项目名称:-Spring-SpringMVC-Mybatis-,代码行数:21,代码来源:CmsCategoryController.java

示例11: updateExportModel

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 保存编辑的模型
 * @param modelId 模型id
 * @param cnames 中文字段集合
 * @param enames 英文字段集合
 * @param request
 * @return
 */
@ResponseBody
@RequiresPermissions("system:export:edit")
@MumuLog(name = "编辑导出模型",operater = "POST")
@RequestMapping(value="/edit",method=RequestMethod.PUT)
public ResponseEntity updateExportModel(int modelId,String cnames,String enames,HttpServletRequest request){
	SysExportModel exportModel=new SysExportModel();
	exportModel.setCnames(cnames);
	exportModel.setEnames(enames);
	exportModel.setModelId(modelId);
	try {
		exportModelService.updateSysExportModel(exportModel);
		return new ResponseEntity(200, "导出模型编辑成功", null);
	} catch (Exception e) {
		log.error(e);
		return new ResponseEntity(500, "更新模型出现异常", null);
	}
}
 
开发者ID:babymm,项目名称:mumu,代码行数:26,代码来源:SystemExportModelController.java

示例12: update

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
@PostMapping
@ApiOperation(value = "修改用户信息")
@RequiresPermissions("sys.base.user.update")
public Object update(ModelMap modelMap, @RequestBody SysUser param) {
	Assert.isNotBlank(param.getAccount(), "ACCOUNT");
	Assert.length(param.getAccount(), 3, 15, "ACCOUNT");
	if (param.getId() != null) {
		if (param.getEnable() == null) {
			param.setEnable(1);
		}
		Parameter parameter = new Parameter(getService(), "queryById").setId(param.getId());
		SysUser user = (SysUser) provider.execute(parameter).getModel();
		Assert.notNull(user, "USER", param.getId());
		if (StringUtils.isNotBlank(param.getPassword())) {
			if (!param.getPassword().equals(user.getPassword())) {
				param.setPassword(SecurityUtil.encryptPassword(param.getPassword()));
			}
		}
	} else if (StringUtils.isNotBlank(param.getPassword())) {
		param.setPassword(SecurityUtil.encryptPassword(param.getPassword()));
	}
	return super.update(modelMap, param);
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:24,代码来源:SysUserController.java

示例13: siteUpdatePassword

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 代理商给其下的某个站点更改密码
 * @param userid 要更改密码的user.id
 * @param newPassword 要更改上的新密码
 */
@RequiresPermissions("agencySiteUpdatePassword")
@RequestMapping("siteUpdatePassword")
@ResponseBody
public BaseVO siteUpdatePassword(HttpServletRequest request,
		@RequestParam(value = "userid", required = true) int userid,
		@RequestParam(value = "newPassword", required = true) String newPassword){
	User user = sqlService.findById(User.class, userid);
	if(user == null){
		return error("用户不存在");
	}
	//判断是否是其直属下级
	if(user.getReferrerid() - getMyAgency().getUserid() != 0){
		return error("要更改密码的网站不是您的直属下级,操作失败");
	}
	
	return userService.updatePassword(userid, newPassword);
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:23,代码来源:AgencyUserController.java

示例14: groupView

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 查看用户组详情
 * @param groupId 用户组id
 * @return
 */
@RequiresPermissions("system:group:view")
@RequestMapping(value="/view/{groupId}",method=RequestMethod.GET)
public String groupView(@PathVariable String groupId,HttpServletRequest request){
	SysGroup group=groupService.getSysGroupById(groupId);
	request.setAttribute("group", group);

	List<SysOrganize> organizes = organizeService.querySysOrganizeByCondition(null);
	List<NodeUtil.NodeBean> nodeBeans = new ArrayList<NodeUtil.NodeBean>();
	for (SysOrganize org : organizes) {
		nodeBeans.add(new NodeUtil.NodeBean(String.valueOf(org.getOrgId()), String.valueOf(org.getParentOrgId()), org));
	}
	List<T> organizesList = NodeUtil.iterator(nodeBeans, "﹎﹎", "orgName");
	request.setAttribute("organizes", organizesList);
	return "system/group/view";
}
 
开发者ID:babymm,项目名称:mumu,代码行数:21,代码来源:SystemGroupController.java

示例15: subAgencyList

import org.apache.shiro.authz.annotation.RequiresPermissions; //导入依赖的package包/类
/**
 * 我的的下级代理商列表
 */
@RequiresPermissions("agencySubAgencyList")
@RequestMapping("subAgencyList")
public String subAgencyList(HttpServletRequest request, Model model){
	Agency agency = getMyAgency();
	
	Sql sql = new Sql(request);
	sql.setSearchTable("agency");
	sql.appendWhere("agency.parent_id = "+agency.getId());
	sql.setSearchColumn(new String[]{"name","phone"});
	int count = sqlService.count("agency", sql.getWhere());
	Page page = new Page(count, G.PAGE_WAP_NUM, request);
	sql.setSelectFromAndPage("SELECT agency.*, user.username FROM agency,user", page);
	sql.appendWhere("user.id = agency.userid");
	sql.setOrderByField(new String[]{"id","expiretime","addtime"});
	List<Map<String, Object>> list = sqlService.findMapBySql(sql);
	AliyunLog.addActionLog(0, "查看我的下级代理列表");
	
	model.addAttribute("list", list);
	model.addAttribute("page", page);
	return "agency/subAgencyList";
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:25,代码来源:AgencyUserController.java


注:本文中的org.apache.shiro.authz.annotation.RequiresPermissions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。