Skip to content

Commit

Permalink
feat: upload endpoint for plan execution biz logs (#353)
Browse files Browse the repository at this point in the history
* feat: upload endpoint for plan execution biz logs
  • Loading branch information
QizhengMo authored Sep 18, 2024
1 parent 9773bb2 commit 2a501ae
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import lombok.extern.jackson.Jacksonized;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -18,6 +19,7 @@
@Builder
@Slf4j
@FieldNameConstants
@Jacksonized
public class BizLog {

private Date date;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.arextest.schedule.model.bizlog;

import java.util.List;
import lombok.Data;

/**
* @author: QizhengMo
* @date: 2024/9/14 17:20
*/
@Data
public class LogUploadRequest {

List<BizLog> logs;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.arextest.schedule.service;

import com.arextest.schedule.dao.mongodb.ReplayBizLogRepository;
import com.arextest.schedule.model.bizlog.BizLog;
import com.arextest.schedule.model.bizlog.ReplayBizLogQueryCondition;
import com.arextest.schedule.model.dao.mongodb.ReplayBizLogCollection;
import java.util.Collections;
Expand Down Expand Up @@ -42,4 +43,8 @@ public long countBizLogsByPlanId(String planId, ReplayBizLogQueryCondition condi

return replayBizLogRepository.countByPlanId(planId, condition);
}

public void upload(List<BizLog> logs) {
replayBizLogRepository.saveAll(logs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.arextest.schedule.mdc.MDCTracer;
import com.arextest.schedule.model.CommonResponse;
import com.arextest.schedule.model.bizlog.LogUploadRequest;
import com.arextest.schedule.model.plan.BuildReplayFailReasonEnum;
import com.arextest.schedule.model.plan.BuildReplayPlanRequest;
import com.arextest.schedule.model.plan.BuildReplayPlanResponse;
Expand All @@ -11,9 +12,10 @@
import com.arextest.schedule.model.plan.QueryReplaySenderParametersResponse;
import com.arextest.schedule.model.plan.ReRunReplayPlanRequest;
import com.arextest.schedule.service.LocalReplayService;
import com.arextest.schedule.service.PlanBizLogService;
import com.arextest.schedule.service.PlanProduceService;
import javax.annotation.Resource;
import javax.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.http.MediaType;
Expand All @@ -30,14 +32,14 @@
@Slf4j
@Controller
@RequestMapping(path = "/api/replay/local/", produces = {MediaType.APPLICATION_JSON_VALUE})
@RequiredArgsConstructor
public class ReplayLocalController {

private static final String SUCCESS_DESC = "success";

@Resource
private LocalReplayService localReplayService;
@Resource
private PlanProduceService planProduceService;
private final LocalReplayService localReplayService;
private final PlanProduceService planProduceService;
private final PlanBizLogService planBizLogService;

@PostMapping(value = "/queryCaseId")
@ResponseBody
Expand Down Expand Up @@ -98,4 +100,11 @@ public CommonResponse queryReRunCaseId(@Valid @RequestBody ReRunReplayPlanReques
new BuildReplayPlanResponse(BuildReplayFailReasonEnum.UNKNOWN));
}
}

@PostMapping(value = "/log")
@ResponseBody
public CommonResponse log(@RequestBody LogUploadRequest request) {
planBizLogService.upload(request.getLogs());
return CommonResponse.successResponse(SUCCESS_DESC, true);
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,5 @@
<url>https://github.com/arextest/arex-replay-schedule</url>
</scm>
<url>https://github.com/arextest/arex-replay-schedule</url>
<version>1.2.19</version>
<version>1.2.20</version>
</project>

0 comments on commit 2a501ae

Please sign in to comment.