提交 2b864de9 authored 作者: 黄承天's avatar 黄承天

[feature]

增加一个接口 可根据测试用例id删除属于该测试用例的所有测试报告
上级 3b9314ab
......@@ -49,6 +49,13 @@ public class ReportController {
return ResponseEntity.ok(reports);
}
@ApiOperation(value = "根据测试用例id删除属于该测试用例的所有测试报告")
@DeleteMapping("/test/{testId}")
public ResponseEntity deleteAllByTestId(@PathVariable Integer testId) {
reportService.deleteAllByTestId(testId);
return ResponseEntity.ok(ImmutableMap.of("message", "操作成功"));
}
@ApiOperation(value = "根据id删除单个测试报告")
@DeleteMapping("/{id}")
public ResponseEntity deleteById(@PathVariable Integer id) {
......
......@@ -21,6 +21,12 @@ public class Project {
@ApiModelProperty(value = "项目名", example = "test", position = 2)
private String name;
@ApiModelProperty(value = "创建时间", example = "2020-11-20 09:30:00", position = 3)
private String createTime;
@ApiModelProperty(value = "最近更新时间", example = "2020-11-20 09:30:00", position = 4)
private String updateTime;
@JsonIgnore
@ApiModelProperty(value = "浏览器配置", example = "[\"chrome\", \"firefox\"]", position = 3)
private List<String> browsers;
......
......@@ -29,10 +29,10 @@ public class ProjectVo {
@ApiModelProperty(value = "操作系统", position = 4)
private String os;
@ApiModelProperty(value = "创建时间", position = 5)
@ApiModelProperty(value = "创建时间", example = "2020-11-20 09:30:00", position = 5)
private String createTime;
@ApiModelProperty(value = "更新时间", position = 6)
@ApiModelProperty(value = "更新时间", example = "2020-11-20 09:30:00", position = 6)
private String updateTime;
@ApiModelProperty(value = "测试用例数据", position = 7)
......
......@@ -69,6 +69,10 @@ public class ReportService {
reportRepository.deleteAllByProjectId(projectId);
}
public void deleteAllByTestId(Integer testId) {
reportRepository.findAllByTestId(testId);
}
public void deleteById(Integer id) {
if (reportRepository.existsById(id)) {
reportRepository.deleteById(id);
......
......@@ -12,6 +12,7 @@ import com.zjty.autotest.repository.ReportRepository;
import com.zjty.autotest.repository.TestCaseRepository;
import com.zjty.autotest.util.JsonUtil;
import com.zjty.autotest.util.TimeUtil;
import org.apache.tools.ant.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -145,6 +146,8 @@ public class TransHelper {
return new Project(
projectDo.getId(),
projectDo.getName(),
TimeUtil.getTime(projectDo.getCreateTime()),
TimeUtil.getTime(projectDo.getUpdateTime()),
null,
projectDo.getOs(),
null,
......
......@@ -2,20 +2,25 @@ package com.zjty.autotest.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
import java.util.TimeZone;
public class TimeUtil {
private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static String getTime(){
public static String getTime() {
Date date = new Date();
return format.format(date);
}
public static String getTime(Date date){
format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
return format.format(date);
public static String getTime(Date date) {
if (Objects.nonNull(date)) {
format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
return format.format(date);
} else {
return null;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论