refactor(功能用例): 接口权限调整

This commit is contained in:
guoyuqi 2024-06-17 13:49:50 +08:00 committed by Craftsman
parent a9b35ccdcb
commit e93a648780
2 changed files with 7 additions and 10 deletions

View File

@ -14,10 +14,12 @@ import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
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.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -42,7 +44,7 @@ public class FunctionalCaseMinderController {
@PostMapping("/list") @PostMapping("/list")
@Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表") @Operation(summary = "用例管理-功能用例-脑图用例跟根据模块ID查询列表")
@RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_MINDER) @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ)
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project") @CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public List<FunctionalMinderTreeDTO> getFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCaseMindRequest request) { public List<FunctionalMinderTreeDTO> getFunctionalCaseMinderTree(@Validated @RequestBody FunctionalCaseMindRequest request) {
return functionalCaseMinderService.getMindFunctionalCase(request, false); return functionalCaseMinderService.getMindFunctionalCase(request, false);
@ -50,11 +52,7 @@ public class FunctionalCaseMinderController {
@PostMapping("/edit") @PostMapping("/edit")
@Operation(summary = "脑图保存") @Operation(summary = "脑图保存")
@RequiresPermissions(value = { @RequiresPermissions(PermissionConstants.FUNCTIONAL_CASE_READ_MINDER)
PermissionConstants.FUNCTIONAL_CASE_READ_UPDATE,
PermissionConstants.FUNCTIONAL_CASE_READ_DELETE,
PermissionConstants.FUNCTIONAL_CASE_READ_ADD,
}, logical = Logical.OR)
public void editFunctionalCaseBatch(@Validated @RequestBody FunctionalCaseMinderEditRequest request) { public void editFunctionalCaseBatch(@Validated @RequestBody FunctionalCaseMinderEditRequest request) {
String userId = SessionUtils.getUserId(); String userId = SessionUtils.getUserId();
functionalCaseMinderService.editFunctionalCaseBatch(request, userId); functionalCaseMinderService.editFunctionalCaseBatch(request, userId);

View File

@ -163,8 +163,7 @@ public class FunctionalCaseMinderService {
private List<String> getFieldIds(FunctionalCaseMindRequest request) { private List<String> getFieldIds(FunctionalCaseMindRequest request) {
TemplateDTO defaultTemplateDTO = projectTemplateService.getDefaultTemplateDTO(request.getProjectId(), TemplateScene.FUNCTIONAL.toString()); TemplateDTO defaultTemplateDTO = projectTemplateService.getDefaultTemplateDTO(request.getProjectId(), TemplateScene.FUNCTIONAL.toString());
List<TemplateCustomFieldDTO> customFields = defaultTemplateDTO.getCustomFields(); List<TemplateCustomFieldDTO> customFields = defaultTemplateDTO.getCustomFields();
List<String> fieldIds = customFields.stream().map(TemplateCustomFieldDTO::getFieldId).toList(); return customFields.stream().map(TemplateCustomFieldDTO::getFieldId).toList();
return fieldIds;
} }
private List<FunctionalMinderTreeDTO> buildAdditionalData(String moduleId) { private List<FunctionalMinderTreeDTO> buildAdditionalData(String moduleId) {