报错:does not have permission [sys:question:page]

提问 未结 1 146
王少
王少 2022-08-07
悬赏:20积分
版本:renren-security 5.0 开发环境:
在进行接口测试的时候报错:org.apache.shiro.authz.UnauthorizedException: Subject does not have permission [sys:question:page] 下面是相关的代码,希望能告诉我哪里出现了问题,或者可能是哪个模块的代码有问题。 SysQuestionController.java [pre] package io.renren.modules.sys.controller; import io.renren.modules.sys.redis.annotation.LogOperation; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; import io.renren.common.utils.Result; import io.renren.common.validator.AssertUtils; import io.renren.common.validator.ValidatorUtils; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.sys.dto.SysQuestionDTO; import io.renren.modules.sys.service.SysQuestionService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import java.util.Arrays; import java.util.Map; @RestController @RequestMapping("/sys/question") @Api(tags = "问卷管理") public class SysQuestionController { @Autowired private SysQuestionService sysQuestionService; @GetMapping("page") @ApiOperation("分页") @ApiImplicitParams({ @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") , @ApiImplicitParam(name = "id", value = "编号", paramType = "query", dataType="Long"), @ApiImplicitParam(name = "problems", value = "题目", paramType = "query", dataType="String") }) @RequiresPermissions("sys:question:page") public Result<PageData<SysQuestionDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ PageData<SysQuestionDTO> page = sysQuestionService.page(params); return new Result<PageData<SysQuestionDTO>>().ok(page); } @GetMapping("{id}") @ApiOperation("信息") @RequiresPermissions("sys:question:info") public Result<SysQuestionDTO> get(@PathVariable("id") Long id){ SysQuestionDTO data = sysQuestionService.get(id); return new Result<SysQuestionDTO>().ok(data); } @PostMapping @ApiOperation("保存") @LogOperation("保存") @RequiresPermissions("sys:question:save") public Result save(@RequestBody SysQuestionDTO dto){ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); sysQuestionService.save(dto); return new Result(); } @PutMapping @ApiOperation("修改") @LogOperation("修改") @RequiresPermissions("sys:question:update") public Result update(@RequestBody SysQuestionDTO dto){ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); sysQuestionService.update(dto); return new Result(); } @DeleteMapping @ApiOperation("删除") @LogOperation("删除") @RequiresPermissions("sys:question:delete") public Result delete(@RequestBody Long[] ids){ AssertUtils.isArrayEmpty(ids, "id"); sysQuestionService.deleteBatchIds(Arrays.asList(ids)); return new Result(); } } [/pre] SysQuestionServiceImpl.java [pre] package io.renren.modules.sys.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import io.renren.common.constant.Constant; import io.renren.common.page.PageData; import io.renren.common.service.impl.BaseServiceImpl; import io.renren.common.utils.ConvertUtils; import io.renren.modules.sys.dao.SysQuestionDao; import io.renren.modules.sys.dto.SysQuestionDTO; import io.renren.modules.sys.entity.SysQuestionEntity; import io.renren.modules.sys.service.SysQuestionService; import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.List; import java.util.Map; @Service public class SysQuestionServiceImpl extends BaseServiceImpl<SysQuestionDao, SysQuestionEntity> implements SysQuestionService { @Override public PageData<SysQuestionDTO> page(Map<String, Object> params) { paramsToLike(params, "id"); //分页 IPage<SysQuestionEntity> page = getPage(params, Constant.CREATE_DATE, false); //查询 List<SysQuestionEntity> list = baseDao.getList(params); return getPageData(list, page.getTotal(), SysQuestionDTO.class); } @Override public List<SysQuestionDTO> list(Map<String, Object> params) { List<SysQuestionEntity> entityList = baseDao.getList(params); return ConvertUtils.sourceToTarget(entityList, SysQuestionDTO.class); } @Override public SysQuestionDTO get(Long id) { SysQuestionEntity entity = baseDao.getById(id); return ConvertUtils.sourceToTarget(entity, SysQuestionDTO.class); } @Override public void save(SysQuestionDTO dto) { SysQuestionEntity entity = ConvertUtils.sourceToTarget(dto, SysQuestionEntity.class); insert(entity); } @Override public void update(SysQuestionDTO dto) { SysQuestionEntity entity = ConvertUtils.sourceToTarget(dto, SysQuestionEntity.class); updateById(entity); } @Override public void delete(Long[] ids) { baseDao.deleteBatchIds(Arrays.asList(ids)); } } [/pre] SysQuestionDTO.java [pre] package io.renren.modules.sys.dto; import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.UpdateGroup; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; import javax.validation.constraints.Null; import java.io.Serializable; @Data @ApiModel(value = "问卷管理") public class SysQuestionDTO implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "id") @Null(message="{id.null}", groups = AddGroup.class) @NotNull(message="{id.require}", groups = UpdateGroup.class) private Long id; @ApiModelProperty(value = "problems") private String problems; } [/pre] SysQuestionDao.java [pre] package io.renren.modules.sys.dao; import io.renren.common.dao.BaseDao; import io.renren.modules.sys.entity.SysQuestionEntity; import org.mapstruct.Mapper; import java.util.List; import java.util.Map; @Mapper public interface SysQuestionDao extends BaseDao<SysQuestionEntity> { List<SysQuestionEntity> getList(Map<String, Object> params); SysQuestionEntity getById(Long id); } [/pre] SysQuestionEntity.java [pre] package io.renren.modules.sys.entity; import com.baomidou.mybatisplus.annotation.TableName; import io.renren.common.entity.BaseEntity; import lombok.Data; import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper=false) @TableName("sys_question") public class SysQuestionEntity extends BaseEntity { private static final long serialVersionUID = 1L; private Long id; private String problems; } [/pre] SysQuestionService.java [pre] package io.renren.modules.sys.service; import io.renren.common.page.PageData; import io.renren.common.service.BaseService; import io.renren.modules.sys.dto.SysQuestionDTO; import io.renren.modules.sys.entity.SysQuestionEntity; import java.util.List; import java.util.Map; public interface SysQuestionService extends BaseService<SysQuestionEntity> { PageData<SysQuestionDTO> page(Map<String, Object> params); List<SysQuestionDTO> list(Map<String, Object> params); SysQuestionDTO get(Long id); void save(SysQuestionDTO dto); void update(SysQuestionDTO dto); void delete(Long[] ids); } [/pre]
回帖
  • violetlength
    2022-08-08
    这个不是菜单里面,权限接口没有设置的问题吗? img[//cdn.renren.io/d5f52202208081033446295.jpg]
    0 回复