fix(接口测试): 修复创建场景提示无操作权限的缺陷
--bug=1040463 --user=王孝刚 【接口测试】项目管理员&系统管理员用户登录后创建场景提示无权限 https://www.tapd.cn/55049933/s/1513387
This commit is contained in:
parent
6e0f17897e
commit
a14e604d12
|
@ -14,6 +14,7 @@ import io.metersphere.commons.constants.*;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
import io.metersphere.commons.utils.Pager;
|
import io.metersphere.commons.utils.Pager;
|
||||||
|
import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.commons.utils.WebSocketUtil;
|
import io.metersphere.commons.utils.WebSocketUtil;
|
||||||
import io.metersphere.dto.BaseCase;
|
import io.metersphere.dto.BaseCase;
|
||||||
import io.metersphere.dto.MsExecResponseDTO;
|
import io.metersphere.dto.MsExecResponseDTO;
|
||||||
|
@ -435,8 +436,8 @@ public class ApiScenarioController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("versions/{scenarioId}")
|
@GetMapping("versions/{scenarioId}")
|
||||||
@CheckOwner(resourceId = "#scenarioId", resourceType = "api_scenario")
|
|
||||||
public List<ApiScenarioDTO> getApiScenarioVersions(@PathVariable String scenarioId) {
|
public List<ApiScenarioDTO> getApiScenarioVersions(@PathVariable String scenarioId) {
|
||||||
|
apiAutomationService.checkOwner(scenarioId, SessionUtils.getCurrentProjectId());
|
||||||
return apiAutomationService.getApiScenarioVersions(scenarioId);
|
return apiAutomationService.getApiScenarioVersions(scenarioId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,8 @@ public class ApiScenarioService {
|
||||||
private ApiTestCaseService apiTestCaseService;
|
private ApiTestCaseService apiTestCaseService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseProjectService baseProjectService;
|
private BaseProjectService baseProjectService;
|
||||||
|
@Resource
|
||||||
|
private ExtCheckOwnerMapper extCheckOwnerMapper;
|
||||||
|
|
||||||
private ThreadLocal<Long> currentScenarioOrder = new ThreadLocal<>();
|
private ThreadLocal<Long> currentScenarioOrder = new ThreadLocal<>();
|
||||||
|
|
||||||
|
@ -2194,6 +2196,17 @@ public class ApiScenarioService {
|
||||||
return this.list(request);
|
return this.list(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkOwner(String scenarioId, String projectId) {
|
||||||
|
ApiScenarioWithBLOBs scenario = apiScenarioMapper.selectByPrimaryKey(scenarioId);
|
||||||
|
if (scenario == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!extCheckOwnerMapper.checkoutOwner("api_scenario", projectId, List.of(scenarioId))) {
|
||||||
|
MSException.throwException(Translator.get("check_owner_case"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public ApiScenarioDTO getApiScenarioByVersion(String refId, String versionId) {
|
public ApiScenarioDTO getApiScenarioByVersion(String refId, String versionId) {
|
||||||
ApiScenarioRequest request = new ApiScenarioRequest();
|
ApiScenarioRequest request = new ApiScenarioRequest();
|
||||||
request.setRefId(refId);
|
request.setRefId(refId);
|
||||||
|
|
Loading…
Reference in New Issue