fix(接口测试): 任务ID重复

--bug=1048118 --user=陈建星 【组织任务中心】即时任务列表-点击ID进入任务详情-展示了同id的其它子任务 https://www.tapd.cn/55049933/s/1598879
This commit is contained in:
AgAngle 2024-10-28 10:13:29 +08:00 committed by Craftsman
parent 339464a588
commit 7f6005592d
2 changed files with 5 additions and 1 deletions

View File

@ -483,7 +483,7 @@ public class ApiCommonService {
public ExecTask newExecTask(String projectId, String userId) { public ExecTask newExecTask(String projectId, String userId) {
ExecTask execTask = new ExecTask(); ExecTask execTask = new ExecTask();
execTask.setNum(NumGenerator.nextNum(projectId, ApplicationNumScope.TASK)); execTask.setNum(NumGenerator.nextNum(ApplicationNumScope.TASK));
execTask.setProjectId(projectId); execTask.setProjectId(projectId);
execTask.setId(IDGenerator.nextStr()); execTask.setId(IDGenerator.nextStr());
execTask.setCreateTime(System.currentTimeMillis()); execTask.setCreateTime(System.currentTimeMillis());

View File

@ -27,6 +27,10 @@ public class NumGenerator {
private static final List<ApplicationNumScope> SUB_NUM = List.of(ApplicationNumScope.API_TEST_CASE, ApplicationNumScope.API_MOCK, ApplicationNumScope.TEST_PLAN_FUNCTION_CASE, ApplicationNumScope.TEST_PLAN_API_CASE, ApplicationNumScope.TEST_PLAN_API_SCENARIO); private static final List<ApplicationNumScope> SUB_NUM = List.of(ApplicationNumScope.API_TEST_CASE, ApplicationNumScope.API_MOCK, ApplicationNumScope.TEST_PLAN_FUNCTION_CASE, ApplicationNumScope.TEST_PLAN_API_CASE, ApplicationNumScope.TEST_PLAN_API_SCENARIO);
public static long nextNum(ApplicationNumScope scope) {
return nextNum(scope.name(), scope);
}
/** /**
* @param prefix 前缀: PROJECT_ID, 或者 PROJECT_ID + "_" + DOMAIN 例如接口用例的前缀为: 100001_12345 * @param prefix 前缀: PROJECT_ID, 或者 PROJECT_ID + "_" + DOMAIN 例如接口用例的前缀为: 100001_12345
* @param scope 用例类型 * @param scope 用例类型