org.apache.shiro.authz.annotation.RequiresPermissions Java Examples

The following examples show how to use org.apache.shiro.authz.annotation.RequiresPermissions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MenuController.java    From web-flash with MIT License 6 votes vote down vote up
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑菜单", key = "name")
@RequiresPermissions(value = {Permission.MENU_EDIT})
public Object save(@ModelAttribute @Valid Menu menu) {
    //判断是否存在该编号
    if(menu.getId()==null) {
        String existedMenuName = ConstantFactory.me().getMenuNameByCode(menu.getCode());
        if (StringUtil.isNotEmpty(existedMenuName)) {
            throw new ApplicationException(BizExceptionEnum.EXISTED_THE_MENU);
        }
        menu.setStatus(MenuStatus.ENABLE.getCode());
    }

    //设置父级菜单编号
    menuService.menuSetPcode(menu);
    if(menu.getId()==null){
        menuService.insert(menu);
    }else {
        menuService.update(menu);
    }
    return Rets.success();
}
 
Example #2
Source File: ExchangeCoinController.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@RequiresPermissions("exchange:exchange-coin:alter-rate")
@PostMapping("alter-rate")
@AccessLog(module = AdminModule.EXCHANGE, operation = "修改币币交易手续费exchangeCoin")
public MessageResult alterExchangeCoinRate(
        @RequestParam("symbol") String symbol,
        @RequestParam(value = "fee", required = false) BigDecimal fee,
        @RequestParam(value = "enable", required = false) Integer enable,
        @RequestParam(value = "sort", required = false) Integer sort,
        @RequestParam(value = "password") String password,
        @SessionAttribute(SysConstant.SESSION_ADMIN) Admin admin) {
    password = Encrypt.MD5(password + md5Key);
    Assert.isTrue(password.equals(admin.getPassword()), messageSource.getMessage("WRONG_PASSWORD"));
    ExchangeCoin exchangeCoin = exchangeCoinService.findOne(symbol);
    notNull(exchangeCoin, "validate symbol!");
    if (fee != null) {
        exchangeCoin.setFee(fee);//修改手续费
    }
    if (sort != null) {
        exchangeCoin.setSort(sort);//设置排序
    }
    if (enable != null && enable > 0 && enable < 3) {
        exchangeCoin.setEnable(enable);//设置启用 禁用
    }
    exchangeCoinService.save(exchangeCoin);
    return success(messageSource.getMessage("SUCCESS"));
}
 
Example #3
Source File: AdminCategoryController.java    From dts-shop with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequiresPermissions("admin:category:list")
@GetMapping("/l1")
public Object catL1() {
	logger.info("【请求开始】商场管理->类目管理->一级分类目录查询");

	// 所有一级分类目录
	List<DtsCategory> l1CatList = categoryService.queryL1();
	List<Map<String, Object>> data = new ArrayList<>(l1CatList.size());
	for (DtsCategory category : l1CatList) {
		Map<String, Object> d = new HashMap<>(2);
		d.put("value", category.getId());
		d.put("label", category.getName());
		data.add(d);
	}

	logger.info("【请求结束】商场管理->类目管理->一级分类目录查询:total:{}", JSONObject.toJSONString(data));
	return ResponseUtil.ok(data);
}
 
Example #4
Source File: RewardPromotionController.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
/**
 * 查询所有未被禁用的(判断type条件)
 * 默认按照updatetime降序
 *
 * @param enable
 * @param type
 * @return
 */
@RequiresPermissions("promotion:reward:page-query")
@GetMapping("page-query")
@AccessLog(module = AdminModule.SYSTEM, operation = "分页查询邀请奖励设置")
public MessageResult pageQuery(
        PageModel pageModel,
        @RequestParam(value = "status", defaultValue = "1") BooleanEnum enable,
        @RequestParam(value = "type", required = false) PromotionRewardType type) {
    BooleanExpression predicate = null;
    if (type != null) {
        predicate.andAnyOf(QRewardPromotionSetting.rewardPromotionSetting.type.eq(type));
    }
    Page<RewardPromotionSetting> all = rewardPromotionSettingService.findAll(predicate, pageModel);
    for(RewardPromotionSetting setting : all){
        if(StringUtils.isEmpty(setting.getInfo())) {
            continue ;
        }
        JSONObject jsonObject = JSONObject.parseObject(setting.getInfo());
        setting.setOne(jsonObject.getBigDecimal("one"));
        setting.setTwo(jsonObject.getBigDecimal("two"));
    }
    return success(all);
}
 
Example #5
Source File: UserOnlineController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询在线用户记录列表
 */
@RequiresPermissions("monitor:online:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String ipaddr,
				   @Param("loginName") String loginName,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(ipaddr)){
		cnd.and("ipaddr", "=", ipaddr);
	}
	if (!Strings.isBlank(loginName)){
		cnd.and("login_name", "=", loginName);
	}
	return userOnlineService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #6
Source File: AdvertiseController.java    From ZTuoExchange_framework with MIT License 6 votes vote down vote up
@RequiresPermissions("cms:system-advertise:create")
@PostMapping("/create")
@AccessLog(module = AdminModule.CMS, operation = "创建系统广告")
public MessageResult findOne(@Valid SysAdvertise sysAdvertise, BindingResult bindingResult) {
    Date end = DateUtil.strToDate(sysAdvertise.getEndTime());
    Date start = DateUtil.strToDate(sysAdvertise.getStartTime());
    Assert.isTrue(end.after(start), msService.getMessage("START_END_TIME"));
    MessageResult result = BindingResultUtil.validate(bindingResult);
    if (result != null) {
        return result;
    }
    sysAdvertise.setSerialNumber(UUIDUtil.getUUID());
    sysAdvertise.setCreateTime(DateUtil.getCurrentDate());

    updateSort(sysAdvertise.getSort(),sysAdvertise.getSysAdvertiseLocation().getOrdinal());
    return success(sysAdvertiseService.save(sysAdvertise));
}
 
Example #7
Source File: AdminGrouponController.java    From dts-shop with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequiresPermissions("admin:groupon:create")
@RequiresPermissionsDesc(menu = { "推广管理", "团购管理" }, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody DtsGrouponRules grouponRules) {
	logger.info("【请求开始】推广管理->团购管理->添加,请求参数:{}", JSONObject.toJSONString(grouponRules));

	Object error = validate(grouponRules);
	if (error != null) {
		return error;
	}

	Integer goodsId = grouponRules.getGoodsId();
	DtsGoods goods = goodsService.findById(goodsId);
	if (goods == null) {
		return ResponseUtil.badArgumentValue();
	}

	grouponRules.setGoodsName(goods.getName());
	grouponRules.setPicUrl(goods.getPicUrl());

	rulesService.createRules(grouponRules);

	logger.info("【请求结束】推广管理->团购管理->添加,响应结果:{}", JSONObject.toJSONString(grouponRules));
	return ResponseUtil.ok(grouponRules);
}
 
Example #8
Source File: LogininforController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询系统访问记录列表
 */
@RequiresPermissions("monitor:logininfor:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	return logininforService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #9
Source File: AdminTopicController.java    From dts-shop with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequiresPermissions("admin:topic:update")
@RequiresPermissionsDesc(menu = { "推广管理", "专题管理" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsTopic topic) {
	logger.info("【请求开始】推广管理->专题管理->编辑,请求参数:{}", JSONObject.toJSONString(topic));

	Object error = validate(topic);
	if (error != null) {
		return error;
	}
	if (topicService.updateById(topic) == 0) {
		logger.error("推广管理->专题管理->编辑 错误:{}", "更新数据失败!");
		return ResponseUtil.updatedDataFailed();
	}

	logger.info("【请求结束】推广管理->专题管理->编辑,响应结果:{}", JSONObject.toJSONString(topic));
	return ResponseUtil.ok(topic);
}
 
Example #10
Source File: LoginLogController.java    From DouBiNovel with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/delete")
@ResponseBody
@RequiresPermissions(value = {"LOGIN_LOG_DELETE", Const.role.ROLE_SUPER}, logical = Logical.OR)
public MvcResult delete(Long id) {
    MvcResult result = MvcResult.create();
    try {
        boolean success = loginLogService.delete(id);
        if (!success) {
            result.setSuccess(false);
            result.setMessage("删除失败:未知原因");
        }
    } catch (Exception e) {
        result.setSuccess(false);
        result.setMessage("删除失败:" + e.getMessage());
    }
    return result;
}
 
Example #11
Source File: AuthorityGroupController.java    From DouBiNovel with Apache License 2.0 6 votes vote down vote up
@RequestMapping("/doAdd")
@ResponseBody
@RequiresPermissions(value = {"AUTHORITY_GROUP_ADD", Const.role.ROLE_SUPER}, logical = Logical.OR)
public MvcResult doAdd(AuthorityGroup authorityGroup) {
    MvcResult result = MvcResult.create();
    try {
        boolean success = authorityGroupService.add(authorityGroup);
        if (!success) {
            result.setSuccess(false);
            result.setMessage("添加失败:未知原因");
        }
    } catch (Exception e) {
        result.setSuccess(false);
        result.setMessage("添加失败:" + e.getMessage());
    }
    return result;
}
 
Example #12
Source File: AdminGrouponController.java    From dts-shop with GNU Lesser General Public License v3.0 6 votes vote down vote up
@RequiresPermissions("admin:groupon:list")
@RequiresPermissionsDesc(menu = { "推广管理", "团购管理" }, button = "查询")
@GetMapping("/list")
public Object list(String goodsId, @RequestParam(defaultValue = "1") Integer page,
		@RequestParam(defaultValue = "10") Integer limit,
		@Sort @RequestParam(defaultValue = "add_time") String sort,
		@Order @RequestParam(defaultValue = "desc") String order) {
	logger.info("【请求开始】推广管理->团购管理->查询,请求参数:goodsId:{},page:{}", goodsId, page);

	List<DtsGrouponRules> rulesList = rulesService.querySelective(goodsId, page, limit, sort, order);
	long total = PageInfo.of(rulesList).getTotal();
	Map<String, Object> data = new HashMap<>();
	data.put("total", total);
	data.put("items", rulesList);

	logger.info("【请求结束】推广管理->团购管理->查询,响应结果:{}", JSONObject.toJSONString(data));
	return ResponseUtil.ok(data);
}
 
Example #13
Source File: StoreCouponController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 修改保存优惠券主
 */
@RequiresPermissions("shop:coupon:edit")
@Log(title = "优惠券主", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(StoreCoupon storeCoupon)
{
    return toAjax(storeCouponService.updateStoreCoupon(storeCoupon));
}
 
Example #14
Source File: GenController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 预览代码
 */
@RequiresPermissions("tool:gen:preview")
@GetMapping("/preview/{tableId}")
@ResponseBody
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
{
    Map<String, String> dataMap = genTableService.previewCode(tableId);
    return AjaxResult.success(dataMap);
}
 
Example #15
Source File: SysPermissionController.java    From spring-boot-plus with Apache License 2.0 5 votes vote down vote up
/**
 * 系统权限分页列表
 */
@PostMapping("/getPageList")
@RequiresPermissions("sys:permission:page")
@OperationLog(name = "系统权限分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "系统权限分页列表", response = SysPermissionQueryVo.class)
public ApiResult<Paging<SysPermissionQueryVo>> getSysPermissionPageList(@Validated @RequestBody SysPermissionPageParam sysPermissionPageParam) throws Exception {
    Paging<SysPermissionQueryVo> paging = sysPermissionService.getSysPermissionPageList(sysPermissionPageParam);
    return ApiResult.ok(paging);
}
 
Example #16
Source File: GenController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 导入表结构
 */
@RequiresPermissions("tool:gen:list")
@GetMapping("/importTable")
public String importTable()
{
    return prefix + "/importTable";
}
 
Example #17
Source File: StoreMemberController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 新增保存商城会员信息
 */
@RequiresPermissions("shop:member:add")
@Log(title = "商城会员信息", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(StoreMember storeMember)
{
    return toAjax(storeMemberService.insertStoreMember(storeMember));
}
 
Example #18
Source File: FrpRdpController.java    From frpMgr with MIT License 5 votes vote down vote up
/**
 * 查询列表
 */
@RequiresPermissions("frp:frp:view")
@RequestMapping(value = {"list", ""})
public String list(Frp frp, Model model) {
	model.addAttribute("frp", frp);
	return "modules/frp/frpRdpList";
}
 
Example #19
Source File: AdminAdController.java    From mall with MIT License 5 votes vote down vote up
@RequiresPermissions("admin:ad:update")
@RequiresPermissionsDesc(menu={"推广管理" , "广告管理"}, button="编辑")
@PostMapping("/update")
public Object update(@RequestBody LitemallAd ad) {
    Object error = validate(ad);
    if (error != null) {
        return error;
    }
    if (adService.updateById(ad) == 0) {
        return ResponseUtil.updatedDataFailed();
    }

    return ResponseUtil.ok(ad);
}
 
Example #20
Source File: AdminIssueController.java    From dts-shop with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequiresPermissions("admin:issue:read")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
	logger.info("【请求开始】商场管理->通用问题->详情,请求参数,id:{}", id);

	DtsIssue issue = issueService.findById(id);

	logger.info("【请求结束】商场管理->通用问题->详情,响应结果:{}", JSONObject.toJSONString(issue));
	return ResponseUtil.ok(issue);
}
 
Example #21
Source File: AdminCouponController.java    From mall with MIT License 5 votes vote down vote up
@RequiresPermissions("admin:coupon:delete")
@RequiresPermissionsDesc(menu={"推广管理" , "优惠券管理"}, button="删除")
@PostMapping("/delete")
public Object delete(@RequestBody LitemallCoupon coupon) {
    couponService.deleteById(coupon.getId());
    return ResponseUtil.ok();
}
 
Example #22
Source File: MemberController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@RequiresPermissions("member:delete")
@PostMapping("delete")
@AccessLog(module = AdminModule.MEMBER, operation = "删除会员Member")
public MessageResult delete(@RequestParam(value = "id") Long id) {
    Member member = memberService.findOne(id);
    notNull(member, "validate id!");
    member.setStatus(CommonStatus.ILLEGAL);// 修改状态非法
    memberService.save(member);
    return success();
}
 
Example #23
Source File: StoreSpecController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 删除商品规格(独立)
 */
@RequiresPermissions("shop:spec:remove")
@Log(title = "商品规格(独立)", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(storeSpecService.deleteStoreSpecByIds(ids));
}
 
Example #24
Source File: AuthorityController.java    From DouBiNovel with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.POST, value = "/doAdd")
@ResponseBody
@RequiresPermissions(value = {"AUTHORITY_ADD", Const.role.ROLE_SUPER}, logical = Logical.OR)
public MvcResult doAdd(Authority authority) {
    MvcResult result = MvcResult.create();
    try {
        if (StringUtils.isEmpty(authority.getCode())) {
            result.setSuccess(false);
            result.setMessage("添加失败:code不能为空");
        } else if (authorityService.getByCode(authority.getCode())) {
            result.setSuccess(false);
            result.setMessage("添加失败:code已存在");
        } else if (StringUtils.isEmpty(authority.getName())) {
            result.setSuccess(false);
            result.setMessage("添加失败:名称不能为空");
        } else if (authority.getGroupId() == null) {
            result.setSuccess(false);
            result.setMessage("添加失败:请选择所属权限组");
        } else {
            AuthorityGroup authorityGroup = authorityGroupService.getById(authority.getGroupId());
            if (authorityGroup == null) {
                result.setSuccess(false);
                result.setMessage("所属权限组不存在");
            } else {
                authority.setGroupName(authorityGroup.getName());
                boolean success = authorityService.add(authority);
                if (!success) {
                    result.setSuccess(false);
                    result.setMessage("添加失败:未知原因");
                }
            }
        }
    } catch (Exception e) {
        result.setSuccess(false);
        result.setMessage("添加失败:" + e.getMessage());
    }
    return result;
}
 
Example #25
Source File: CoinController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
@RequiresPermissions("system:coin:detail")
@PostMapping("detail")
@AccessLog(module = AdminModule.SYSTEM, operation = "后台货币Coin详情")
public MessageResult detail(@RequestParam("name") String name) {
    Coin coin = coinService.findOne(name);
    notNull(coin, "validate coin.name!");
    return success(coin);
}
 
Example #26
Source File: AuthorityController.java    From DouBiNovel with Apache License 2.0 5 votes vote down vote up
@RequestMapping("/listJSON")
@ResponseBody
@RequiresPermissions(value = {"AUTHORITY_VIEW", Const.role.ROLE_SUPER}, logical = Logical.OR)
public MvcResult listJSON(BaseQuery query) {
    MvcResult result = MvcResult.create();
    try {
        PageTemplate<Authority> pageTemplate = authorityService.getByQuery(query);
        result.setData(pageTemplate);
    } catch (Exception e) {
        result.setCode(-1);
        result.setSuccess(false);
        result.setMessage("获取出错," + e.getMessage());
    }
    return result;
}
 
Example #27
Source File: TaskController.java    From flash-waimai with MIT License 5 votes vote down vote up
@RequestMapping(value="/logList")
@RequiresPermissions(value = {Permission.TASK})
public Object logList(@RequestParam  Long taskId) {
    Page<TaskLog> page = new PageFactory<TaskLog>().defaultPage();
    page.addFilter(SearchFilter.build("idTask", SearchFilter.Operator.EQ,taskId));
    page = taskLogService.queryPage(page);
    return Rets.success(page);
}
 
Example #28
Source File: TaskController.java    From flash-waimai with MIT License 5 votes vote down vote up
@RequestMapping(value = "/enable",method = RequestMethod.POST)
@BussinessLog(value = "启用定时任务", key = "taskId",dict = TaskDict.class)
@RequiresPermissions(value = {Permission.TASK_EDIT})
public Object enable(@RequestParam Long taskId  ) {
    taskService.enable(taskId);
    return Rets.success();
}
 
Example #29
Source File: SysNoticeController.java    From supplierShop with MIT License 5 votes vote down vote up
/**
 * 删除公告
 */
@RequiresPermissions("system:notice:remove")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
    return toAjax(noticeService.deleteNoticeByIds(ids));
}
 
Example #30
Source File: DividendController.java    From ZTuoExchange_framework with MIT License 5 votes vote down vote up
/**
 * 查看手续费信息
 *
 * @return
 */
@RequestMapping(value = "/fee/info", method = RequestMethod.POST)
@RequiresPermissions("system:dividend:fee-query")
@AccessLog(module = AdminModule.SYSTEM, operation = "查看手续费信息")
public MessageResult statisticsFee(@RequestParam(value = "start") Date start,
                                   @RequestParam(value = "end") Date end) {
    if (end.before(start)) {
        return error("error,end Time before start Time");
    }
    MessageResult result = success();
    result.setData(orderDetailAggregationService.queryStatistics(start.getTime(), end.getTime()));
    return result;
}