fix(通用设置): 各模块只有首页菜单权限问题处理

--bug=1027258 --user=王旭 【通用设置】设置权限处一个菜单只赋予一个查看权限,点击左侧tab栏闪退至个人信息页面 https://www.tapd.cn/55049933/s/1387167
This commit is contained in:
WangXu10 2023-06-27 18:35:35 +08:00 committed by 刘瑞斌
parent b0d229a633
commit e03250c2a0
5 changed files with 11 additions and 5 deletions

View File

@ -69,7 +69,7 @@ public class ApiDefinitionController {
} }
@PostMapping("/list/week/{projectId}/{versionId}/{goPage}/{pageSize}") @PostMapping("/list/week/{projectId}/{versionId}/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_API_DEFINITION_READ) @RequiresPermissions(value= {PermissionConstants.PROJECT_API_DEFINITION_READ, PermissionConstants.PROJECT_API_HOME}, logical = Logical.OR)
public Pager<List<ApiDefinitionResult>> weekList(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) { public Pager<List<ApiDefinitionResult>> weekList(@PathVariable String projectId, @PathVariable String versionId, @PathVariable int goPage, @PathVariable int pageSize) {
if (StringUtils.equalsIgnoreCase(versionId, "default")) { if (StringUtils.equalsIgnoreCase(versionId, "default")) {
versionId = null; versionId = null;

View File

@ -134,6 +134,7 @@ public class PermissionConstants {
public static final String PROJECT_TRACK_REPORT_READ_EDIT = "PROJECT_TRACK_REPORT:READ+EDIT"; public static final String PROJECT_TRACK_REPORT_READ_EDIT = "PROJECT_TRACK_REPORT:READ+EDIT";
public static final String PROJECT_TRACK_REPORT_READ_EXPORT = "PROJECT_TRACK_REPORT:READ+EXPORT"; public static final String PROJECT_TRACK_REPORT_READ_EXPORT = "PROJECT_TRACK_REPORT:READ+EXPORT";
public static final String PROJECT_API_HOME = "PROJECT_API_HOME:READ";
public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ"; public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ";
public static final String PROJECT_API_DEFINITION_READ_CREATE_API = "PROJECT_API_DEFINITION:READ+CREATE_API"; public static final String PROJECT_API_DEFINITION_READ_CREATE_API = "PROJECT_API_DEFINITION:READ+CREATE_API";
public static final String PROJECT_API_DEFINITION_READ_EDIT_API = "PROJECT_API_DEFINITION:READ+EDIT_API"; public static final String PROJECT_API_DEFINITION_READ_EDIT_API = "PROJECT_API_DEFINITION:READ+EDIT_API";
@ -190,6 +191,7 @@ public class PermissionConstants {
public static final String PROJECT_API_REPORT_READ_DELETE = "PROJECT_API_REPORT:READ+DELETE"; public static final String PROJECT_API_REPORT_READ_DELETE = "PROJECT_API_REPORT:READ+DELETE";
public static final String PROJECT_API_REPORT_READ_EXPORT = "PROJECT_API_REPORT:READ+EXPORT"; public static final String PROJECT_API_REPORT_READ_EXPORT = "PROJECT_API_REPORT:READ+EXPORT";
public static final String PROJECT_PERFORMANCE_HOME = "PROJECT_PERFORMANCE_HOME:READ";
public static final String PROJECT_PERFORMANCE_TEST_READ = "PROJECT_PERFORMANCE_TEST:READ"; public static final String PROJECT_PERFORMANCE_TEST_READ = "PROJECT_PERFORMANCE_TEST:READ";
public static final String PROJECT_PERFORMANCE_TEST_READ_CREATE = "PROJECT_PERFORMANCE_TEST:READ+CREATE"; public static final String PROJECT_PERFORMANCE_TEST_READ_CREATE = "PROJECT_PERFORMANCE_TEST:READ+CREATE";
public static final String PROJECT_PERFORMANCE_TEST_READ_EDIT = "PROJECT_PERFORMANCE_TEST:READ+EDIT"; public static final String PROJECT_PERFORMANCE_TEST_READ_EDIT = "PROJECT_PERFORMANCE_TEST:READ+EDIT";

View File

@ -23,6 +23,7 @@ import io.metersphere.service.BaseCheckPermissionService;
import io.metersphere.service.PerformanceTestService; import io.metersphere.service.PerformanceTestService;
import io.metersphere.task.dto.TaskRequestDTO; import io.metersphere.task.dto.TaskRequestDTO;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@ -49,7 +50,7 @@ public class PerformanceTestController {
private ApiPerformanceService apiPerformanceService; private ApiPerformanceService apiPerformanceService;
@PostMapping("recent/{count}") @PostMapping("recent/{count}")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ) @RequiresPermissions(value = {PermissionConstants.PROJECT_PERFORMANCE_TEST_READ, PermissionConstants.PROJECT_PERFORMANCE_HOME}, logical = Logical.OR)
public List<LoadTestDTO> recentTestPlans(@PathVariable int count, @RequestBody QueryTestPlanRequest request) { public List<LoadTestDTO> recentTestPlans(@PathVariable int count, @RequestBody QueryTestPlanRequest request) {
PageHelper.startPage(1, count, true); PageHelper.startPage(1, count, true);
return performanceTestService.recentTestPlans(request); return performanceTestService.recentTestPlans(request);
@ -264,7 +265,7 @@ public class PerformanceTestController {
} }
@PostMapping("/list/schedule") @PostMapping("/list/schedule")
@RequiresPermissions(PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_SCHEDULE) @RequiresPermissions(value = {PermissionConstants.PROJECT_PERFORMANCE_TEST_READ_SCHEDULE, PermissionConstants.PROJECT_PERFORMANCE_HOME}, logical = Logical.OR)
public List<ScheduleDao> listSchedule(@RequestBody QueryScheduleRequest request) { public List<ScheduleDao> listSchedule(@RequestBody QueryScheduleRequest request) {
return performanceTestService.listSchedule(request); return performanceTestService.listSchedule(request);
} }

View File

@ -6,6 +6,7 @@ import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.dto.CustomFieldDao; import io.metersphere.dto.CustomFieldDao;
import io.metersphere.dto.CustomFieldTemplateDao; import io.metersphere.dto.CustomFieldTemplateDao;
import io.metersphere.service.CustomFieldTemplateService; import io.metersphere.service.CustomFieldTemplateService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -20,7 +21,8 @@ public class CustomFieldTemplateController {
CustomFieldTemplateService customFieldTemplateService; CustomFieldTemplateService customFieldTemplateService;
@PostMapping("/list") @PostMapping("/list")
@RequiresPermissions(PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM) @RequiresPermissions(value = {PermissionConstants.PROJECT_TEMPLATE_READ_CUSTOM, PermissionConstants.PROJECT_TEMPLATE_READ_CASE_TEMPLATE,
PermissionConstants.PROJECT_TEMPLATE_READ_ISSUE_TEMPLATE, PermissionConstants.PROJECT_TEMPLATE_READ_API_TEMPLATE}, logical = Logical.OR)
public List<CustomFieldTemplateDao> list(@RequestBody CustomFieldTemplate request) { public List<CustomFieldTemplateDao> list(@RequestBody CustomFieldTemplate request) {
return customFieldTemplateService.list(request); return customFieldTemplateService.list(request);
} }

View File

@ -20,6 +20,7 @@ import io.metersphere.service.*;
import io.metersphere.dto.TestCaseReviewDTO; import io.metersphere.dto.TestCaseReviewDTO;
import io.metersphere.dto.TestReviewDTOWithMetric; import io.metersphere.dto.TestReviewDTOWithMetric;
import io.metersphere.service.wapper.CheckPermissionService; import io.metersphere.service.wapper.CheckPermissionService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -146,7 +147,7 @@ public class TestCaseReviewController {
} }
@PostMapping("/list/all/relate/{goPage}/{pageSize}") @PostMapping("/list/all/relate/{goPage}/{pageSize}")
@RequiresPermissions(PermissionConstants.PROJECT_TRACK_REVIEW_READ) @RequiresPermissions(value= {PermissionConstants.PROJECT_TRACK_REVIEW_READ, PermissionConstants.PROJECT_TRACK_HOME}, logical = Logical.OR)
public Pager<List<TestReviewDTOWithMetric>> listRelateAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ReviewRelateRequest request) { public Pager<List<TestReviewDTOWithMetric>> listRelateAll(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ReviewRelateRequest request) {
testCaseReviewService.setReviewIds(request); testCaseReviewService.setReviewIds(request);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);